From 6a89b8fd0a02c358caa524486a27d0a447624ecd Mon Sep 17 00:00:00 2001 From: est31 Date: Wed, 12 Oct 2016 05:23:37 +0200 Subject: [PATCH 1/2] rustdoc: color the question mark operator The idea was proposed by eddyb in: https://github.com/rust-lang/rust/issues/31436#issuecomment-247426582 --- src/librustdoc/html/highlight.rs | 8 ++++++-- src/librustdoc/html/static/rustdoc.css | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 881352cb73e18..d1fe7853445f2 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -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 @@ 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; @@ -348,6 +351,7 @@ impl Class { Class::Lifetime => "lifetime", Class::PreludeTy => "prelude-ty", Class::PreludeVal => "prelude-val", + Class::QuestionMark => "question-mark" } } } diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index f8133ea49ceba..d8f9173c52477 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -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; } From 87cbfb455fc5cb1d7fe0bedfe7aae42e6d3c4b15 Mon Sep 17 00:00:00 2001 From: est31 Date: Wed, 12 Oct 2016 14:48:13 +0200 Subject: [PATCH 2/2] Change color and make ? bold --- src/librustdoc/html/static/rustdoc.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index d8f9173c52477..85ec4fe3f3f4d 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -571,7 +571,8 @@ 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; + color: #ff9011; + font-weight: bold; } .rusttest { display: none; }