Skip to content

Commit

Permalink
Rollup merge of rust-lang#91534 - jsha:heading-color, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Make rustdoc headings black, and markdown blue

Demo:

https://rustdoc.crud.net/jsha/heading-color/std/string/index.html#structs
https://rustdoc.crud.net/jsha/heading-color/std/string/struct.String.html#examples

Fixes rust-lang#91304

r? `@camelid` /cc `@GuillaumeGomez`

(Note: we may want to make rustdoc headings and markdown headings the same color -- rust-lang#90245 -- but we would want to do that intentionally; this is fixing up a change that did so accidentally)
  • Loading branch information
matthiaskrgr authored Dec 8, 2021
2 parents 840df40 + e1ff02b commit ed57588
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
let (short, name) = item_ty_to_strs(myty.unwrap());
write!(
w,
"<h2 id=\"{id}\" class=\"section-header\">\
"<h2 id=\"{id}\" class=\"small-section-header\">\
<a href=\"#{id}\">{name}</a>\
</h2>\n{}",
ITEM_TABLE_OPEN,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ a {
a.srclink,
a#toggle-all-docs,
a.anchor,
.section-header a,
.small-section-header a,
#source-sidebar a,
pre.rust a,
.sidebar a,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ a {
a.srclink,
a#toggle-all-docs,
a.anchor,
.section-header a,
.small-section-header a,
#source-sidebar a,
pre.rust a,
.sidebar a,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ a {
a.srclink,
a#toggle-all-docs,
a.anchor,
.section-header a,
.small-section-header a,
#source-sidebar a,
pre.rust a,
.sidebar a,
Expand Down
15 changes: 12 additions & 3 deletions src/test/rustdoc-gui/headers-color.goml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use
assert-css: ("#method\.must_use", {"color": "rgb(197, 197, 197)", "background-color": "rgba(255, 236, 164, 0.06)"}, ALL)

goto: file://|DOC_PATH|/test_docs/index.html
assert-css: (".section-header a", {"color": "rgb(197, 197, 197)"}, ALL)
assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL)

goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
assert-css: (".section-header a", {"color": "rgb(57, 175, 215)"}, ALL)

// Dark theme
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
Expand All @@ -34,7 +37,10 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use
assert-css: ("#method\.must_use", {"color": "rgb(221, 221, 221)", "background-color": "rgb(73, 74, 61)"}, ALL)

goto: file://|DOC_PATH|/test_docs/index.html
assert-css: (".section-header a", {"color": "rgb(221, 221, 221)"}, ALL)
assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL)

goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
assert-css: (".section-header a", {"color": "rgb(210, 153, 29)"}, ALL)

// Light theme
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
Expand All @@ -52,4 +58,7 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.must_use
assert-css: ("#method\.must_use", {"color": "rgb(0, 0, 0)", "background-color": "rgb(253, 255, 211)"}, ALL)

goto: file://|DOC_PATH|/test_docs/index.html
assert-css: (".section-header a", {"color": "rgb(0, 0, 0)"}, ALL)
assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL)

goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
assert-css: (".section-header a", {"color": "rgb(56, 115, 173)"}, ALL)

0 comments on commit ed57588

Please sign in to comment.