mod directives
- module directives
Module for the various Sphinx directives for the Rust domain.
The module primarily provides the
Directive, which implements the various directives using directive specific structs. The enum and all directive specific structs implement bothRstContentandMdContenttraits. It also provides theDirectiveOptionenum, which implements the various options of the directive.The output of the directives is parsed by the
sphinxcontrib_rust.directives.RustDirectivewithin the Python extension.Modules
Re-exports
sphinx_rustdocgen::directives::crate_directive::CrateDirectivesphinx_rustdocgen::directives::directive_options::DirectiveVisibilitysphinx_rustdocgen::directives::enum_directive::EnumDirectivesphinx_rustdocgen::directives::executable_directive::ExecutableDirectivesphinx_rustdocgen::directives::function_directive::FunctionDirectivesphinx_rustdocgen::directives::impl_directive::ImplDirectivesphinx_rustdocgen::directives::macro_directive::MacroDirectivesphinx_rustdocgen::directives::module_directive::ModuleDirectivesphinx_rustdocgen::directives::struct_directive::StructDirectivesphinx_rustdocgen::directives::trait_directive::TraitDirectivesphinx_rustdocgen::directives::type_directive::TypeDirectivesphinx_rustdocgen::directives::variable_directive::VariableDirective
Types
- type ItemSections
Named type for the output of
order_items.
Macros
- macro push_sorted
Macro to sort and push items within a vec.
Functions
- fn extract_doc_from_attrs(attrs: &Vec<Attribute>) -> Vec<String>
Extract the docstring from the attrs of an item.
- Args:
- attrs:
syn::attr::Attributevec.
- Returns:
A vec of strings, where each string is a line of a documentation comment. If there are no documentation comments, an empty vec is returned.
- fn order_items(items: Vec<Directive>) -> ItemSections
Order the items for documentation
The items are ordered using the following rules:
If the item is a module without content, it is removed and a link to the module is added to the
toctree. If there are no such module, thetoctreeisn’t added.Each directive is then separated by type and ordered alphabetically except for
impldirectives.All
implblocks associated with a struct or enum are ordered after it, starting with the associatedimplblock, followed by traitimplblocks in alphabetical order.
It uses the
push_sorted!()macro.- Returns:
A vec of section names with their directives.
Enums
- enum Directive
The Sphinx directives that are implemented by the Rust domain.
- Crate(CrateDirective)
- Enum(EnumDirective)
- Executable(ExecutableDirective)
- Function(FunctionDirective)
- Impl(ImplDirective)
- Macro(MacroDirective)
- Module(ModuleDirective)
- Struct(StructDirective)
- Trait(TraitDirective)
- Type(TypeDirective)
- Use(UseDirective)
- Variable(VariableDirective)
Implementations
- impl Directive
Functions
- fn add_content<I: IntoIterator<Item = String>>(&mut self, content: I)
Add the content to the directive.
The content is appended to any existing content.
- fn change_parent(&mut self, new_parent: &str)
Change the parent of the directive.
- fn directive_visibility(&self) -> &DirectiveVisibility
Get the visibility of the directive.
- fn from_extern_item(parent_path: &str, item: &ForeignItem) -> Option<Directive>
Create the appropriate directive from the provided
syn::ForeignItem- Args:
- parent_path:
The path of the module which defines the items.
- item:
The foreign item to parse into a directive.
- Returns:
An option a
Directivevariant.
- fn from_extern_items<'a, T: Iterator<Item = &'a ForeignItem>>(parent_path: &str, items: T) -> Vec<Directive>
Create the appropriate directives from the provided
syn::ForeignItemiterator.- Args:
- parent_path:
The path of the trait which defines the items.
- items:
The foreign items to parse into a directive.
- Returns:
An vec of
Directivevariants.
- fn from_impl_item(parent_path: &str, item: &ImplItem, inherited_visibility: &Option<&Visibility>) -> Option<Directive>
Create the appropriate directive from the provided
syn::ImplItem- Args:
- parent_path:
The path of the impl block which defines the item.
- item:
The impl item to parse into a directive.
- Returns:
An option a
Directivevariant.
- fn from_impl_items<'a, T: Iterator<Item = &'a ImplItem>>(parent_path: &str, items: T, inherited_visibility: &Option<&Visibility>) -> Vec<Directive>
Create the appropriate directives from the provided
syn::ImplItemiterator.- Args:
- parent_path:
The path of the impl block which defines the items.
- items:
The impl items to parse into a directive.
- Returns:
An vec of
Directivevariants.
- fn from_item(parent_path: &str, item: &Item, inherited_visibility: &Option<&Visibility>) -> Option<Directive>
Create the appropriate directive from the provided
syn::Item- Args:
- parent_path:
The parent path of the item.
- item:
The item to parse into a directive.
- Returns:
An option a
Directivevariant.
- fn from_trait_item(parent_path: &str, item: &TraitItem, inherited_visibility: &Option<&Visibility>) -> Option<Directive>
Create the appropriate directive from the provided
syn::TraitItem- Args:
- parent_path:
The path of the trait which defines the items.
- item:
The trait item to parse into a directive.
- Returns:
An option a
Directivevariant.
- fn from_trait_items<'a, T: Iterator<Item = &'a TraitItem>>(parent_path: &str, items: T, inherited_visibility: &Option<&Visibility>) -> Vec<Directive>
Create the appropriate directives from the provided
syn::TraitItemiterator.- Args:
- parent_path:
The path of the module which defines the items.
- items:
The trait items to parse into a directive.
- Returns:
An vec of
Directivevariants.
- fn name(&self) -> &str
Traits implemented
- impl RstDirective for Directive
Functions
- fn get_rst_text(self, level: usize, max_visibility: &DirectiveVisibility) -> Vec<String>
- impl MdDirective for Directive
Functions
- fn fence_size(&self) -> usize
- fn get_md_text(self, fence_size: usize, max_visibility: &DirectiveVisibility) -> Vec<String>
Structs and Unions
- struct FileDirectives
- modules: Vec<ModuleDirective>
The directives for the modules defined in the file.
- impls: Vec<ImplDirective>
The directives for the impls defined in the file.
- uses: Vec<UseDirective>
The directives for the use statements in the file.
- items: Vec<Directive>
The directives for all other items in the file. This will never contain a module, impl or use directive.
Implementations
- impl FileDirectives
Functions
- fn claim_impls(&mut self, parent_name: &str, impls: Vec<ImplDirective>) -> Vec<ImplDirective>
- fn from_ast_items(runtime_configuration: &RuntimeConfiguration, ast_items: &Vec<Item>, module_parent: &SourceCodeFile) -> Self
Create new file directives from the AST of a file.
- Args:
- ast_items:
A list of items parsed by syn.
- module_parent:
The parent source code file to find modules under.