Struct rustdoc::html::render::context::Context [−][src]
pub(crate) struct Context<'tcx> {
pub(crate) current: Vec<String>,
pub(super) dst: PathBuf,
pub(super) render_redirect_pages: bool,
pub(super) id_map: RefCell<IdMap>,
pub(super) deref_id_map: RefCell<FxHashMap<DefId, String>>,
pub(super) shared: Rc<SharedContext<'tcx>>,
pub(super) cache: Rc<Cache>,
}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<String>Expand description
Current hierarchy of components leading down to what’s currently being rendered
dst: PathBufExpand description
The current destination folder of where HTML artifacts should be placed. This changes as the context descends into the module hierarchy.
render_redirect_pages: boolExpand description
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.
id_map: RefCell<IdMap>Expand description
The map used to ensure all generated ‘id=’ attributes are unique.
deref_id_map: RefCell<FxHashMap<DefId, String>>Expand description
Tracks section IDs for Deref targets so they match in both the main
body and the sidebar.
Expand description
Shared mutable state.
Issue for improving the situation: #82381
cache: Rc<Cache>Expand description
The Cache used during rendering.
Ideally the cache would be in SharedContext, but it’s mutated
between when the SharedContext is created and when Context
is created, so more refactoring would be needed.
It’s immutable once in Context, so it’s not as bad that it’s not in
SharedContext.
Implementations
impl<'tcx> Context<'tcx>[src]
impl<'tcx> Context<'tcx>[src]pub(crate) fn tcx(&self) -> TyCtxt<'tcx>[src]
pub(crate) fn cache(&self) -> &Cache[src]
pub(super) fn sess(&self) -> &'tcx Session[src]
pub(super) fn derive_id(&self, id: String) -> String[src]
pub(super) fn root_path(&self) -> String[src]
pub(super) fn root_path(&self) -> String[src]String representation of how to get back to the root path of the ‘doc/’ folder in terms of a relative URL.
fn render_item(&self, it: &Item, is_module: bool) -> String[src]
fn build_sidebar_items(
&self,
m: &Module
) -> BTreeMap<String, Vec<(String, Option<String>)>>[src]
fn build_sidebar_items(
&self,
m: &Module
) -> BTreeMap<String, Vec<(String, Option<String>)>>[src]Construct a map of items shown in the sidebar to a plain-text summary of their docs.
pub(super) fn src_href(&self, item: &Item) -> Option<String>[src]
pub(super) fn src_href(&self, item: &Item) -> Option<String>[src]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.
impl Context<'_>[src]
impl Context<'_>[src]fn suffix_path(&self, filename: &str) -> PathBuf[src]
fn write_shared<C: AsRef<[u8]>>(
&self,
resource: SharedResource<'_>,
contents: C,
emit: &[EmitType]
) -> Result<(), Error>[src]
&self,
resource: SharedResource<'_>,
contents: C,
emit: &[EmitType]
) -> Result<(), Error>
fn write_minify(
&self,
resource: SharedResource<'_>,
contents: &str,
minify: bool,
emit: &[EmitType]
) -> Result<(), Error>[src]
&self,
resource: SharedResource<'_>,
contents: &str,
minify: bool,
emit: &[EmitType]
) -> Result<(), Error>
Trait Implementations
impl<'tcx> FormatRenderer<'tcx> for Context<'tcx>[src]
impl<'tcx> FormatRenderer<'tcx> for Context<'tcx>[src]Generates the documentation for crate into the directory dst
const RUN_ON_MODULE: bool[src]
const RUN_ON_MODULE: bool[src]Whether to call item recursivly for modules Read more
fn init(
krate: Crate,
options: RenderOptions,
cache: Cache,
tcx: TyCtxt<'tcx>
) -> Result<(Self, Crate), Error>[src]
fn init(
krate: Crate,
options: RenderOptions,
cache: Cache,
tcx: TyCtxt<'tcx>
) -> Result<(Self, Crate), Error>[src]Sets up any state required for the renderer. When this is called the cache has already been populated. Read more
fn make_child_renderer(&self) -> Self[src]
fn make_child_renderer(&self) -> Self[src]Make a new renderer to render a child of the item currently being rendered.
fn after_krate(&mut self) -> Result<(), Error>[src]
fn after_krate(&mut self) -> Result<(), Error>[src]Post processing hook for cleanup and dumping output to files.
fn mod_item_in(&mut self, item: &Item) -> Result<(), Error>[src]
fn mod_item_in(&mut self, item: &Item) -> Result<(), Error>[src]Renders a module (should not handle recursing into children).
fn mod_item_out(&mut self) -> Result<(), Error>[src]
fn mod_item_out(&mut self) -> Result<(), Error>[src]Runs after recursively rendering all sub-items of a module.
fn item(&mut self, item: Item) -> Result<(), Error>[src]
fn item(&mut self, item: Item) -> Result<(), Error>[src]Renders a single non-module item. This means no recursive sub-item rendering is required.
fn cache(&self) -> &Cache[src]
Auto Trait Implementations
impl<'tcx> !RefUnwindSafe for Context<'tcx>
impl<'tcx> !Send for Context<'tcx>
impl<'tcx> !Sync for Context<'tcx>
impl<'tcx> Unpin for Context<'tcx>
impl<'tcx> !UnwindSafe for Context<'tcx>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T[src]
impl<T> Instrument for T[src]fn instrument(self, span: Span) -> Instrumented<Self>[src]
fn instrument(self, span: Span) -> Instrumented<Self>[src]Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>[src]
fn in_current_span(self) -> Instrumented<Self>[src]impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>, pub fn vzip(self) -> V
impl<T> WithConstness for T[src]
impl<T> WithConstness for T[src]fn with_constness(self, constness: Constness) -> ConstnessAnd<Self>[src]
fn with_const(self) -> ConstnessAnd<Self>[src]
fn without_const(self) -> ConstnessAnd<Self>[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,