diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-04-24 12:17:03 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-24 12:17:03 +0900 |
| commit | b4544698d39d9e6995a32b41b33f327b9b0f3f82 (patch) | |
| tree | d1dc1e26f31f7672ff9ac41b5596907a5bd8e68e /src/librustdoc/html/static | |
| parent | 5321f9559bdb81fe0f2dda881bef2934ca65eba2 (diff) | |
| parent | 569096cbaffe39fbede339430c5ed8e80d991a80 (diff) | |
| download | rust-b4544698d39d9e6995a32b41b33f327b9b0f3f82.tar.gz rust-b4544698d39d9e6995a32b41b33f327b9b0f3f82.zip | |
Rollup merge of #84320 - jsha:details-implementors, r=Manishearth,Nemo157,GuillaumeGomez
Use details tag for trait implementors. Part of #83332 and following on from #83337 and #83355. This removes one category of JS-generated toggles (implementors), and replaces them with a `<details>` tag. This simplifies the JS, and fixes some bugs where things that were supposed to be hidden by the toggle were not hidden. Compare https://hoffman-andrews.com/rust/details-implementors/std/io/trait.Read.html#impl-Read vs https://doc.rust-lang.org/nightly/std/io/trait.Read.html#implementors. This introduces a `left: -23px` to put the toggle in the correct place, matching the current style for `.collapse-toggle`. It's worth noting this introduces a slight behavior change: since the entire line is now a `<summary>`, any part of the line is clickable. So for instance, in `impl Read for File`, clicking `impl` or `for` will collapse / expand the docs. Clicking `Read` or `File` still links to the appropriate documentation as before.
Diffstat (limited to 'src/librustdoc/html/static')
| -rw-r--r-- | src/librustdoc/html/static/main.js | 27 | ||||
| -rw-r--r-- | src/librustdoc/html/static/rustdoc.css | 8 |
2 files changed, 14 insertions, 21 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 5dfc206eb2e..2e3e148eaf6 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1207,31 +1207,18 @@ function hideThemeButtonState() { if (!next) { return; } - if (hasClass(e, "impl") && - (next.getElementsByClassName("method").length > 0 || - next.getElementsByClassName("associatedconstant").length > 0)) { - var newToggle = toggle.cloneNode(true); - insertAfter(newToggle, e.childNodes[e.childNodes.length - 1]); - // In case the option "auto-collapse implementors" is not set to false, we collapse - // all implementors. - if (hideImplementors === true && e.parentNode.id === "implementors-list") { - collapseDocs(newToggle, "hide"); - } - } }; onEachLazy(document.getElementsByClassName("method"), func); onEachLazy(document.getElementsByClassName("associatedconstant"), func); - onEachLazy(document.getElementsByClassName("impl"), funcImpl); var impl_call = function() {}; - // Large items are hidden by default in the HTML. If the setting overrides that, show 'em. - if (!hideLargeItemContents) { - onEachLazy(document.getElementsByTagName("details"), function (e) { - if (hasClass(e, "type-contents-toggle")) { - e.open = true; - } - }); - } + onEachLazy(document.getElementsByTagName("details"), function (e) { + var showLargeItem = !hideLargeItemContents && hasClass(e, "type-contents-toggle"); + var showImplementor = !hideImplementors && hasClass(e, "implementors-toggle"); + if (showLargeItem || showImplementor) { + e.open = true; + } + }); if (hideMethodDocs === true) { impl_call = function(e, newToggle) { if (e.id.match(/^impl(?:-\d+)?$/) === null) { diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 44fb531100a..a024fa49b0e 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -1573,6 +1573,10 @@ h4 > .notable-traits { left: -10px; } + .item-list > details.rustdoc-toggle > summary:not(.hideme)::before { + left: -10px; + } + #all-types { margin: 10px; } @@ -1787,6 +1791,7 @@ details.rustdoc-toggle > summary::before { font-weight: 300; font-size: 0.8em; letter-spacing: 1px; + cursor: pointer; } details.rustdoc-toggle > summary.hideme::before { @@ -1794,7 +1799,8 @@ details.rustdoc-toggle > summary.hideme::before { } details.rustdoc-toggle > summary:not(.hideme)::before { - float: left; + position: absolute; + left: -23px; } /* When a "hideme" summary is open and the "Expand description" or "Show |
