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,
}
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 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
.
Implementations
sourceimpl<'tcx> Context<'tcx>
impl<'tcx> Context<'tcx>
pub(crate) fn tcx(&self) -> TyCtxt<'tcx>
pub(crate) fn cache(&self) -> &Cache
pub(super) fn sess(&self) -> &'tcx Session
pub(super) fn derive_id(&mut self, id: String) -> String
sourcepub(super) fn root_path(&self) -> String
pub(super) fn root_path(&self) -> String
String representation of how to get back to the root path of the ‘doc/’ folder in terms of a relative URL.
fn render_item(&mut self, it: &Item, is_module: bool) -> String
Construct a map of items shown in the sidebar to a plain-text summary of their docs.
sourcepub(super) fn src_href(&self, item: &Item) -> Option<String>
pub(super) fn src_href(&self, item: &Item) -> Option<String>
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.
pub(crate) fn href_from_span(
&self,
span: Span,
with_lines: bool
) -> Option<String>
pub(crate) fn href_from_span_relative(
&self,
span: Span,
relative_to: &str
) -> Option<String>
Trait Implementations
sourceimpl<'tcx> FormatRenderer<'tcx> for Context<'tcx>
impl<'tcx> FormatRenderer<'tcx> for Context<'tcx>
Generates the documentation for crate
into the directory dst
sourcefn descr() -> &'static str
fn descr() -> &'static str
sourceconst RUN_ON_MODULE: bool = true
const RUN_ON_MODULE: bool = true
item
recursively for modules Read moresourcefn init(
krate: Crate,
options: RenderOptions,
cache: Cache,
tcx: TyCtxt<'tcx>
) -> Result<(Self, Crate), Error>
fn init(
krate: Crate,
options: RenderOptions,
cache: Cache,
tcx: TyCtxt<'tcx>
) -> Result<(Self, Crate), Error>
sourcefn make_child_renderer(&self) -> Self
fn make_child_renderer(&self) -> Self
sourcefn after_krate(&mut self) -> Result<(), Error>
fn after_krate(&mut self) -> Result<(), Error>
sourcefn mod_item_in(&mut self, item: &Item) -> Result<(), Error>
fn mod_item_in(&mut self, item: &Item) -> Result<(), Error>
sourcefn mod_item_out(&mut self) -> Result<(), Error>
fn mod_item_out(&mut self) -> Result<(), Error>
sourcefn item(&mut self, item: Item) -> Result<(), Error>
fn item(&mut self, item: Item) -> Result<(), Error>
fn cache(&self) -> &Cache
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
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: 128 bytes