sphinxcontrib_rust

Init module for the extension with the setup function used by Sphinx

Functions

generate_docs(app)

Generate the Rust docs once the builder is ready.

setup(app)

Set up the extension

Classes

CrateConfiguration(crate_name, crate_dir, ...)

Dataclass for the crate configuration.

class sphinxcontrib_rust.CrateConfiguration(crate_name: str, crate_dir: str, doc_dir: str, format: str = 'rst', visibility: str = 'pub', force: bool = False, strip_src: bool = True)

Dataclass for the crate configuration.

This is the Python equivalent of sphinx_rustdocgen::Configuration. It is serialized as JSON and shared with the Rust executable.

classmethod from_sphinx_config(sphinx_config: Config) tuple[str, dict[str, CrateConfiguration]]

Extract the configuration for the crates from the Sphinx configuration.

The function mainly checks whether a given configuration option is global or per crate and creates the appropriate configuration for each crate. If all options are global, all crates will have the same configuration other than their crate_dir field.

Args:
config:

The Sphinx configuration.

Returns:

A tuple of the path of the executable for generating the docs and a dict of crate name to crate configuration mapping.

sphinxcontrib_rust.generate_docs(app: Sphinx)

Generate the Rust docs once the builder is ready.

Args:
app:

The Sphinx application.

config:

The parsed configuration.

sphinxcontrib_rust.setup(app: Sphinx) Mapping[str, Any]

Set up the extension

Modules

directives

Module for all the directive classes of the Rust domain

domain

Module for the rust Sphinx domain for documentation Rust items

index

Module for code related to generating the index of Rust items

items

Module for Rust items and related utility classes

nodes

Module for creating docutils nodes from the JSON in the layout option of the directives

rust_link

Module for enabling intra-doc links similar to Rustdoc