Skip to content

Commit

Permalink
Rollup merge of rust-lang#37102 - est31:rustdoc_question_mark, r=Guil…
Browse files Browse the repository at this point in the history
…laumeGomez

rustdoc: color the question mark operator

The idea of coloring `?` specially was proposed by @eddyb in: rust-lang#31436 (comment)
  • Loading branch information
Jonathan Turner committed Oct 14, 2016
2 parents ad40a42 + 87cbfb4 commit 3da9ddb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/librustdoc/html/highlight.rs
Expand Up @@ -104,6 +104,7 @@ pub enum Class {
Lifetime,
PreludeTy,
PreludeVal,
QuestionMark,
}

/// Trait that controls writing the output of syntax highlighting. Users should
Expand Down Expand Up @@ -237,8 +238,10 @@ impl<'a> Classifier<'a> {
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;
Expand Down Expand Up @@ -348,6 +351,7 @@ impl Class {
Class::Lifetime => "lifetime",
Class::PreludeTy => "prelude-ty",
Class::PreludeVal => "prelude-val",
Class::QuestionMark => "question-mark"
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/librustdoc/html/static/rustdoc.css
Expand Up @@ -570,6 +570,10 @@ 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: #ff9011;
font-weight: bold;
}

.rusttest { display: none; }
pre.rust { position: relative; }
Expand Down

0 comments on commit 3da9ddb

Please sign in to comment.