Skip to content

Commit a7c25b2

Browse files
committed
rustdoc: clean up .out-of-band/.in-band CSS
* Remove the `float: right` fallback from the main header, which hasn't been needed since IE11 support was dropped. * Remove `in-band` from low-level headers, which hasn't been needed since `.rightside` switched to `float: right` in 593d6d1 * Remove unreachable `.in-band > code, .in-band > .code-header` CSS, since the `in-band` class was attached to the `code-header` itself, not nested directly below it. * Use `rem` instead of `em` for code header margins. * This results in a slight change in spacing around impls and item-info, but since it makes it more consistent with the way methods are presented, it's probably fine.
1 parent f3fafbb commit a7c25b2

File tree

6 files changed

+16
-22
lines changed

6 files changed

+16
-22
lines changed

src/librustdoc/html/render/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,7 @@ pub(crate) fn render_impl_summary(
17901790
write!(w, "<section id=\"{}\" class=\"impl has-srclink\"{}>", id, aliases);
17911791
render_rightside(w, cx, &i.impl_item, containing_item, RenderMode::Normal);
17921792
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
1793-
write!(w, "<h3 class=\"code-header in-band\">");
1793+
write!(w, "<h3 class=\"code-header\">");
17941794

17951795
if let Some(use_absolute) = use_absolute {
17961796
write!(w, "{}", inner_impl.print(use_absolute, cx));

src/librustdoc/html/static/css/rustdoc.css

+7-12
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ h4.code-header {
176176
border-bottom-style: none;
177177
margin: 0;
178178
padding: 0;
179-
margin-top: 0.6em;
180-
margin-bottom: 0.4em;
179+
margin-top: 0.6rem;
180+
margin-bottom: 0.4rem;
181181
}
182182
.impl,
183183
.impl-items .method,
@@ -658,18 +658,17 @@ h2.location a {
658658
overflow-x: auto;
659659
}
660660

661-
.content .out-of-band {
661+
.out-of-band {
662662
flex-grow: 0;
663663
font-size: 1.125rem;
664664
font-weight: normal;
665-
float: right;
666665
}
667666

668667
.method > .code-header, .trait-impl > .code-header {
669668
display: block;
670669
}
671670

672-
.content .in-band {
671+
.in-band {
673672
flex-grow: 1;
674673
margin: 0px;
675674
padding: 0px;
@@ -682,10 +681,6 @@ h2.location a {
682681
background-color: var(--main-background-color);
683682
}
684683

685-
.in-band > code, .in-band > .code-header {
686-
display: inline-block;
687-
}
688-
689684
.docblock code, .docblock-short code,
690685
pre, .rustdoc.source .example-wrap {
691686
background-color: var(--code-block-background-color);
@@ -1731,13 +1726,13 @@ in storage.js plus the media query with (min-width: 701px)
17311726
flex-direction: column;
17321727
}
17331728

1734-
.content .out-of-band {
1729+
.out-of-band {
17351730
text-align: left;
17361731
margin-left: initial;
17371732
padding: initial;
17381733
}
17391734

1740-
.content .out-of-band .since::before {
1735+
.out-of-band .since::before {
17411736
content: "Since ";
17421737
}
17431738

@@ -1969,7 +1964,7 @@ in storage.js plus the media query with (min-width: 701px)
19691964
}
19701965

19711966
@media print {
1972-
nav.sidebar, nav.sub, .content .out-of-band, a.srclink, #copy-path,
1967+
nav.sidebar, nav.sub, .out-of-band, a.srclink, #copy-path,
19731968
details.rustdoc-toggle[open] > summary::before, details.rustdoc-toggle > summary::before,
19741969
details.rustdoc-toggle.top-doc > summary {
19751970
display: none;

src/librustdoc/html/static/js/main.js

-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ function loadCss(cssFileName) {
555555
const code = document.createElement("h3");
556556
code.innerHTML = struct[TEXT_IDX];
557557
addClass(code, "code-header");
558-
addClass(code, "in-band");
559558

560559
onEachLazy(code.getElementsByTagName("a"), elem => {
561560
const href = elem.getAttribute("href");

src/test/rustdoc-gui/headers-color.goml

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ assert-css: (
1919
)
2020
assert-css: (
2121
".impl .code-header",
22-
{"color": "rgb(230, 225, 207)", "background-color": "rgb(15, 20, 25)"},
22+
{"color": "rgb(230, 225, 207)", "background-color": "rgba(0, 0, 0, 0)"},
2323
ALL,
2424
)
2525

@@ -58,7 +58,7 @@ assert-css: (
5858
)
5959
assert-css: (
6060
".impl .code-header",
61-
{"color": "rgb(221, 221, 221)", "background-color": "rgb(53, 53, 53)"},
61+
{"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"},
6262
ALL,
6363
)
6464

@@ -95,7 +95,7 @@ assert-css: (
9595
)
9696
assert-css: (
9797
".impl .code-header",
98-
{"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"},
98+
{"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
9999
ALL,
100100
)
101101

src/test/rustdoc-gui/implementors.goml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ assert-count: ("#implementors-list .impl", 2)
88
assert: ("#implementors-list .impl:nth-child(1) > a.anchor")
99
assert-attribute: ("#implementors-list .impl:nth-child(1)", {"id": "impl-Whatever-for-Struct"})
1010
assert-attribute: ("#implementors-list .impl:nth-child(1) > a.anchor", {"href": "#impl-Whatever-for-Struct"})
11-
assert: "#implementors-list .impl:nth-child(1) > .code-header.in-band"
11+
assert: "#implementors-list .impl:nth-child(1) > .code-header"
1212

1313
assert: ("#implementors-list .impl:nth-child(2) > a.anchor")
1414
assert-attribute: ("#implementors-list .impl:nth-child(2)", {"id": "impl-Whatever-1"})
1515
assert-attribute: ("#implementors-list .impl:nth-child(2) > a.anchor", {"href": "#impl-Whatever-1"})
16-
assert: "#implementors-list .impl:nth-child(2) > .code-header.in-band"
16+
assert: "#implementors-list .impl:nth-child(2) > .code-header"
1717

1818
goto: file://|DOC_PATH|/test_docs/struct.HasEmptyTraits.html
1919
compare-elements-position-near-false: (
2020
"#impl-EmptyTrait1-for-HasEmptyTraits",
2121
"#impl-EmptyTrait2-for-HasEmptyTraits",
22-
{"y": 30},
22+
{"y": 34.1875},
2323
)
2424
compare-elements-position-near: (
2525
"#impl-EmptyTrait3-for-HasEmptyTraits h3",
2626
"#impl-EmptyTrait3-for-HasEmptyTraits .item-info",
27-
{"y": 30},
27+
{"y": 34.1875},
2828
)
2929

3030
// Now check that re-exports work correctly.

src/test/rustdoc-gui/src-font-size.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html
55
show-text: true
66
// Check the impl headers.
77
assert-css: (".impl.has-srclink .srclink", {"font-size": "16px"}, ALL)
8-
assert-css: (".impl.has-srclink .code-header.in-band", {"font-size": "18px"}, ALL)
8+
assert-css: (".impl.has-srclink .code-header", {"font-size": "18px"}, ALL)
99
// Check the impl items.
1010
assert-css: (".impl-items .has-srclink .srclink", {"font-size": "16px"}, ALL)
1111
assert-css: (".impl-items .has-srclink .code-header", {"font-size": "16px"}, ALL)

0 commit comments

Comments
 (0)