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
  593d6d1cb1

* 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.
This commit is contained in:
Michael Howell 2022-09-25 13:09:22 -07:00
parent f3fafbb006
commit a7c25b2957
6 changed files with 16 additions and 22 deletions

View File

@ -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));

View File

@ -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,
@ -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;
@ -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);
@ -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 ";
}
@ -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;

View File

@ -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");

View File

@ -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,
)
@ -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,
)
@ -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,
)

View File

@ -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.

View File

@ -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)