mod directives

module directives

Modules

Re-exports

Types

type ItemSections

Named type for the output of order_items.

Macros

macro push_sorted
macro visibility_to_inherit

DRY macro to check which visibility value to pass to inner items.

Functions

fn extract_doc_from_attrs(attrs: &Vec<Attribute>) -> Vec<String>

Extract the docstring from the attrs of an item.

Args:
attrs:

syn::attr::Attribute vec.

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:

  1. 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, the toctree isn’t added.

  2. Each directive is then separated by type and ordered alphabetically except for impl directives.

  3. All impl blocks associated with a struct or enum are ordered after it, starting with the associated impl block, followed by trait impl blocks in alphabetical order.

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)

Functions

fn add_content<I: IntoIterator<Item = String>>(&mut self, content: I)
fn change_parent(&mut self, new_parent: &str)
fn directive_visibility(&self) -> &DirectiveVisibility
fn from_extern_item(parent_path: &str, item: &ForeignItem) -> Option<Directive>
fn from_extern_items<'a, T: Iterator<Item = &'a ForeignItem>>(parent_path: &str, items: T) -> Vec<Directive>
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 Directive variant.

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::ImplItem iterator.

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 Directive variants.

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 Directive variant.

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 Directive variant.

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::TraitItem iterator.

Args:
parent_path:

The path of the trait which defines the items.

items:

The trait items to parse into a directive.

Returns:

An vec of Directive variants.

fn name(&self) -> &str

Traits implemented

impl RstDirective for Directive
fn get_rst_text(self, level: usize, max_visibility: &DirectiveVisibility) -> Vec<String>
impl MdDirective for Directive
fn get_md_text(self, fence_size: usize, max_visibility: &DirectiveVisibility) -> Vec<String>
fn fence_size(&self) -> usize

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.

Functions

fn claim_impls(&mut self, parent_name: &str, impls: Vec<ImplDirective>) -> Vec<ImplDirective>
fn from_ast_items(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.