cargo_wiki/generators/
mod.rs

1use anyhow::Result;
2use rustdoc_types::{Id, Item, ItemSummary};
3use std::collections::HashMap;
4
5pub mod generic_gen;
6pub mod module_gen;
7pub mod struct_gen;
8pub mod type_gen;
9pub mod visibility_gen;
10
11pub type Index = HashMap<Id, Item>;
12pub type Paths = HashMap<Id, ItemSummary>;
13pub type ExternalCrates = HashMap<u32, rustdoc_types::ExternalCrate>;
14
15/// A collection of generic generator functions. All the generators that implement this trait are
16/// of those types that have a whole file based for them.
17///
18/// **NOTE:** [ModuleGenerator](module_gen::ModuleGenerator) doesn't follow `Generator` trait even
19/// though module have a whole file for them as this is a special kind of generator.
20pub trait Generator {
21    fn generate_syntax(
22        item: &Item,
23        index: &Index,
24        paths: &Paths,
25        external_crates: &ExternalCrates,
26    ) -> Result<String>;
27}