提交 6a89b8fd 编写于 作者: E est31

rustdoc: color the question mark operator

The idea was proposed by eddyb in: https://github.com/rust-lang/rust/issues/31436#issuecomment-247426582
上级 304d0c8d
......@@ -104,6 +104,7 @@ pub enum Class {
Lifetime,
PreludeTy,
PreludeVal,
QuestionMark,
}
/// Trait that controls writing the output of syntax highlighting. Users should
......@@ -237,8 +238,10 @@ fn write_token<W: Writer>(&mut self,
token::Dot | token::DotDot | token::DotDotDot | token::Comma | token::Semi |
token::Colon | token::ModSep | token::LArrow | token::OpenDelim(_) |
token::CloseDelim(token::Brace) | token::CloseDelim(token::Paren) |
token::CloseDelim(token::NoDelim) |
token::Question => Class::None,
token::CloseDelim(token::NoDelim) => Class::None,
token::Question => Class::QuestionMark,
token::Dollar => {
if self.lexer.peek().tok.is_ident() {
self.in_macro_nonterminal = true;
......@@ -348,6 +351,7 @@ pub fn rustdoc_class(self) -> &'static str {
Class::Lifetime => "lifetime",
Class::PreludeTy => "prelude-ty",
Class::PreludeVal => "prelude-val",
Class::QuestionMark => "question-mark"
}
}
}
......
......@@ -570,6 +570,9 @@ pre.rust .self, pre.rust .bool-val, pre.rust .prelude-val,
pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; }
pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; }
pre.rust .lifetime { color: #B76514; }
pre.rust .question-mark {
color: #c67e2d;
}
.rusttest { display: none; }
pre.rust { position: relative; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册