pub(crate) struct Context<'tcx> {
    pub(crate) current: Vec<Symbol>,
    pub(crate) dst: PathBuf,
    pub(super) render_redirect_pages: bool,
    pub(super) deref_id_map: FxHashMap<DefId, String>,
    pub(super) id_map: IdMap,
    pub(crate) shared: Rc<SharedContext<'tcx>>,
    pub(crate) include_sources: bool,
    pub(crate) types_with_notable_traits: FxHashSet<Type>,
}
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).

Fields§

§current: Vec<Symbol>

Current hierarchy of components leading down to what’s currently being rendered

§dst: PathBuf

The current destination folder of where HTML artifacts should be placed. This changes as the context descends into the module hierarchy.

§render_redirect_pages: bool

A flag, which when true, will render pages which redirect to the real location of an item. This is used to allow external links to publicly reused items to redirect to the right location.

§deref_id_map: FxHashMap<DefId, String>

Tracks section IDs for Deref targets so they match in both the main body and the sidebar.

§id_map: IdMap

The map used to ensure all generated ‘id=’ attributes are unique.

§shared: Rc<SharedContext<'tcx>>

Shared mutable state.

Issue for improving the situation: #82381

§include_sources: bool

This flag indicates whether source links should be generated or not. If the source files are present in the html rendering, then this will be true.

§types_with_notable_traits: FxHashSet<Type>

Collection of all types with notable traits referenced in the current module.

Implementations§

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.

Trait Implementations§

Generates the documentation for crate into the directory dst

Gives a description of the renderer. Used for performance profiling.
Whether to call item recursively for modules Read more
Sets up any state required for the renderer. When this is called the cache has already been populated. Read more
Make a new renderer to render a child of the item currently being rendered.
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.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

Layout§

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: 160 bytes