sphinxcontrib_rust.directives

Module for all the directive classes of the Rust domain

Classes

RustCrateDirective(name, arguments, options, ...)

Directive for handling crate documentation

RustDirective(name, arguments, options, ...)

Base class for Rust directives.

RustEnumDirective(name, arguments, options, ...)

Directive for handling enum documentation

RustExecutableDirective(name, arguments, ...)

Directive for handling executable documentation

RustFunctionDirective(name, arguments, ...)

Directive for handling function documentation

RustImplDirective(name, arguments, options, ...)

Directive for handling function documentation

RustMacroDirective(name, arguments, options, ...)

Directive for handling function documentation

RustModuleDirective(name, arguments, ...)

Directive for handling module documentation

RustStructDirective(name, arguments, ...)

Directive for handling struct documentation

RustTraitDirective(name, arguments, options, ...)

Directive for handling trait documentation

RustTypeDirective(name, arguments, options, ...)

Directive for handling type documentation

RustUseDirective(name, arguments, options, ...)

Directive for handling the use statements in the file.

RustVariableDirective(name, arguments, ...)

Directive for handling type documentation

class sphinxcontrib_rust.directives.RustCrateDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Directive for handling crate documentation

property rust_item_type: RustItemType

The Rust object type for the directive

class sphinxcontrib_rust.directives.RustDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Base class for Rust directives.

This class implements most of the logic for the directives. For each directive, there is a subclass that overrides any directive specific behaviour.

The input for the directives is generated with the Rust code in sphinx-rustdocgen::directives

add_target_and_index(name: Sequence[str], sig: str, signode: desc_signature) None

Adds the item to the domain and generates the index for it.

This is called after handle_signature() has executed.

Args:
name:

The name of the item, which is the return value from handle_signature().

sig:

The argument to the directive, which is the Rust path of the item set by the Rust doc generator.

signode:

The docutils node of the for item.

classmethod get_directives() dict[RustItemType, Type[RustDirective]]

Get all the directives for the object types

get_signatures() list[str]

Override the default get_signatures method, which splits the signatures by line.

Currently, only one signature is allowed for each Rust object, and due to the use of where on new lines, it is all part of one signature. Only the final newline is removed.

See Also:
handle_signature(sig: str, signode: desc_signature) ObjDescT

Handle the directive and generate its display signature.

The display signature is what is displayed instead of the directive name and options in the generated output. The :sig: option of the directive is used to override the provided sig value. If the option is not set, the item type and the final component of the path are used.

Raising ValueError will put the sig value into a single node, which is what the super implementation does.

Args:
sig:

The argument of the directive as set during doc generation, not the :sig: option. The Rust side of the code will put the full Rust path of the item as the argument.

signode:

The docutils node for the item, to which the display signature nodes should be appended.

Returns:

The path for the object, which is a tuple of the Rust path components and defines the hierarchy of the object for indexing.

option_spec: ClassVar[OptionSpec] = {'index': <function RustDirective.<lambda>>, 'layout': <function unchanged>, 'sig': <function unchanged>, 'toc': <function unchanged>, 'vis': <function unchanged_required>}

Mapping of option names to validator functions.

abstract property rust_item_type: RustItemType

The Rust object type for the directive

class sphinxcontrib_rust.directives.RustEnumDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Directive for handling enum documentation

property rust_item_type: RustItemType

The Rust object type for the directive

class sphinxcontrib_rust.directives.RustExecutableDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Directive for handling executable documentation

property rust_item_type: RustItemType

The Rust object type for the directive

class sphinxcontrib_rust.directives.RustFunctionDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Directive for handling function documentation

property rust_item_type: RustItemType

The Rust object type for the directive

class sphinxcontrib_rust.directives.RustImplDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Directive for handling function documentation

property rust_item_type: RustItemType

The Rust object type for the directive

class sphinxcontrib_rust.directives.RustMacroDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Directive for handling function documentation

property rust_item_type: RustItemType

The Rust object type for the directive

class sphinxcontrib_rust.directives.RustModuleDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Directive for handling module documentation

property rust_item_type: RustItemType

The Rust object type for the directive

class sphinxcontrib_rust.directives.RustStructDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Directive for handling struct documentation

property rust_item_type: RustItemType

The Rust object type for the directive

class sphinxcontrib_rust.directives.RustTraitDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Directive for handling trait documentation

property rust_item_type: RustItemType

The Rust object type for the directive

class sphinxcontrib_rust.directives.RustTypeDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Directive for handling type documentation

property rust_item_type: RustItemType

The Rust object type for the directive

class sphinxcontrib_rust.directives.RustUseDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Directive for handling the use statements in the file.

When the directive is encountered, all the options to the directive are added to the domain data for the document as potential links.

This is not an object description and does not inherit from RustDirective. It also has no content.

group_arguments() list[tuple[str, str]]

Collect data into non-overlapping fixed-length chunks or blocks.

has_content = False

May the directive have content?

optional_arguments = 999

Number of optional arguments after the required arguments.

class sphinxcontrib_rust.directives.RustVariableDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Directive for handling type documentation

property rust_item_type: RustItemType

The Rust object type for the directive