Crate sphinx-rustdocgen
- crate sphinx-rustdocgen
Library for the docextractor 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
Macros
- macro push_module_files
Macro to push the module files to the files vec for processing
- Args:
- files:
The files list to push the files to.
- parent:
The parent path of the module or crate’s file.
- directive:
The directive for the module or crate.
Functions
- fn find_mod_file (parent_path : & Path , module_directive : & ModuleDirective) -> PathBuf
Find the file for the module from provided parent path.
If the parent path is a directory, this calls
find_mod_file_underto locate the module’s file. If the parent path is a file name, it is assumed to be the path to the module’s parent module’s file. If the file name ismod.rs, the module’s file is searched under the same directory. Otherwise, it is searched under the directory with the same name as the parent module.- Args:
- parent_path:
The path to the file for the parent module of the current module.
- module_directive:
The directive for the module.
- Returns:
The path for the module’s source code file.
- Panics:
If the module’s file cannot be determined.
- fn find_mod_file_under (parent_dir : & Path , module_directive : & ModuleDirective) -> PathBuf
Find the file for the module under the parent directory.
The module’s source code file in this case can be
parent_dir/modname.rsorparent_dir/modname/mod.rs.- Args:
- parent_dir:
The directory under which to find the module’s file.
- module_directive:
The directive for the module.
- Returns:
The path for the module’s source code file.
- Panics:
If neither
parent_dir/modname.rsnorparent_dir/modname/mod.rsexist.
- fn traverse_crate (mut config : Configuration)
Traverse the crate and extract the docstrings for the items.
- Args:
- config:
The configuration for the crate.
Enums
- enum FileType
The different types of files that can be encountered. For each file, the name of the item within it is captured.
- Bin(String)
A binary executable’s source file.
- Lib(String)
The crate’s library file.
- Mod(String)
All other module files.
Structs and Unions
- Configuration
- crate_name: String
- src_dir: PathBuf
- doc_dir: PathBuf
- force: bool
- format: Format
- visibility: DirectiveVisibility
Impls
- impl Configuration
- fn canonicalize (& mut self) -> & mut Self
Canonicalize the source and documents directory.
The method checks that the directories exist and have proper permissions before updating them with their canonical paths.
Panics: * If the source directory is not a directory or cannot be accessed. * If the documents directory cannot be created.
- fn get_doc_file_name (& self , file_name : & Path) -> String