From 6432bb71b63bc9e929aff8f93b5c55fe25d4b1d8 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 31 Oct 2022 13:12:51 -0700 Subject: [PATCH] rustdoc: rename syntax highlighting CSS class `attribute` to `attr` Link classes use the abbreviation `attr`, so why shouldn't syntax highlighting? --- src/librustdoc/html/highlight.rs | 2 +- src/librustdoc/html/highlight/fixtures/sample.html | 8 ++++---- src/librustdoc/html/highlight/tests.rs | 2 +- src/librustdoc/html/static/css/rustdoc.css | 2 +- src/test/rustdoc-gui/highlight-colors.goml | 10 +++++----- src/test/rustdoc/issue-41783.codeblock.html | 2 +- src/test/rustdoc/issue-41783.rs | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 28136cc48d658..cd8c8c463b1ab 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -362,7 +362,7 @@ impl Class { match self { Class::Comment => "comment", Class::DocComment => "doccomment", - Class::Attribute => "attribute", + Class::Attribute => "attr", Class::KeyWord => "kw", Class::RefKeyWord => "kw-2", Class::Self_(_) => "self", diff --git a/src/librustdoc/html/highlight/fixtures/sample.html b/src/librustdoc/html/highlight/fixtures/sample.html index 4a5a3cf609cd4..fced2eacd9e72 100644 --- a/src/librustdoc/html/highlight/fixtures/sample.html +++ b/src/librustdoc/html/highlight/fixtures/sample.html @@ -3,16 +3,16 @@ .kw { color: #8959A8; } .kw-2, .prelude-ty { color: #4271AE; } .number, .string { color: #718C00; } -.self, .bool-val, .prelude-val, .attribute, .attribute .ident { color: #C82829; } +.self, .bool-val, .prelude-val, .attr, .attr .ident { color: #C82829; } .macro, .macro-nonterminal { color: #3E999F; } .lifetime { color: #B76514; } .question-mark { color: #ff9011; } -
#![crate_type = "lib"]
+
#![crate_type = "lib"]
 
 use std::path::{Path, PathBuf};
 
-#[cfg(target_os = "linux")]
+#[cfg(target_os = "linux")]
 #[cfg(target_os = "windows")]
 fn main() -> () {
     let foo = true && false || true;
@@ -23,7 +23,7 @@
     mac!(foo, &mut bar);
     assert!(self.length < N && index <= self.length);
     ::std::env::var("gateau").is_ok();
-    #[rustfmt::skip]
+    #[rustfmt::skip]
     let s:std::path::PathBuf = std::path::PathBuf::new();
     let mut s = String::new();
 
diff --git a/src/librustdoc/html/highlight/tests.rs b/src/librustdoc/html/highlight/tests.rs
index a5e633df43448..2c93b9a097f40 100644
--- a/src/librustdoc/html/highlight/tests.rs
+++ b/src/librustdoc/html/highlight/tests.rs
@@ -9,7 +9,7 @@ const STYLE: &str = r#"
 .kw { color: #8959A8; }
 .kw-2, .prelude-ty { color: #4271AE; }
 .number, .string { color: #718C00; }
-.self, .bool-val, .prelude-val, .attribute, .attribute .ident { color: #C82829; }
+.self, .bool-val, .prelude-val, .attr, .attr .ident { color: #C82829; }
 .macro, .macro-nonterminal { color: #3E999F; }
 .lifetime { color: #B76514; }
 .question-mark { color: #ff9011; }
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index 894499e5c4fc9..ae1cef776a1f3 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -1092,7 +1092,7 @@ pre.rust .bool-val {
 pre.rust .self {
 	color: var(--code-highlight-self-color);
 }
-pre.rust .attribute {
+pre.rust .attr {
 	color: var(--code-highlight-attribute-color);
 }
 pre.rust .macro,
diff --git a/src/test/rustdoc-gui/highlight-colors.goml b/src/test/rustdoc-gui/highlight-colors.goml
index 51693314e85ef..ff1be389dcb07 100644
--- a/src/test/rustdoc-gui/highlight-colors.goml
+++ b/src/test/rustdoc-gui/highlight-colors.goml
@@ -15,7 +15,7 @@ define-function: (
         string,
         bool_val,
         self,
-        attribute,
+        attr,
         macro,
         question_mark,
         comment,
@@ -33,7 +33,7 @@ define-function: (
         ("assert-css", ("pre.rust .string", {"color": |string|}, ALL)),
         ("assert-css", ("pre.rust .bool-val", {"color": |bool_val|}, ALL)),
         ("assert-css", ("pre.rust .self", {"color": |self|}, ALL)),
-        ("assert-css", ("pre.rust .attribute", {"color": |attribute|}, ALL)),
+        ("assert-css", ("pre.rust .attr", {"color": |attr|}, ALL)),
         ("assert-css", ("pre.rust .macro", {"color": |macro|}, ALL)),
         ("assert-css", ("pre.rust .question-mark", {"color": |question_mark|}, ALL)),
         ("assert-css", ("pre.rust .comment", {"color": |comment|}, ALL)),
@@ -52,7 +52,7 @@ call-function: ("check-colors", {
     "string": "rgb(184, 204, 82)",
     "bool_val": "rgb(255, 119, 51)",
     "self": "rgb(54, 163, 217)",
-    "attribute": "rgb(230, 225, 207)",
+    "attr": "rgb(230, 225, 207)",
     "macro": "rgb(163, 122, 204)",
     "question_mark": "rgb(255, 144, 17)",
     "comment": "rgb(120, 135, 151)",
@@ -69,7 +69,7 @@ call-function: ("check-colors", {
     "string": "rgb(131, 163, 0)",
     "bool_val": "rgb(238, 104, 104)",
     "self": "rgb(238, 104, 104)",
-    "attribute": "rgb(238, 104, 104)",
+    "attr": "rgb(238, 104, 104)",
     "macro": "rgb(62, 153, 159)",
     "question_mark": "rgb(255, 144, 17)",
     "comment": "rgb(141, 141, 139)",
@@ -86,7 +86,7 @@ call-function: ("check-colors", {
     "string": "rgb(113, 140, 0)",
     "bool_val": "rgb(200, 40, 41)",
     "self": "rgb(200, 40, 41)",
-    "attribute": "rgb(200, 40, 41)",
+    "attr": "rgb(200, 40, 41)",
     "macro": "rgb(62, 153, 159)",
     "question_mark": "rgb(255, 144, 17)",
     "comment": "rgb(142, 144, 140)",
diff --git a/src/test/rustdoc/issue-41783.codeblock.html b/src/test/rustdoc/issue-41783.codeblock.html
index 89987491d1b46..3bca4536cd5b6 100644
--- a/src/test/rustdoc/issue-41783.codeblock.html
+++ b/src/test/rustdoc/issue-41783.codeblock.html
@@ -1,5 +1,5 @@
 # single
 ## double
 ### triple
-#[outer]
+#[outer]
 #![inner]
diff --git a/src/test/rustdoc/issue-41783.rs b/src/test/rustdoc/issue-41783.rs
index 87267a750c615..769f984a274a7 100644
--- a/src/test/rustdoc/issue-41783.rs
+++ b/src/test/rustdoc/issue-41783.rs
@@ -1,10 +1,10 @@
 // @has issue_41783/struct.Foo.html
 // @!hasraw - 'space'
 // @!hasraw - 'comment'
-// @hasraw - '#[outer]'
-// @!hasraw - '#[outer]'
+// @hasraw - '#[outer]'
+// @!hasraw - '#[outer]'
 // @hasraw - '#![inner]'
-// @!hasraw - '#![inner]'
+// @!hasraw - '#![inner]'
 // @snapshot 'codeblock' - '//*[@class="rustdoc-toggle top-doc"]/*[@class="docblock"]//pre/code'
 
 /// ```no_run