pub struct RendererInternals;Expand description
Unit struct containing renderer functions. Helpful because free functions are annoying.
Implementations§
Source§impl RendererInternals
impl RendererInternals
Sourcepub fn render_struct_definition(
md: &mut String,
name: &str,
s: &Struct,
krate: &Crate,
type_renderer: &TypeRenderer<'_>,
)
pub fn render_struct_definition( md: &mut String, name: &str, s: &Struct, krate: &Crate, type_renderer: &TypeRenderer<'_>, )
Render a struct definition code block to markdown.
Produces a heading with the struct name and generics, followed by a Rust code block showing the struct definition.
§Arguments
md- Output markdown stringname- The struct name (may differ from item.name for re-exports)s- The struct data from rustdockrate- The crate containing field definitionstype_renderer- Type renderer for generics and field types
Sourcepub fn render_struct_fields<F>(
md: &mut String,
fields: &[Id],
krate: &Crate,
type_renderer: &TypeRenderer<'_>,
process_docs: F,
)
pub fn render_struct_fields<F>( md: &mut String, fields: &[Id], krate: &Crate, type_renderer: &TypeRenderer<'_>, process_docs: F, )
Render documented struct fields to markdown.
Produces a “Fields” section with each documented field as a bullet point showing the field name, type, and documentation.
§Arguments
md- Output markdown stringfields- Field IDs from the structkrate- Crate containing field definitionstype_renderer- Type renderer for field typesprocess_docs- Closure to process documentation with intra-doc link resolution
Sourcepub fn render_enum_definition(
md: &mut String,
name: &str,
e: &Enum,
krate: &Crate,
type_renderer: &TypeRenderer<'_>,
)
pub fn render_enum_definition( md: &mut String, name: &str, e: &Enum, krate: &Crate, type_renderer: &TypeRenderer<'_>, )
Render an enum definition code block to markdown.
Produces a heading with the enum name and generics, followed by a Rust code block showing the enum definition with all variants.
§Arguments
md- Output markdown stringname- The enum name (may differ from item.name for re-exports)e- The enum data from rustdockrate- The crate containing variant definitionstype_renderer- Type renderer for generics and variant types
Sourcepub fn render_enum_variant(
md: &mut String,
variant: &Item,
krate: &Crate,
type_renderer: &TypeRenderer<'_>,
)
pub fn render_enum_variant( md: &mut String, variant: &Item, krate: &Crate, type_renderer: &TypeRenderer<'_>, )
Render a single enum variant within the definition code block.
Handles all three variant kinds: plain, tuple, and struct variants.
Sourcepub fn render_enum_variants_docs<F>(
md: &mut String,
variants: &[Id],
krate: &Crate,
process_docs: F,
)
pub fn render_enum_variants_docs<F>( md: &mut String, variants: &[Id], krate: &Crate, process_docs: F, )
Render documented enum variants to markdown.
Produces a “Variants” section with each documented variant as a bullet point.
§Arguments
md- Output markdown stringvariants- Variant IDs from the enumkrate- Crate containing variant definitionsprocess_docs- Closure to process documentation with intra-doc link resolution
Sourcepub fn render_function_definition(
md: &mut String,
name: &str,
f: &Function,
type_renderer: &TypeRenderer<'_>,
)
pub fn render_function_definition( md: &mut String, name: &str, f: &Function, type_renderer: &TypeRenderer<'_>, )
Render a function definition to markdown.
Produces a heading with the function name, followed by a Rust code block showing the full signature with modifiers (const, async, unsafe).
§Arguments
md- Output markdown stringname- The function namef- The function data from rustdoctype_renderer- Type renderer for parameter and return types
Sourcepub fn render_constant_definition(
md: &mut String,
name: &str,
type_: &Type,
const_: &Constant,
type_renderer: &TypeRenderer<'_>,
)
pub fn render_constant_definition( md: &mut String, name: &str, type_: &Type, const_: &Constant, type_renderer: &TypeRenderer<'_>, )
Render a constant definition to markdown.
Produces a heading with the constant name, followed by a Rust code block
showing const NAME: Type = value;.
§Arguments
md- Output markdown stringname- The constant nametype_- The constant’s typeconst_- The constant data including valuetype_renderer- Type renderer for the type
Sourcepub fn render_type_alias_definition(
md: &mut String,
name: &str,
ta: &TypeAlias,
type_renderer: &TypeRenderer<'_>,
)
pub fn render_type_alias_definition( md: &mut String, name: &str, ta: &TypeAlias, type_renderer: &TypeRenderer<'_>, )
Render a type alias definition to markdown.
Produces a heading with the alias name and generics, followed by a Rust
code block showing type Name<T> = TargetType;.
§Arguments
md- Output markdown stringname- The type alias nameta- The type alias data from rustdoctype_renderer- Type renderer for generics and the aliased type
Sourcepub fn render_macro_heading(md: &mut String, name: &str)
pub fn render_macro_heading(md: &mut String, name: &str)
Render a macro definition to markdown.
Produces a heading with the macro name and ! suffix.
Note: We don’t show macro rules since rustdoc JSON doesn’t provide them.
§Arguments
md- Output markdown stringname- The macro name
Sourcepub fn render_impl_items<F, L>(
md: &mut String,
impl_block: &Impl,
krate: &Crate,
type_renderer: &TypeRenderer<'_>,
process_docs: &Option<F>,
create_type_link: &Option<L>,
parent_type_name: Option<&str>,
impl_ctx: ImplContext<'_>,
full_method_docs: bool,
)
pub fn render_impl_items<F, L>( md: &mut String, impl_block: &Impl, krate: &Crate, type_renderer: &TypeRenderer<'_>, process_docs: &Option<F>, create_type_link: &Option<L>, parent_type_name: Option<&str>, impl_ctx: ImplContext<'_>, full_method_docs: bool, )
Render the items within an impl block.
This renders all methods, associated constants, and associated types within an impl block as bullet points.
§Arguments
md- Output markdown stringimpl_block- The impl block to render items fromkrate- The crate containing item definitionstype_renderer- Type renderer for typesprocess_docs- Optional closure to process documentationcreate_type_link- Optional closure to create links for types(id -> Option<markdown_link>)parent_type_name- Optional type name for generating method anchorsimpl_ctx- Context for anchor generation (inherent vs trait impl)
Sourcepub fn append_docs(md: &mut String, docs: Option<String>)
pub fn append_docs(md: &mut String, docs: Option<String>)
Append processed documentation to markdown.
Helper function to add documentation with consistent formatting.
Sourcepub fn render_collapsible_start(summary: &str) -> String
pub fn render_collapsible_start(summary: &str) -> String
Render the opening of a collapsible <details> block with a summary.
Produces HTML that creates a collapsible section in markdown. Use with
[render_collapsible_end] to close the block.
§Arguments
summary- The text to display in the summary line (clickable header)
§Example
use cargo_docs_md::generator::render_shared::RendererInternals;
let start = RendererInternals::render_collapsible_start("Derived Traits (9 implementations)");
assert!(start.contains("<details>"));
assert!(start.contains("<summary>Derived Traits (9 implementations)</summary>"));Sourcepub const fn render_collapsible_end() -> &'static str
pub const fn render_collapsible_end() -> &'static str
Render the closing of a collapsible <details> block.
Returns a static string to close a block opened with [render_collapsible_start].
§Example
use cargo_docs_md::generator::render_shared::RendererInternals;
assert_eq!(RendererInternals::render_collapsible_end(), "\n</details>\n\n");Sourcepub fn impl_sort_key(
impl_block: &Impl,
type_renderer: &TypeRenderer<'_>,
) -> String
pub fn impl_sort_key( impl_block: &Impl, type_renderer: &TypeRenderer<'_>, ) -> String
Generate a sort key for an impl block for deterministic ordering.
Combines trait name, generic params, and for-type to create a unique key.
Sourcepub fn render_source_location(
span: Option<&Span>,
source_path_config: Option<&SourcePathConfig>,
) -> String
pub fn render_source_location( span: Option<&Span>, source_path_config: Option<&SourcePathConfig>, ) -> String
Render a source location reference for an item.
Produces a small italicized line showing the source file and line range.
If source_path_config is provided, generates a clickable markdown link
relative to the current file’s location.
§Arguments
span- The source span from the itemsource_path_config- Optional configuration for path transformation
§Returns
A formatted markdown string with the source location, or empty string if span is None.
§Example Output (without config)
*Defined in `/home/user/.cargo/registry/src/.../serde-1.0.228/src/lib.rs:10-25`*§Example Output (with config, depth=2)
*Defined in [`serde-1.0.228/src/lib.rs:10-25`](../../.source_xxx/serde-1.0.228/src/lib.rs#L10-L25)*Sourcepub fn render_union_definition(
md: &mut String,
name: &str,
u: &Union,
krate: &Crate,
type_renderer: &TypeRenderer<'_>,
)
pub fn render_union_definition( md: &mut String, name: &str, u: &Union, krate: &Crate, type_renderer: &TypeRenderer<'_>, )
Render a union definition code block to markdown.
Produces a heading with the union name and generics, followed by a Rust code block showing the union definition with all fields.
§Arguments
md- Output markdown stringname- The union name (may differ from item.name for re-exports)u- The union data from rustdockrate- The crate containing field definitionstype_renderer- Type renderer for generics and field types
Sourcepub fn render_union_fields<F>(
md: &mut String,
fields: &[Id],
krate: &Crate,
type_renderer: &TypeRenderer<'_>,
process_docs: F,
)
pub fn render_union_fields<F>( md: &mut String, fields: &[Id], krate: &Crate, type_renderer: &TypeRenderer<'_>, process_docs: F, )
Render union fields documentation.
Creates a “Fields” section with each field’s name, type, and documentation. Only renders if at least one field has documentation.
§Arguments
md- Output markdown stringfields- Field IDs from the unionkrate- The crate containing field definitionstype_renderer- Type renderer for field typesprocess_docs- Callback to process documentation strings
Sourcepub fn render_static_definition(
md: &mut String,
name: &str,
s: &Static,
type_renderer: &TypeRenderer<'_>,
)
pub fn render_static_definition( md: &mut String, name: &str, s: &Static, type_renderer: &TypeRenderer<'_>, )
Render a static definition code block to markdown.
Produces a heading with the static name, followed by a Rust code block showing the static definition.
§Arguments
md- Output markdown stringname- The static name (may differ from item.name for re-exports)s- The static data from rustdoctype_renderer- Type renderer for the static’s type
Auto Trait Implementations§
impl Freeze for RendererInternals
impl RefUnwindSafe for RendererInternals
impl Send for RendererInternals
impl Sync for RendererInternals
impl Unpin for RendererInternals
impl UnwindSafe for RendererInternals
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more