Rollup merge of #74196 - GuillaumeGomez:auto-collapse-implementors, r=Manishearth
Add option to collapse automatically implementors Fixes #73403 It adds an option (enabled by default) which collapses all implementors impl blocks. r? @kinnison cc @rust-lang/rustdoc
This commit is contained in:
commit
efad203144
2 changed files with 11 additions and 4 deletions
|
@ -1322,8 +1322,9 @@ fn settings(root_path: &str, suffix: &str) -> String {
|
||||||
.into(),
|
.into(),
|
||||||
("auto-hide-attributes", "Auto-hide item attributes.", true).into(),
|
("auto-hide-attributes", "Auto-hide item attributes.", true).into(),
|
||||||
("auto-hide-method-docs", "Auto-hide item methods' documentation", false).into(),
|
("auto-hide-method-docs", "Auto-hide item methods' documentation", false).into(),
|
||||||
("auto-hide-trait-implementations", "Auto-hide trait implementations documentation", true)
|
("auto-hide-trait-implementations", "Auto-hide trait implementation documentation", true)
|
||||||
.into(),
|
.into(),
|
||||||
|
("auto-collapse-implementors", "Auto-hide implementors of a trait", true).into(),
|
||||||
("go-to-only-result", "Directly go to item in search if there is only one result", false)
|
("go-to-only-result", "Directly go to item in search if there is only one result", false)
|
||||||
.into(),
|
.into(),
|
||||||
("line-numbers", "Show line numbers on code examples", false).into(),
|
("line-numbers", "Show line numbers on code examples", false).into(),
|
||||||
|
|
|
@ -2243,8 +2243,7 @@ function defocusSearchBar() {
|
||||||
relatedDoc = relatedDoc.nextElementSibling;
|
relatedDoc = relatedDoc.nextElementSibling;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!relatedDoc && hasClass(docblock, "docblock") === false) ||
|
if (!relatedDoc && hasClass(docblock, "docblock") === false) {
|
||||||
(pageId && document.getElementById(pageId))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2364,6 +2363,7 @@ function defocusSearchBar() {
|
||||||
(function() {
|
(function() {
|
||||||
var toggle = createSimpleToggle(false);
|
var toggle = createSimpleToggle(false);
|
||||||
var hideMethodDocs = getCurrentValue("rustdoc-auto-hide-method-docs") === "true";
|
var hideMethodDocs = getCurrentValue("rustdoc-auto-hide-method-docs") === "true";
|
||||||
|
var hideImplementors = getCurrentValue("rustdoc-auto-collapse-implementors") !== "false";
|
||||||
var pageId = getPageId();
|
var pageId = getPageId();
|
||||||
|
|
||||||
var func = function(e) {
|
var func = function(e) {
|
||||||
|
@ -2393,7 +2393,13 @@ function defocusSearchBar() {
|
||||||
if (hasClass(e, "impl") &&
|
if (hasClass(e, "impl") &&
|
||||||
(next.getElementsByClassName("method").length > 0 ||
|
(next.getElementsByClassName("method").length > 0 ||
|
||||||
next.getElementsByClassName("associatedconstant").length > 0)) {
|
next.getElementsByClassName("associatedconstant").length > 0)) {
|
||||||
insertAfter(toggle.cloneNode(true), e.childNodes[e.childNodes.length - 1]);
|
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", pageId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue