pub(crate) trait FormatRenderer<'tcx>: Sized {
const RUN_ON_MODULE: bool;
// Required methods
fn descr() -> &'static str;
fn init(
krate: Crate,
options: RenderOptions,
cache: Cache,
tcx: TyCtxt<'tcx>,
) -> Result<(Self, Crate), Error>;
fn make_child_renderer(&self) -> Self;
fn item(&mut self, item: Item) -> Result<(), Error>;
fn mod_item_in(&mut self, item: &Item) -> Result<(), Error>;
fn after_krate(&mut self) -> Result<(), Error>;
fn cache(&self) -> &Cache;
// Provided method
fn mod_item_out(&mut self) -> Result<(), Error> { ... }
}
Expand description
Allows for different backends to rustdoc to be used with the run_format()
function. Each
backend renderer has hooks for initialization, documenting an item, entering and exiting a
module, and cleanup/finalizing output.
Required Associated Constants§
Sourceconst RUN_ON_MODULE: bool
const RUN_ON_MODULE: bool
Whether to call item
recursively for modules
This is true for html, and false for json. See #80664
Required Methods§
Sourcefn descr() -> &'static str
fn descr() -> &'static str
Gives a description of the renderer. Used for performance profiling.
Sourcefn 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>
Sets up any state required for the renderer. When this is called the cache has already been populated.
Sourcefn make_child_renderer(&self) -> Self
fn make_child_renderer(&self) -> Self
Make a new renderer to render a child of the item currently being rendered.
Sourcefn item(&mut self, item: Item) -> Result<(), Error>
fn item(&mut self, item: Item) -> Result<(), Error>
Renders a single non-module item. This means no recursive sub-item rendering is required.
Sourcefn mod_item_in(&mut self, item: &Item) -> Result<(), Error>
fn mod_item_in(&mut self, item: &Item) -> Result<(), Error>
Renders a module (should not handle recursing into children).
Sourcefn after_krate(&mut self) -> Result<(), Error>
fn after_krate(&mut self) -> Result<(), Error>
Post processing hook for cleanup and dumping output to files.
fn cache(&self) -> &Cache
Provided Methods§
Sourcefn mod_item_out(&mut self) -> Result<(), Error>
fn mod_item_out(&mut self) -> Result<(), Error>
Runs after recursively rendering all sub-items of a module.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl<'tcx> FormatRenderer<'tcx> for Context<'tcx>
impl<'tcx> FormatRenderer<'tcx> for Context<'tcx>
Generates the documentation for crate
into the directory dst