Crate sphinx_rustdocgen

crate sphinx_rustdocgen

Library for the sphinx-rustdocgen executable.

It consists of functions to extract content from the AST and to write the content to an RST or MD file. The crate is tested on itself, so all the documentation in the crate is in RST. The tests for Markdown are done on the dependencies.

Modules

Re-exports

Functions

fn traverse_crate(config: Configuration)

Traverse the crate and extract the docstrings for the items.

Args:
config:

The configuration for the crate.

Structs and Unions

struct Configuration

Struct to hold the deserialized configuration passed from Python.

crate_name: String

The name of the crate.

crate_dir: PathBuf

The directory containing the Cargo.toml file for the crate.

doc_dir: PathBuf

The directory under which to create the crate’s documentation. A new directory is created under this directory for the crate.

force: bool

Rebuild document for all files, even if it has not changed.

format: Format

The format to use for the output.

visibility: DirectiveVisibility

The required visibility of the items to include.

strip_src: bool

Whether to remove the src/ directory when generating the docs or not.

Implementations

impl Configuration

Functions

fn get_canonical_crate_dir(&self) -> PathBuf

Canonicalize the crate directory and return it.

struct RuntimeConfiguration

Runtime version of the configuration after validation and normalizing.

crate_name: String

The name of the crate in the configuration.

crate_dir: PathBuf

The crate’s root directory, the one which contains Cargo.toml.

src_dir: Option<PathBuf>

The crate’s src/ directory, if one is found and strip_src is true.

doc_dir: PathBuf

The directory under which to write the documents.

force: bool

Whether to rewrite all the documents, even the ones that are unchanged.

format: Format

The format of the docstrings.

max_visibility: DirectiveVisibility

Only document items with visibility less than this.

executables: Vec<SourceCodeFile>

The executables within the crate that will be documented.

lib: Option<SourceCodeFile>

The crate’s library to document, if any.

Implementations

impl RuntimeConfiguration

Functions

fn get_doc_file_name(&self, source_file_path: &Path) -> PathBuf

Returns the stem of the document file relative to the top level directory

fn write_doc_file(&self, source_file_path: &Path, file_top_level_directive: impl FileTopLevelDirective)

Write a documentation file for the provided source file path and content.

Args:
source_file_path:

The path of the source file corresponding to the content.

content_fn:

A function to extract the content for the file.

Traits implemented

impl From<Configuration> for RuntimeConfiguration

Functions

fn from(config: Configuration) -> Self

Create a validated and normalized version of the Configuration.