Skip to content

Commit 64e1038

Browse files
committed
Make invisible closed toggles that haven't been used.
This reduces clutter on the page, while still supporting the "auto hide X" settings and the "collapse all docs" button.
1 parent e4a6032 commit 64e1038

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/librustdoc/html/static/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,12 @@ function hideThemeButtonState() {
862862
displayHelp(true, ev);
863863
});
864864

865+
onEachLazy(document.getElementsByTagName("summary"), function(el) {
866+
el.addEventListener("click", function(ev) {
867+
addClass(el, "used");
868+
});
869+
})
870+
865871
onEachLazy(document.getElementsByTagName("a"), function(el) {
866872
// For clicks on internal links (<A> tags with a hash property), we expand the section we're
867873
// jumping to *before* jumping there. We can't do this in onHashChange, because it changes

src/librustdoc/html/static/rustdoc.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,11 +1487,21 @@ details.rustdoc-toggle[open] > summary.hideme > span {
14871487
display: none;
14881488
}
14891489

1490-
details.rustdoc-toggle[open] > summary::before {
1490+
/* If a toggle has been used to open a section, we should make sure */
1491+
/* there's a [-] so it can be closed again. But if a toggle is open */
1492+
/* and has never been used, don't show it. This minimizes clutter on */
1493+
/* the page while still supporting the "auto hide <X>" settings and */
1494+
/* the expand/collapse all functionality. */
1495+
details.rustdoc-toggle[open] > summary.used::before {
14911496
content: "[−]";
14921497
display: inline;
14931498
}
14941499

1500+
details.rustdoc-toggle[open] > summary::before {
1501+
content: "";
1502+
display: inline;
1503+
}
1504+
14951505
details.undocumented > summary::before {
14961506
content: "[+] Show hidden undocumented items";
14971507
cursor: pointer;

0 commit comments

Comments
 (0)