Function rustdoc::html::highlight::write_code

source ·
pub(super) fn write_code(
    out: &mut impl Write,
    src: &str,
    href_context: Option<HrefContext<'_, '_>>,
    decoration_info: Option<DecorationInfo>
)
Expand description

Convert the given src source code into HTML by adding classes for highlighting.

This code is used to render code blocks (in the documentation) as well as the source code pages.

Some explanations on the last arguments:

In case we are rendering a code block and not a source code file, href_context will be None. To put it more simply: if href_context is None, the code won’t try to generate links to an item definition.

More explanations about spans and how we use them here are provided in the