rustdoc::html::highlight - Rust (original) (raw)
Expand description
Basic syntax highlighting functionality.
This module uses librustc_astβs lexer to provide token-based highlighting for the HTML documentation generated by rustdoc.
Use the render_with_highlighting
to highlight some rust code.
Classifier π
Processes program tokens, classifying strings of text by highlighting category (Class
).
DecorationInfo π
Decorations are represented as a map from CSS class to vector of character ranges. Each range will be wrapped in a span with that class.
Decorations π
Custom spans inserted into the source. Eg βscrape-examples uses this to highlight function calls
HrefContext π
This type is needed in case we want to render links on items to allow to go to their definition.
LineInfo π
PeekIter π
This iterator comes from the same idea than βPeekableβ except that it allows to βpeekβ more than just the next item by using peek_next
. The peek
method always returns the next item after the current one whereas peek_next
will return the next item after the last one peeked.
TokenHandler π
This type is used as a conveniency to prevent having to pass all its fields as arguments into the various functions (which became its methods).
TokenIter π
Class π
How a span of text is classified. Mostly corresponds to token kinds.
Highlight π
Tooltip π
can_merge π
Check if two Class
can be merged together. In the following rules, βunclassifiedβ means None
basically (since itβs Option<Class>
). The following rules apply:
empty_line_number π
enter_span π
Called when we start processing a span of text that should be highlighted. The Class
argument specifies how it should be highlighted.
exit_span π
Called at the end of a span of highlighted text.
get_real_ident_class π
Classifies into identifier class; returns None
if this is a non-keyword identifier.
render_example_with_highlighting π
Highlights src
as an inline example, returning the HTML output.
string π
Called for a span of text. If the text should be highlighted differently from the surrounding text, then the Class
argument will be a value other than None
.
string_without_closing_tag π
This function writes text
into out
with some modifications depending on klass
:
write_code π
Convert the given src
source code into HTML by adding classes for highlighting.
write_footer π
write_header π
write_line_number π