Context in rustdoc::html::render::context - Rust (original) (raw)
pub(crate) struct Context<'tcx> {
pub(crate) current: Vec<Symbol>,
pub(crate) dst: PathBuf,
pub(super) deref_id_map: RefCell<DefIdMap<String>>,
pub(super) id_map: RefCell<IdMap>,
pub(crate) shared: SharedContext<'tcx>,
pub(crate) types_with_notable_traits: RefCell<FxIndexSet<Type>>,
pub(crate) info: ContextInfo,
}
Expand description
Major driving force in all rustdoc rendering. This contains information about where in the tree-like hierarchy rendering is occurring and controls how the current page is being rendered.
It is intended that this context is a lightweight object which can be fairly easily cloned because it is cloned per work-job (about once per item in the rustdoc tree).
Current hierarchy of components leading down to what’s currently being rendered
The current destination folder of where HTML artifacts should be placed. This changes as the context descends into the module hierarchy.
Tracks section IDs for Deref
targets so they match in both the main body and the sidebar.
The map used to ensure all generated ‘id=’ attributes are unique.
Shared mutable state.
Issue for improving the situation: #82381
Collection of all types with notable traits referenced in the current module.
Contains information that needs to be saved and reset after rendering an item which is not a module.
String representation of how to get back to the root path of the ‘doc/’ folder in terms of a relative URL.
Construct a map of items shown in the sidebar to a plain-text summary of their docs.
Generates a url appropriate for an href
attribute back to the source of this item.
The url generated, when clicked, will redirect the browser back to the original source code.
If None
is returned, then a source link couldn’t be generated. This may happen, for example, with externally inlined items where the source of their crate documentation isn’t known.
Generates the documentation for crate
into the directory dst
Whether to call item
recursively for modules Read more
This associated type is the type where the current module information is stored. Read more
Gives a description of the renderer. Used for performance profiling.
Sets up any state required for the renderer. When this is called the cache has already been populated.
This method is called right before call Self::item. This method returns a type containing information that needs to be reset after the Self::item method has been called with the Self::restore_module_data method. Read more
Used to reset current module’s information.
Post processing hook for cleanup and dumping output to files.
Renders a module (should not handle recursing into children).
Runs after recursively rendering all sub-items of a module.
Renders a single non-module item. This means no recursive sub-item rendering is required.
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 2352 bytes