Skip to content

Commit 1d328de

Browse files
committed
rustdoc: rename CSS rustdoc-toggle -> toggle and toggle -> settings-toggle
This swaps things around so that the class that gets used more often has the shorter name.
1 parent 0b90256 commit 1d328de

19 files changed

+117
-117
lines changed

src/librustdoc/html/render/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ fn document_full_inner(
513513
debug!("Doc block: =====\n{}\n=====", s);
514514
if is_collapsible {
515515
w.write_str(
516-
"<details class=\"rustdoc-toggle top-doc\" open>\
516+
"<details class=\"toggle top-doc\" open>\
517517
<summary class=\"hideme\">\
518518
<span>Expand description</span>\
519519
</summary>",
@@ -1514,7 +1514,7 @@ fn render_impl(
15141514
let toggled = !doc_buffer.is_empty();
15151515
if toggled {
15161516
let method_toggle_class = if item_type.is_method() { " method-toggle" } else { "" };
1517-
write!(w, "<details class=\"rustdoc-toggle{}\" open><summary>", method_toggle_class);
1517+
write!(w, "<details class=\"toggle{}\" open><summary>", method_toggle_class);
15181518
}
15191519
match &*item.kind {
15201520
clean::MethodItem(..) | clean::TyMethodItem(_) => {
@@ -1730,7 +1730,7 @@ fn render_impl(
17301730
close_tags.insert_str(0, "</details>");
17311731
write!(
17321732
w,
1733-
"<details class=\"rustdoc-toggle implementors-toggle\"{}>",
1733+
"<details class=\"toggle implementors-toggle\"{}>",
17341734
if rendering_params.toggle_open_by_default { " open" } else { "" }
17351735
);
17361736
write!(w, "<summary>")
@@ -2999,7 +2999,7 @@ fn render_call_locations(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Ite
29992999
if it.peek().is_some() {
30003000
write!(
30013001
w,
3002-
"<details class=\"rustdoc-toggle more-examples-toggle\">\
3002+
"<details class=\"toggle more-examples-toggle\">\
30033003
<summary class=\"hideme\">\
30043004
<span>More examples</span>\
30053005
</summary>\

src/librustdoc/html/render/print_item.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn should_hide_fields(n_fields: usize) -> bool {
204204
fn toggle_open(w: &mut Buffer, text: impl fmt::Display) {
205205
write!(
206206
w,
207-
"<details class=\"rustdoc-toggle type-contents-toggle\">\
207+
"<details class=\"toggle type-contents-toggle\">\
208208
<summary class=\"hideme\">\
209209
<span>Show {}</span>\
210210
</summary>",
@@ -733,7 +733,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
733733
let toggled = !content.is_empty();
734734
if toggled {
735735
let method_toggle_class = if item_type.is_method() { " method-toggle" } else { "" };
736-
write!(w, "<details class=\"rustdoc-toggle{method_toggle_class}\" open><summary>");
736+
write!(w, "<details class=\"toggle{method_toggle_class}\" open><summary>");
737737
}
738738
write!(w, "<section id=\"{}\" class=\"method has-srclink\">", id);
739739
render_rightside(w, cx, m, t, RenderMode::Normal);
@@ -1840,7 +1840,7 @@ fn document_non_exhaustive(w: &mut Buffer, item: &clean::Item) {
18401840
if item.is_non_exhaustive() {
18411841
write!(
18421842
w,
1843-
"<details class=\"rustdoc-toggle non-exhaustive\">\
1843+
"<details class=\"toggle non-exhaustive\">\
18441844
<summary class=\"hideme\"><span>{}</span></summary>\
18451845
<div class=\"docblock\">",
18461846
{

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

+36-36
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ main {
317317
margin-right: auto;
318318
}
319319

320-
details:not(.rustdoc-toggle) summary {
320+
details:not(.toggle) summary {
321321
margin-bottom: .6em;
322322
}
323323

@@ -1401,34 +1401,34 @@ details.dir-entry a {
14011401
Unfortunately we can't yet specify contain: content or contain: strict
14021402
because the [-]/[+] toggles extend past the boundaries of the <details>
14031403
https://developer.mozilla.org/en-US/docs/Web/CSS/contain */
1404-
details.rustdoc-toggle {
1404+
details.toggle {
14051405
contain: layout;
14061406
position: relative;
14071407
}
14081408

14091409
/* The hideme class is used on summary tags that contain a span with
14101410
placeholder text shown only when the toggle is closed. For instance,
14111411
"Expand description" or "Show methods". */
1412-
details.rustdoc-toggle > summary.hideme {
1412+
details.toggle > summary.hideme {
14131413
cursor: pointer;
14141414
font-size: 1rem;
14151415
}
14161416

1417-
details.rustdoc-toggle > summary {
1417+
details.toggle > summary {
14181418
list-style: none;
14191419
/* focus outline is shown on `::before` instead of this */
14201420
outline: none;
14211421
}
1422-
details.rustdoc-toggle > summary::-webkit-details-marker,
1423-
details.rustdoc-toggle > summary::marker {
1422+
details.toggle > summary::-webkit-details-marker,
1423+
details.toggle > summary::marker {
14241424
display: none;
14251425
}
14261426

1427-
details.rustdoc-toggle > summary.hideme > span {
1427+
details.toggle > summary.hideme > span {
14281428
margin-left: 9px;
14291429
}
14301430

1431-
details.rustdoc-toggle > summary::before {
1431+
details.toggle > summary::before {
14321432
background: url("toggle-plus-1092eb4930d581b0.svg") no-repeat top left;
14331433
content: "";
14341434
cursor: pointer;
@@ -1440,32 +1440,32 @@ details.rustdoc-toggle > summary::before {
14401440
filter: var(--toggle-filter);
14411441
}
14421442

1443-
details.rustdoc-toggle > summary.hideme > span,
1443+
details.toggle > summary.hideme > span,
14441444
.more-examples-toggle summary, .more-examples-toggle .hide-more {
14451445
color: var(--toggles-color);
14461446
}
14471447

14481448
/* Screen readers see the text version at the end the line.
14491449
Visual readers see the icon at the start of the line, but small and transparent. */
1450-
details.rustdoc-toggle > summary::after {
1450+
details.toggle > summary::after {
14511451
content: "Expand";
14521452
overflow: hidden;
14531453
width: 0;
14541454
height: 0;
14551455
position: absolute;
14561456
}
14571457

1458-
details.rustdoc-toggle > summary.hideme::after {
1458+
details.toggle > summary.hideme::after {
14591459
/* "hideme" toggles already have a description when they're contracted */
14601460
content: "";
14611461
}
14621462

1463-
details.rustdoc-toggle > summary:focus::before,
1464-
details.rustdoc-toggle > summary:hover::before {
1463+
details.toggle > summary:focus::before,
1464+
details.toggle > summary:hover::before {
14651465
opacity: 1;
14661466
}
14671467

1468-
details.rustdoc-toggle > summary:focus-visible::before {
1468+
details.toggle > summary:focus-visible::before {
14691469
/* The SVG is black, and gets turned white using a filter in the dark themes.
14701470
Do the same with the outline.
14711471
The dotted 1px style is copied from Firefox's focus ring style.
@@ -1478,17 +1478,17 @@ details.non-exhaustive {
14781478
margin-bottom: 8px;
14791479
}
14801480

1481-
details.rustdoc-toggle > summary.hideme::before {
1481+
details.toggle > summary.hideme::before {
14821482
position: relative;
14831483
}
14841484

1485-
details.rustdoc-toggle > summary:not(.hideme)::before {
1485+
details.toggle > summary:not(.hideme)::before {
14861486
position: absolute;
14871487
left: -24px;
14881488
top: 4px;
14891489
}
14901490

1491-
.impl-items > details.rustdoc-toggle > summary:not(.hideme)::before {
1491+
.impl-items > details.toggle > summary:not(.hideme)::before {
14921492
position: absolute;
14931493
left: -24px;
14941494
}
@@ -1498,19 +1498,19 @@ details.rustdoc-toggle > summary:not(.hideme)::before {
14981498
affect the layout of the items to its right. To do that, we use
14991499
absolute positioning. Note that we also set position: relative
15001500
on the parent <details> to make this work properly. */
1501-
details.rustdoc-toggle[open] > summary.hideme {
1501+
details.toggle[open] > summary.hideme {
15021502
position: absolute;
15031503
}
15041504

1505-
details.rustdoc-toggle[open] > summary.hideme > span {
1505+
details.toggle[open] > summary.hideme > span {
15061506
display: none;
15071507
}
15081508

1509-
details.rustdoc-toggle[open] > summary::before {
1509+
details.toggle[open] > summary::before {
15101510
background: url("toggle-minus-31bbd6e4c77f5c96.svg") no-repeat top left;
15111511
}
15121512

1513-
details.rustdoc-toggle[open] > summary::after {
1513+
details.toggle[open] > summary::after {
15141514
content: "Collapse";
15151515
}
15161516

@@ -1660,8 +1660,8 @@ in storage.js
16601660
display: block;
16611661
}
16621662

1663-
#main-content > details.rustdoc-toggle > summary::before,
1664-
#main-content > div > details.rustdoc-toggle > summary::before {
1663+
#main-content > details.toggle > summary::before,
1664+
#main-content > div > details.toggle > summary::before {
16651665
left: -11px;
16661666
}
16671667

@@ -1715,12 +1715,12 @@ in storage.js
17151715
}
17161716

17171717
/* Position of the "[-]" element. */
1718-
details.rustdoc-toggle:not(.top-doc) > summary {
1718+
details.toggle:not(.top-doc) > summary {
17191719
margin-left: 10px;
17201720
}
1721-
.impl-items > details.rustdoc-toggle > summary:not(.hideme)::before,
1722-
#main-content > details.rustdoc-toggle:not(.top-doc) > summary::before,
1723-
#main-content > div > details.rustdoc-toggle > summary::before {
1721+
.impl-items > details.toggle > summary:not(.hideme)::before,
1722+
#main-content > details.toggle:not(.top-doc) > summary::before,
1723+
#main-content > div > details.toggle > summary::before {
17241724
left: -11px;
17251725
}
17261726

@@ -1753,8 +1753,8 @@ in storage.js
17531753

17541754
@media print {
17551755
nav.sidebar, nav.sub, .out-of-band, a.srclink, #copy-path,
1756-
details.rustdoc-toggle[open] > summary::before, details.rustdoc-toggle > summary::before,
1757-
details.rustdoc-toggle.top-doc > summary {
1756+
details.toggle[open] > summary::before, details.toggle > summary::before,
1757+
details.toggle.top-doc > summary {
17581758
display: none;
17591759
}
17601760

@@ -1796,24 +1796,24 @@ in storage.js
17961796
.impl,
17971797
#implementors-list > .docblock,
17981798
.impl-items > section,
1799-
.impl-items > .rustdoc-toggle > summary,
1799+
.impl-items > .toggle > summary,
18001800
.methods > section,
1801-
.methods > .rustdoc-toggle > summary
1801+
.methods > .toggle > summary
18021802
{
18031803
margin-bottom: 0.75em;
18041804
}
18051805

18061806
.variants > .docblock,
18071807
.implementors-toggle > .docblock,
1808-
.impl-items > .rustdoc-toggle[open]:not(:last-child),
1809-
.methods > .rustdoc-toggle[open]:not(:last-child),
1808+
.impl-items > .toggle[open]:not(:last-child),
1809+
.methods > .toggle[open]:not(:last-child),
18101810
.implementors-toggle[open]:not(:last-child) {
18111811
margin-bottom: 2em;
18121812
}
18131813

1814-
#trait-implementations-list .impl-items > .rustdoc-toggle:not(:last-child),
1815-
#synthetic-implementations-list .impl-items > .rustdoc-toggle:not(:last-child),
1816-
#blanket-implementations-list .impl-items > .rustdoc-toggle:not(:last-child) {
1814+
#trait-implementations-list .impl-items > .toggle:not(:last-child),
1815+
#synthetic-implementations-list .impl-items > .toggle:not(:last-child),
1816+
#blanket-implementations-list .impl-items > .toggle:not(:last-child) {
18171817
margin-bottom: 1em;
18181818
}
18191819

src/librustdoc/html/static/css/settings.css

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010

1111
.setting-line .radio-line input,
12-
.setting-line .toggle input {
12+
.setting-line .settings-toggle input {
1313
margin-right: 0.3em;
1414
height: 1.2rem;
1515
width: 1.2rem;
@@ -22,14 +22,14 @@
2222
.setting-line .radio-line input {
2323
border-radius: 50%;
2424
}
25-
.setting-line .toggle input:checked {
25+
.setting-line .settings-toggle input:checked {
2626
content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">\
2727
<path d="M7,25L17,32L33,12" fill="none" stroke="black" stroke-width="5"/>\
2828
<path d="M7,23L17,30L33,10" fill="none" stroke="white" stroke-width="5"/></svg>');
2929
}
3030

3131
.setting-line .radio-line input + span,
32-
.setting-line .toggle span {
32+
.setting-line .settings-toggle span {
3333
padding-bottom: 1px;
3434
}
3535

@@ -50,7 +50,7 @@
5050
margin-left: 0.5em;
5151
}
5252

53-
.toggle {
53+
.settings-toggle {
5454
position: relative;
5555
width: 100%;
5656
margin-right: 20px;
@@ -67,11 +67,11 @@
6767
box-shadow: inset 0 0 0 3px var(--main-background-color);
6868
background-color: var(--settings-input-color);
6969
}
70-
.setting-line .toggle input:checked {
70+
.setting-line .settings-toggle input:checked {
7171
background-color: var(--settings-input-color);
7272
}
7373
.setting-line .radio-line input:focus,
74-
.setting-line .toggle input:focus {
74+
.setting-line .settings-toggle input:focus {
7575
box-shadow: 0 0 1px 1px var(--settings-input-color);
7676
}
7777
/* In here we combine both `:focus` and `:checked` properties. */
@@ -80,6 +80,6 @@
8080
0 0 2px 2px var(--settings-input-color);
8181
}
8282
.setting-line .radio-line input:hover,
83-
.setting-line .toggle input:hover {
83+
.setting-line .settings-toggle input:hover {
8484
border-color: var(--settings-input-color) !important;
8585
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ function loadCss(cssUrl) {
620620
function expandAllDocs() {
621621
const innerToggle = document.getElementById(toggleAllDocsId);
622622
removeClass(innerToggle, "will-expand");
623-
onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => {
623+
onEachLazy(document.getElementsByClassName("toggle"), e => {
624624
if (!hasClass(e, "type-contents-toggle") && !hasClass(e, "more-examples-toggle")) {
625625
e.open = true;
626626
}
@@ -632,7 +632,7 @@ function loadCss(cssUrl) {
632632
function collapseAllDocs() {
633633
const innerToggle = document.getElementById(toggleAllDocsId);
634634
addClass(innerToggle, "will-expand");
635-
onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => {
635+
onEachLazy(document.getElementsByClassName("toggle"), e => {
636636
if (e.parentNode.id !== "implementations-list" ||
637637
(!hasClass(e, "implementors-toggle") &&
638638
!hasClass(e, "type-contents-toggle"))
@@ -680,7 +680,7 @@ function loadCss(cssUrl) {
680680
setImplementorsTogglesOpen("blanket-implementations-list", false);
681681
}
682682

683-
onEachLazy(document.getElementsByClassName("rustdoc-toggle"), e => {
683+
onEachLazy(document.getElementsByClassName("toggle"), e => {
684684
if (!hideLargeItemContents && hasClass(e, "type-contents-toggle")) {
685685
e.open = true;
686686
}
@@ -823,7 +823,7 @@ function loadCss(cssUrl) {
823823
});
824824
});
825825

826-
onEachLazy(document.querySelectorAll(".rustdoc-toggle > summary:not(.hideme)"), el => {
826+
onEachLazy(document.querySelectorAll(".toggle > summary:not(.hideme)"), el => {
827827
el.addEventListener("click", e => {
828828
if (e.target.tagName !== "SUMMARY" && e.target.tagName !== "A") {
829829
e.preventDefault();

src/librustdoc/html/static/js/settings.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@
150150
});
151151
output += "</div></div>";
152152
} else {
153-
// This is a toggle.
153+
// This is a checkbox toggle.
154154
const checked = setting["default"] === true ? " checked" : "";
155155
output += `\
156-
<label class="toggle">\
156+
<label class="settings-toggle">\
157157
<input type="checkbox" id="${js_data_name}"${checked}>\
158158
<span class="label">${setting_name}</span>\
159159
</label>`;

tests/rustdoc-gui/method-margins.goml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// This test ensures that the margins on methods are coherent inside an impl block.
22
goto: "file://" + |DOC_PATH| + "/test_docs/trait_members/struct.HasTrait.html#impl-TraitMembers-for-HasTrait"
33

4-
assert-count: ("#trait-implementations-list > .rustdoc-toggle", 1)
4+
assert-count: ("#trait-implementations-list > .toggle", 1)
55

66
compare-elements-css: (
77
// compare margin on type with margin on method
8-
"#trait-implementations-list .impl-items > .rustdoc-toggle:nth-child(1) > summary",
9-
"#trait-implementations-list .impl-items > .rustdoc-toggle:nth-child(2) > summary",
8+
"#trait-implementations-list .impl-items > .toggle:nth-child(1) > summary",
9+
"#trait-implementations-list .impl-items > .toggle:nth-child(2) > summary",
1010
["margin"]
1111
)
1212

1313
compare-elements-css: (
1414
// compare margin on type with margin on method
15-
"#trait-implementations-list .impl-items > .rustdoc-toggle:nth-child(1)",
16-
"#trait-implementations-list .impl-items > .rustdoc-toggle:nth-child(2)",
15+
"#trait-implementations-list .impl-items > .toggle:nth-child(1)",
16+
"#trait-implementations-list .impl-items > .toggle:nth-child(2)",
1717
["margin"]
1818
)

0 commit comments

Comments
 (0)