Trait rustdoc::html::highlight::Writer [] [src]

pub trait Writer {
    fn enter_span(&mut self, _: Class) -> Result<()>;
    fn exit_span(&mut self) -> Result<()>;
    fn string<T: Display>(&mut self,
                          _: T,
                          _: Class,
                          _: Option<&TokenAndSpan>)
                          -> Result<()>; }
🔬 This is a nightly-only experimental API. (rustdoc)

Trait that controls writing the output of syntax highlighting. Users should implement this trait to customise writing output.

The classifier will call into the Writer implementation as it finds spans of text to highlight. Exactly how that text should be highlighted is up to the implementation.

Required Methods

🔬 This is a nightly-only experimental API. (rustdoc)

Called when we start processing a span of text that should be highlighted. The Class argument specifies how it should be highlighted.

🔬 This is a nightly-only experimental API. (rustdoc)

Called at the end of a span of highlighted text.

🔬 This is a nightly-only experimental API. (rustdoc)

Called for a span of text, usually, but not always, a single token. If the string of text (T) does correspond to a token, then the token will also be passed. If the text should be highlighted differently from the surrounding text, then the Class argument will be a value other than None. The following sequences of callbacks are equivalent: plain enter_span(Foo), string("text", None), exit_span() string("text", Foo) The latter can be thought of as a shorthand for the former, which is more flexible.

Implementors