From 64e1038f6b214f835a50030ae9c3526d545844f3 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Fri, 21 May 2021 10:33:56 -0700 Subject: [PATCH 1/2] 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. --- src/librustdoc/html/static/main.js | 6 ++++++ src/librustdoc/html/static/rustdoc.css | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 1a15a444a701a..ea0ab82e5eb98 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -862,6 +862,12 @@ function hideThemeButtonState() { displayHelp(true, ev); }); + onEachLazy(document.getElementsByTagName("summary"), function(el) { + el.addEventListener("click", function(ev) { + addClass(el, "used"); + }); + }) + onEachLazy(document.getElementsByTagName("a"), function(el) { // For clicks on internal links ( tags with a hash property), we expand the section we're // jumping to *before* jumping there. We can't do this in onHashChange, because it changes diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 578e8ce5acbef..7c8621f95e8ff 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -1487,11 +1487,21 @@ details.rustdoc-toggle[open] > summary.hideme > span { display: none; } -details.rustdoc-toggle[open] > summary::before { +/* If a toggle has been used to open a section, we should make sure */ +/* there's a [-] so it can be closed again. But if a toggle is open */ +/* and has never been used, don't show it. This minimizes clutter on */ +/* the page while still supporting the "auto hide " settings and */ +/* the expand/collapse all functionality. */ +details.rustdoc-toggle[open] > summary.used::before { content: "[−]"; display: inline; } +details.rustdoc-toggle[open] > summary::before { + content: ""; + display: inline; +} + details.undocumented > summary::before { content: "[+] Show hidden undocumented items"; cursor: pointer; From 6e7ead0c6b3f04f3d2fac7b8d26f9e25c574eeac Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Tue, 8 Jun 2021 15:20:06 -0700 Subject: [PATCH 2/2] Remove stability marker arrow. This was originally introduced in # 51387, to solve a UI problem: in a list of collapsed methods, it was not clear whether the stability marker attached to the item above it or the one below it. That problem has now been solved in a couple of different ways: - The margin between the stability marker and the item it annotates is much smaller, indicating their relationship. - Stability markers are now collapsed along with the docblock. Also, the arrow made our CSS fragile, since it was positioned absolutely and needed to line up horizontally with the beginning of the item (or with the link icon). Aligning this with the rest of the docblock makes getting the CSS right a lot easier. --- src/librustdoc/html/static/main.js | 4 ++-- src/librustdoc/html/static/rustdoc.css | 10 +--------- src/librustdoc/html/static/themes/ayu.css | 2 -- src/librustdoc/html/static/themes/dark.css | 2 -- src/librustdoc/html/static/themes/light.css | 2 -- 5 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index ea0ab82e5eb98..a04eaa7f0b270 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -863,10 +863,10 @@ function hideThemeButtonState() { }); onEachLazy(document.getElementsByTagName("summary"), function(el) { - el.addEventListener("click", function(ev) { + el.addEventListener("click", function() { addClass(el, "used"); }); - }) + }); onEachLazy(document.getElementsByTagName("a"), function(el) { // For clicks on internal links ( tags with a hash property), we expand the section we're diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 7c8621f95e8ff..c429562348b66 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -580,7 +580,7 @@ nav.sub { .content .item-info { position: relative; - margin-left: 33px; + margin-left: 24px; /* same as .docblock */ margin-top: -13px; } @@ -588,14 +588,6 @@ nav.sub { margin-top: initial; } -.content .item-info::before { - content: '⬑'; - font-size: 25px; - position: absolute; - top: -6px; - left: -19px; -} - .content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant, .impl-items > .associatedtype, .content .impl-items details > summary > .type, .impl-items details > summary > .associatedconstant, diff --git a/src/librustdoc/html/static/themes/ayu.css b/src/librustdoc/html/static/themes/ayu.css index d220d8708a123..034fd3151de21 100644 --- a/src/librustdoc/html/static/themes/ayu.css +++ b/src/librustdoc/html/static/themes/ayu.css @@ -165,8 +165,6 @@ pre, .rustdoc.source .example-wrap { color: #c5c5c5; } -.content .item-info::before { color: #ccc; } - .content span.foreigntype, .content a.foreigntype { color: #ef57ff; } .content span.union, .content a.union { color: #98a01c; } .content span.constant, .content a.constant, diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 6385a763f2ef7..752ec81fcee27 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -138,8 +138,6 @@ a.result-static:focus { background-color: #0063cc; } a.result-primitive:focus { background-color: #00708a; } a.result-keyword:focus { background-color: #884719; } -.content .item-info::before { color: #ccc; } - .content span.enum, .content a.enum, .block a.current.enum { color: #82b089; } .content span.struct, .content a.struct, .block a.current.struct { color: #2dbfb8; } .content span.type, .content a.type, .block a.current.type { color: #ff7f00; } diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index c19d5bfc317f7..6ac824dd76c05 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -136,8 +136,6 @@ a.result-static:focus { background-color: #c3e0ff; } a.result-primitive:focus { background-color: #9aecff; } a.result-keyword:focus { background-color: #f99650; } -.content .item-info::before { color: #ccc; } - .content span.enum, .content a.enum, .block a.current.enum { color: #508157; } .content span.struct, .content a.struct, .block a.current.struct { color: #ad448e; } .content span.type, .content a.type, .block a.current.type { color: #ba5d00; }