mod module_directive
- module module_directive
Implementation of the
rust:moduledirectiveFunctions
- fn find_file_under_dir(module_ident: &str, directory: &Path) -> Option<PathBuf>
Find the file for the module under the provided directory.
- Args:
- module_ident:
The identifier of the module.
- directory:
The directory under which to find the module’s file.
- Returns:
A None value if neither
<directory>/<module>.rsnor<directory>/<module>/mod.rsexist, otherwise a Some value for the path of the file.
- fn has_test_token(tokens: &str) -> bool
Check if the module is a test module or not.
Structs and Unions
- struct ModuleAttrs
Module attributes
- is_test: bool
Whether the module is a test module or not
- path: PathBuf
Path to the module
Implementations
- impl ModuleAttrs
Functions
- fn get_module_file(module_ident: &str, parent_file: &SourceCodeFile) -> PathBuf
Create a file path for the module’s source code and documentation.
If the module is defined in its own file, the function will try to find the file and return its path. Otherwise, it will return a hypothetical path as if the module were defined in a
mod.rsfile in its own directory. This is mainly to prevent conflicts with existing files of the same name.
- fn parse_module_attrs(item_mod: &ItemMod, parent_file: &SourceCodeFile) -> ModuleAttrs
Parse module attrs
- struct ModuleDirective
Struct to hold data for a module’s documentation.
- name: String
The full path to the module.
- options: Vec<DirectiveOption>
The options for the module directive.
- content: Vec<String>
The docstring for the module.
- ident: String
The identifier of the module (i.e. the final portion of name).
- doc_file: PathBuf
The path to directive’s documentation file
- source_code_file: SourceCodeFile
The source code file for the module.
- file_directives: FileDirectives
The directives within the crate’s document file.
Implementations
- impl ModuleDirective
Variables
- const DIRECTIVE_NAME: &'static str
Functions
- fn change_parent(&mut self, new_parent: &str)
Change the parent module of the module.
- fn claim_impls(&mut self, impls: Vec<ImplDirective>) -> Vec<ImplDirective>
Attach impl directives to the appropriate struct, enum or trait directive.
- Args:
- impls:
The impl directives to claim from.
- Returns:
A vec of impl directives that were not claimed.
- fn collect_impls(&mut self) -> Vec<ImplDirective>
Collect all impl directives from self and any sub-modules.
- fn directive_visibility(&self) -> &DirectiveVisibility
Return the visibility of this directive.
- fn filter_items(&mut self, max_visibility: &DirectiveVisibility) -> Vec<Directive>
Filter out items that will not be documented due to visibility restrictions.
The function recurses through all submodules and identifies items that will not be documented due to the configured visibility. As part of the filtering, it will also identify any re-exports that should be inlined.
- Returns:
A vec of directives that will not be documented.
- fn from_item(rc: &RuntimeConfiguration, parent_file: &SourceCodeFile, item: &ItemMod) -> Option<Self>
Create a
ModuleDirectivefrom the item, if the module is not a test module.If the module’s items are in a different file, the function will try to find the appropriate file and parse it for the items. This is done recursively for any submodules within the items.
- Args:
- parent_path:
The path of the module’s parent module or the crate name.
- item:
The
ItemModparsed out bysyn.
- Returns:
A
Somevalue if the module is not a test module, otherwiseNone.
Traits implemented
- impl RstDirective for ModuleDirective
Functions
- fn get_rst_text(self, level: usize, max_visibility: &DirectiveVisibility) -> Vec<String>
- impl MdDirective for ModuleDirective
Functions
- fn fence_size(&self) -> usize
- fn get_md_text(self, fence_size: usize, max_visibility: &DirectiveVisibility) -> Vec<String>
- impl FileTopLevelDirective for ModuleDirective
Functions
- fn get_doc_file(&self) -> &Path
- fn get_text(self, format: &Format, max_visibility: &DirectiveVisibility) -> Vec<String>