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`
This commit is contained in:
commit
fab45bf485
13 changed files with 109 additions and 18 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue