Skip to content

Commit a7d45de

Browse files
authored
Rollup merge of #102280 - notriddle:notriddle/band, r=GuillaumeGomez
rustdoc: clean up `.out-of-band`/`.in-band` CSS | | method | impl |--------|--------|------ | before | ![image](https://user-images.githubusercontent.com/1593513/192164603-dea9befb-0f5f-4bd5-a44d-1f8328e27955.png) | ![image](https://user-images.githubusercontent.com/1593513/192164642-06f958cb-8fd5-4b73-bdb7-d2778f358f80.png) | after | ![image](https://user-images.githubusercontent.com/1593513/192164612-f72ee8db-c87c-477c-99e8-283b1cf0c14b.png) | ![image](https://user-images.githubusercontent.com/1593513/192164653-8e628dc3-5bf3-4ce8-829b-06e27a90fe06.png) * 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. Preview: http://notriddle.com/notriddle-rustdoc-demos/band/std/fs/struct.File.html
2 parents beb2240 + a50081e commit a7d45de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+159
-165
lines changed

src/librustdoc/html/render/mod.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 12 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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},
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},
2828
)
2929

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

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

Lines changed: 1 addition & 1 deletion
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)

src/test/rustdoc/anonymous-lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub trait Stream {
1212
}
1313

1414
// @has 'foo/trait.Stream.html'
15-
// @has - '//*[@class="code-header in-band"]' 'impl<S: ?Sized + Stream + Unpin> Stream for &mut S'
15+
// @has - '//*[@class="code-header"]' 'impl<S: ?Sized + Stream + Unpin> Stream for &mut S'
1616
impl<S: ?Sized + Stream + Unpin> Stream for &mut S {
1717
type Item = S::Item;
1818

src/test/rustdoc/assoc-consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub trait Foo {
1313
pub struct Bar;
1414

1515
impl Foo for Bar {
16-
// @has assoc_consts/struct.Bar.html '//h3[@class="code-header in-band"]' 'impl Foo for Bar'
16+
// @has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Foo for Bar'
1717
// @has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize'
1818
const FOO: usize = 12;
1919
// @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
@@ -81,7 +81,7 @@ pub trait Qux {
8181
const QUX_DEFAULT2: u32 = 3;
8282
}
8383

84-
// @has assoc_consts/struct.Bar.html '//h3[@class="code-header in-band"]' 'impl Qux for Bar'
84+
// @has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Qux for Bar'
8585
impl Qux for Bar {
8686
// @has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8'
8787
// @has - '//*[@class="docblock"]' "Docs for QUX0 in trait."

src/test/rustdoc/blanket-reexport-item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![crate_name = "foo"]
22

3-
// @has foo/struct.S.html '//*[@id="impl-Into%3CU%3E-for-S"]//h3[@class="code-header in-band"]' 'impl<T, U> Into<U> for T'
3+
// @has foo/struct.S.html '//*[@id="impl-Into%3CU%3E-for-S"]//h3[@class="code-header"]' 'impl<T, U> Into<U> for T'
44
pub struct S2 {}
55
mod m {
66
pub struct S {}

src/test/rustdoc/const-generics/add-impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub struct Simd<T, const WIDTH: usize> {
77
inner: T,
88
}
99

10-
// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header in-band"]' 'impl Add<Simd<u8, 16>> for Simd<u8, 16>'
10+
// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl Add<Simd<u8, 16>> for Simd<u8, 16>'
1111
impl Add for Simd<u8, 16> {
1212
type Output = Self;
1313

0 commit comments

Comments
 (0)