Skip to content

Commit

Permalink
rustdoc: Stop hiding entire item declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Apr 12, 2021
1 parent c18c0ad commit c96f86d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 33 deletions.
11 changes: 0 additions & 11 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,17 +486,6 @@ fn settings(root_path: &str, suffix: &str, themes: &[StylePath]) -> Result<Strin
],
)
.into(),
(
"Auto-hide item declarations",
vec![
("auto-hide-struct", "Auto-hide structs declaration", true),
("auto-hide-enum", "Auto-hide enums declaration", false),
("auto-hide-union", "Auto-hide unions declaration", true),
("auto-hide-trait", "Auto-hide traits declaration", true),
("auto-hide-macro", "Auto-hide macros declaration", false),
],
)
.into(),
("auto-hide-attributes", "Auto-hide item attributes.", true).into(),
("auto-hide-method-docs", "Auto-hide item methods' documentation", false).into(),
("auto-hide-trait-implementations", "Auto-hide trait implementation documentation", true)
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ fn wrap_into_docblock<F>(w: &mut Buffer, f: F)
where
F: FnOnce(&mut Buffer),
{
w.write_str("<div class=\"docblock type-decl hidden-by-usual-hider\">");
w.write_str("<div class=\"docblock type-decl\">");
f(w);
w.write_str("</div>")
}
Expand Down
25 changes: 4 additions & 21 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2683,18 +2683,7 @@ function hideThemeButtonState() {
});
}
}
var showItemDeclarations = getSettingValue("auto-hide-" + className);
if (showItemDeclarations === null) {
if (className === "enum" || className === "macro") {
showItemDeclarations = "false";
} else if (className === "struct" || className === "union" || className === "trait") {
showItemDeclarations = "true";
} else {
// In case we found an unknown type, we just use the "parent" value.
showItemDeclarations = getSettingValue("auto-hide-declarations");
}
}
showItemDeclarations = showItemDeclarations === "false";

function buildToggleWrapper(e) {
if (hasClass(e, "autohide")) {
var wrap = e.previousElementSibling;
Expand All @@ -2721,11 +2710,8 @@ function hideThemeButtonState() {
var extraClass;

if (hasClass(e, "type-decl")) {
fontSize = "20px";
otherMessage = "&nbsp;Show&nbsp;declaration";
if (showItemDeclarations === false) {
extraClass = "collapsed";
}
// We do something special for these
return;
} else if (hasClass(e, "sub-variant")) {
otherMessage = "&nbsp;Show&nbsp;fields";
} else if (hasClass(e, "non-exhaustive")) {
Expand All @@ -2750,11 +2736,8 @@ function hideThemeButtonState() {
otherMessage,
fontSize,
extraClass,
hasClass(e, "type-decl") === false || showItemDeclarations === true),
false),
e);
if (hasClass(e, "type-decl") === true && showItemDeclarations === true) {
collapseDocs(e.previousSibling.childNodes[0], "toggle");
}
if (hasClass(e, "non-exhaustive") === true) {
collapseDocs(e.previousSibling.childNodes[0], "toggle");
}
Expand Down

0 comments on commit c96f86d

Please sign in to comment.