diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-07-13 08:54:33 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-13 08:54:33 +0900 |
| commit | fab45bf4859d8c74fff421eafed0159fa3f47fde (patch) | |
| tree | 114cec8299be214bb43adaad518998fc7092cae3 /src/librustdoc | |
| parent | 2d9a0387c10a527731209338ab83817ece26ee05 (diff) | |
| parent | bd819493d7780b9b511896b5f1080d8dc419f314 (diff) | |
Rollup merge of #87035 - GuillaumeGomez:fix-implementors-display, r=notriddle
Fix implementors display Part of https://github.com/rust-lang/rust/issues/86632. This PR does a few things: * It fixes of the JS rendered implementors. * It generates anchors for JS rendered implementors to make it coherent with the others. * It adds a test to ensure that we won't have the same issue again. * It changes the way we render the rustdoc-gui crates to simplify it a bit and also to allow to have dependencies without going through compiletest. Before:  After:  I plan to add the `[src]` links in another PR because this one is already big enough. cc `@Mark-Simulacrum` (for the bootstrap changes) r? `@Nemo157`
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/html/static/js/main.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 98128878999..38ddbb3ad74 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -683,6 +683,9 @@ function hideThemeButtonState() { }); } + var currentNbImpls = implementors.getElementsByClassName("impl").length; + var traitName = document.querySelector("h1.fqn > .in-band > .trait").textContent; + var baseIdName = "impl-" + traitName + "-"; var libs = Object.getOwnPropertyNames(imp); for (var i = 0, llength = libs.length; i < llength; ++i) { if (libs[i] === window.currentCrate) { continue; } @@ -705,6 +708,7 @@ function hideThemeButtonState() { var code = document.createElement("code"); code.innerHTML = struct.text; + addClass(code, "in-band"); onEachLazy(code.getElementsByTagName("a"), function(elem) { var href = elem.getAttribute("href"); @@ -714,12 +718,18 @@ function hideThemeButtonState() { } }); - var display = document.createElement("h3"); + var currentId = baseIdName + currentNbImpls; + var anchor = document.createElement("a"); + anchor.href = "#" + currentId; + addClass(anchor, "anchor"); + + var display = document.createElement("div"); + display.id = currentId; addClass(display, "impl"); - display.innerHTML = "<span class=\"in-band\"><table class=\"table-display\">" + - "<tbody><tr><td><code>" + code.outerHTML + "</code></td><td></td></tr>" + - "</tbody></table></span>"; + display.appendChild(anchor); + display.appendChild(code); list.appendChild(display); + currentNbImpls += 1; } } }; |
