1
Fork 0

Add setting to prevent doc auto-hide of trait implementations

This commit is contained in:
Guillaume Gomez 2018-07-08 15:07:06 +02:00
parent 0c0315cfd9
commit c0ec5d5e44
2 changed files with 14 additions and 10 deletions

View file

@ -1669,6 +1669,8 @@ impl<'a> Settings<'a> {
settings: vec![ settings: vec![
("item-declarations", "Auto-hide item declarations.", true), ("item-declarations", "Auto-hide item declarations.", true),
("item-attributes", "Auto-hide item attributes.", true), ("item-attributes", "Auto-hide item attributes.", true),
("trait-implementations", "Auto-hide trait implementations documentation",
true),
("go-to-only-result", "Directly go to item in search if there is only one result", ("go-to-only-result", "Directly go to item in search if there is only one result",
false), false),
], ],

View file

@ -1938,17 +1938,19 @@
if (collapse) { if (collapse) {
toggleAllDocs(pageId, true); toggleAllDocs(pageId, true);
} }
onEach(document.getElementsByClassName("collapse-toggle"), function(e) { if (getCurrentValue('rustdoc-trait-implementations') !== "false") {
// inherent impl ids are like 'impl' or impl-<number>'. onEach(document.getElementsByClassName("collapse-toggle"), function(e) {
// they will never be hidden by default. // inherent impl ids are like 'impl' or impl-<number>'.
var n = e.parentNode; // they will never be hidden by default.
if (n.id.match(/^impl(?:-\d+)?$/) === null) { var n = e.parentNode;
// Automatically minimize all non-inherent impls if (n.id.match(/^impl(?:-\d+)?$/) === null) {
if (collapse || hasClass(n, 'impl')) { // Automatically minimize all non-inherent impls
collapseDocs(e, "hide", pageId); if (collapse || hasClass(n, 'impl')) {
collapseDocs(e, "hide", pageId);
}
} }
} });
}); }
} }
var x = document.getElementById('toggle-all-docs'); var x = document.getElementById('toggle-all-docs');