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.
StructsΒ§
- Class
Info π - Class
Stack π - This represents the stack of HTML elements. For example a macro expansion will contain other elements which might themselves contain other elements (like macros).
- Classifier π
- Processes program tokens, classifying strings of text by highlighting
category (
Class). - Decoration
Info π - 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
- Href
Context π - This type is needed in case we want to render links on items to allow to go to their definition.
- Line
Info π - Peek
Iter π - 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. Thepeekmethod always returns the next item after the current one whereaspeek_nextwill return the next item after the last one peeked. - Token
Handler π - 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).
- Token
Iter π
EnumsΒ§
- Class π
- How a span of text is classified. Mostly corresponds to token kinds.
- Highlight π
- Line
Number πKind - Represents the type of line number to be generated as HTML.
- Tooltip π
ConstantsΒ§
- NON_
MACRO_ πKEYWORDS - Used to know if a keyword followed by a
!should never be treated as a macro.
FunctionsΒ§
- can_
merge π - Check if two
Classcan be merged together. In the following rules, βunclassifiedβ meansNonebasically (since itβsOption<Class>). The following rules apply: - classify π
- end_
expansion π - generate_
link_ πto_ def - get_
expansion π - get_
next_ πexpansion - is_
keyword π - new_
span π - Convenient wrapper to create a
Spanfrom a position in the file. - render_
example_ πwith_ highlighting - Highlights
srcas an inline example, returning the HTML output. - string_
without_ πclosing_ tag - This function writes
textintooutwith some modifications depending onklass: - write_
code π - Convert the given
srcsource code into HTML by adding classes for highlighting. - write_
footer π - write_
header π