Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open trait implementations' toggles by default. #86260

Merged
merged 1 commit into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ fn settings(root_path: &str, suffix: &str, themes: &[StylePath]) -> Result<Strin
.into(),
("auto-hide-large-items", "Auto-hide item contents for large items.", true).into(),
("auto-hide-method-docs", "Auto-hide item methods' documentation", false).into(),
("auto-hide-trait-implementations", "Auto-hide trait implementation documentation", true)
("auto-hide-trait-implementations", "Auto-hide trait implementation documentation", false)
.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)
Expand Down Expand Up @@ -1543,15 +1543,10 @@ fn render_impl(
}
}
if render_mode == RenderMode::Normal {
let is_implementing_trait = i.inner_impl().trait_.is_some();
let toggled = !impl_items.is_empty() || !default_impl_items.is_empty();
if toggled {
close_tags.insert_str(0, "</details>");
if is_implementing_trait {
write!(w, "<details class=\"rustdoc-toggle implementors-toggle\">");
} else {
write!(w, "<details class=\"rustdoc-toggle implementors-toggle\" open>");
}
write!(w, "<details class=\"rustdoc-toggle implementors-toggle\" open>");
}
if toggled {
write!(w, "<summary>")
Expand Down
14 changes: 7 additions & 7 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,25 +779,25 @@ function hideThemeButtonState() {

var hideMethodDocs = getSettingValue("auto-hide-method-docs") === "true";
var hideImplementors = getSettingValue("auto-collapse-implementors") !== "false";
var hideImplementations = getSettingValue("auto-hide-trait-implementations") !== "false";
var hideImplementations = getSettingValue("auto-hide-trait-implementations") === "true";
var hideLargeItemContents = getSettingValue("auto-hide-large-items") !== "false";

function openImplementors(id) {
function setImplementorsTogglesOpen(id, open) {
var list = document.getElementById(id);
if (list !== null) {
onEachLazy(list.getElementsByClassName("implementors-toggle"), function(e) {
e.open = true;
e.open = open;
});
}
}

if (!hideImplementations) {
openImplementors("trait-implementations-list");
openImplementors("blanket-implementations-list");
if (hideImplementations) {
setImplementorsTogglesOpen("trait-implementations-list", false);
setImplementorsTogglesOpen("blanket-implementations-list", false);
}

if (!hideImplementors) {
openImplementors("implementors-list");
setImplementorsTogglesOpen("implementors-list", true);
}

onEachLazy(document.getElementsByClassName("rustdoc-toggle"), function (e) {
Expand Down
5 changes: 5 additions & 0 deletions src/test/rustdoc-gui/toggled-open-implementations.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This tests that the "implementations" section on struct/enum pages
// has all the implementations toggled open by default, so users can
// find method names in those implementations with Ctrl-F.
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
assert: (".rustdoc-toggle.implementors-toggle", "open", "")