Skip to content

Commit

Permalink
rustdoc: clean up .out-of-band/.in-band CSS
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
notriddle committed Sep 25, 2022
1 parent f3fafbb commit a7c25b2
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ pub(crate) fn render_impl_summary(
write!(w, "<section id=\"{}\" class=\"impl has-srclink\"{}>", id, aliases);
render_rightside(w, cx, &i.impl_item, containing_item, RenderMode::Normal);
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
write!(w, "<h3 class=\"code-header in-band\">");
write!(w, "<h3 class=\"code-header\">");

if let Some(use_absolute) = use_absolute {
write!(w, "{}", inner_impl.print(use_absolute, cx));
Expand Down
19 changes: 7 additions & 12 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ h4.code-header {
border-bottom-style: none;
margin: 0;
padding: 0;
margin-top: 0.6em;
margin-bottom: 0.4em;
margin-top: 0.6rem;
margin-bottom: 0.4rem;
}
.impl,
.impl-items .method,
Expand Down Expand Up @@ -658,18 +658,17 @@ h2.location a {
overflow-x: auto;
}

.content .out-of-band {
.out-of-band {
flex-grow: 0;
font-size: 1.125rem;
font-weight: normal;
float: right;
}

.method > .code-header, .trait-impl > .code-header {
display: block;
}

.content .in-band {
.in-band {
flex-grow: 1;
margin: 0px;
padding: 0px;
Expand All @@ -682,10 +681,6 @@ h2.location a {
background-color: var(--main-background-color);
}

.in-band > code, .in-band > .code-header {
display: inline-block;
}

.docblock code, .docblock-short code,
pre, .rustdoc.source .example-wrap {
background-color: var(--code-block-background-color);
Expand Down Expand Up @@ -1731,13 +1726,13 @@ in storage.js plus the media query with (min-width: 701px)
flex-direction: column;
}

.content .out-of-band {
.out-of-band {
text-align: left;
margin-left: initial;
padding: initial;
}

.content .out-of-band .since::before {
.out-of-band .since::before {
content: "Since ";
}

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

@media print {
nav.sidebar, nav.sub, .content .out-of-band, a.srclink, #copy-path,
nav.sidebar, nav.sub, .out-of-band, a.srclink, #copy-path,
details.rustdoc-toggle[open] > summary::before, details.rustdoc-toggle > summary::before,
details.rustdoc-toggle.top-doc > summary {
display: none;
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ function loadCss(cssFileName) {
const code = document.createElement("h3");
code.innerHTML = struct[TEXT_IDX];
addClass(code, "code-header");
addClass(code, "in-band");

onEachLazy(code.getElementsByTagName("a"), elem => {
const href = elem.getAttribute("href");
Expand Down
6 changes: 3 additions & 3 deletions src/test/rustdoc-gui/headers-color.goml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ assert-css: (
)
assert-css: (
".impl .code-header",
{"color": "rgb(230, 225, 207)", "background-color": "rgb(15, 20, 25)"},
{"color": "rgb(230, 225, 207)", "background-color": "rgba(0, 0, 0, 0)"},
ALL,
)

Expand Down Expand Up @@ -58,7 +58,7 @@ assert-css: (
)
assert-css: (
".impl .code-header",
{"color": "rgb(221, 221, 221)", "background-color": "rgb(53, 53, 53)"},
{"color": "rgb(221, 221, 221)", "background-color": "rgba(0, 0, 0, 0)"},
ALL,
)

Expand Down Expand Up @@ -95,7 +95,7 @@ assert-css: (
)
assert-css: (
".impl .code-header",
{"color": "rgb(0, 0, 0)", "background-color": "rgb(255, 255, 255)"},
{"color": "rgb(0, 0, 0)", "background-color": "rgba(0, 0, 0, 0)"},
ALL,
)

Expand Down
8 changes: 4 additions & 4 deletions src/test/rustdoc-gui/implementors.goml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ assert-count: ("#implementors-list .impl", 2)
assert: ("#implementors-list .impl:nth-child(1) > a.anchor")
assert-attribute: ("#implementors-list .impl:nth-child(1)", {"id": "impl-Whatever-for-Struct"})
assert-attribute: ("#implementors-list .impl:nth-child(1) > a.anchor", {"href": "#impl-Whatever-for-Struct"})
assert: "#implementors-list .impl:nth-child(1) > .code-header.in-band"
assert: "#implementors-list .impl:nth-child(1) > .code-header"

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

goto: file://|DOC_PATH|/test_docs/struct.HasEmptyTraits.html
compare-elements-position-near-false: (
"#impl-EmptyTrait1-for-HasEmptyTraits",
"#impl-EmptyTrait2-for-HasEmptyTraits",
{"y": 30},
{"y": 34.1875},
)
compare-elements-position-near: (
"#impl-EmptyTrait3-for-HasEmptyTraits h3",
"#impl-EmptyTrait3-for-HasEmptyTraits .item-info",
{"y": 30},
{"y": 34.1875},
)

// Now check that re-exports work correctly.
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/src-font-size.goml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ goto: file://|DOC_PATH|/test_docs/struct.Foo.html
show-text: true
// Check the impl headers.
assert-css: (".impl.has-srclink .srclink", {"font-size": "16px"}, ALL)
assert-css: (".impl.has-srclink .code-header.in-band", {"font-size": "18px"}, ALL)
assert-css: (".impl.has-srclink .code-header", {"font-size": "18px"}, ALL)
// Check the impl items.
assert-css: (".impl-items .has-srclink .srclink", {"font-size": "16px"}, ALL)
assert-css: (".impl-items .has-srclink .code-header", {"font-size": "16px"}, ALL)

0 comments on commit a7c25b2

Please sign in to comment.