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 impl documentation

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

Directive for handling macro 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

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>, 'toc': <function unchanged>, 'vis': <function unchanged>}

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 impl 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 macro 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.

This is a meta-directive that does not add content. Instead, it adds the used names for the document to the domain data and any re-exports to the domain items.

Note

This inherits from RustDirective only to make it easier to work with. It does not behave like other directives.

has_content = False

May the directive have content?

option_spec: ClassVar[OptionSpec] = {'reexport': <function unchanged>, 'used_name': <function unchanged_required>}

Mapping of option names to validator functions.

run()

Main directive entry function, called by docutils upon encountering the directive.

This directive is meant to be quite easily subclassable, so it delegates to several additional methods. What it does:

  • find out if called as a domain-specific directive, set self.domain

  • create a desc node to fit all description inside

  • parse standard options, currently no-index

  • create an index node if needed as self.indexnode

  • parse all given signatures (as returned by self.get_signatures()) using self.handle_signature(), which should either return a name or raise ValueError

  • add index entries using self.add_target_and_index()

  • parse the content and handle doc fields in it

property rust_item_type: RustItemType

The Rust object type for the directive

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