Skip to content

Commit 8ccee61

Browse files
Fix display for external trait implementors
1 parent ac8c3bf commit 8ccee61

File tree

1 file changed

+14
-4
lines changed
  • src/librustdoc/html/static/js

1 file changed

+14
-4
lines changed

src/librustdoc/html/static/js/main.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,9 @@ function hideThemeButtonState() {
683683
});
684684
}
685685

686+
var currentNbImpls = implementors.getElementsByClassName("impl").length;
687+
var traitName = document.querySelector("h1.fqn > .in-band > .trait").textContent;
688+
var baseIdName = "impl-" + traitName + "-";
686689
var libs = Object.getOwnPropertyNames(imp);
687690
for (var i = 0, llength = libs.length; i < llength; ++i) {
688691
if (libs[i] === window.currentCrate) { continue; }
@@ -705,6 +708,7 @@ function hideThemeButtonState() {
705708

706709
var code = document.createElement("code");
707710
code.innerHTML = struct.text;
711+
addClass(code, "in-band");
708712

709713
onEachLazy(code.getElementsByTagName("a"), function(elem) {
710714
var href = elem.getAttribute("href");
@@ -714,12 +718,18 @@ function hideThemeButtonState() {
714718
}
715719
});
716720

717-
var display = document.createElement("h3");
721+
var currentId = baseIdName + currentNbImpls;
722+
var anchor = document.createElement("a");
723+
anchor.href = "#" + currentId;
724+
addClass(anchor, "anchor");
725+
726+
var display = document.createElement("div");
727+
display.id = currentId;
718728
addClass(display, "impl");
719-
display.innerHTML = "<span class=\"in-band\"><table class=\"table-display\">" +
720-
"<tbody><tr><td><code>" + code.outerHTML + "</code></td><td></td></tr>" +
721-
"</tbody></table></span>";
729+
display.appendChild(anchor);
730+
display.appendChild(code);
722731
list.appendChild(display);
732+
currentNbImpls += 1;
723733
}
724734
}
725735
};

0 commit comments

Comments
 (0)