Skip to content

Commit 62658bf

Browse files
committed
Open trait implementations' toggles by default.
This makes it possible to use Ctrl-F to find methods defined in traits.
1 parent 8daad74 commit 62658bf

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/librustdoc/html/render/mod.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ fn settings(root_path: &str, suffix: &str, themes: &[StylePath]) -> Result<Strin
488488
.into(),
489489
("auto-hide-large-items", "Auto-hide item contents for large items.", true).into(),
490490
("auto-hide-method-docs", "Auto-hide item methods' documentation", false).into(),
491-
("auto-hide-trait-implementations", "Auto-hide trait implementation documentation", true)
491+
("auto-hide-trait-implementations", "Auto-hide trait implementation documentation", false)
492492
.into(),
493493
("auto-collapse-implementors", "Auto-hide implementors of a trait", true).into(),
494494
("go-to-only-result", "Directly go to item in search if there is only one result", false)
@@ -1543,15 +1543,10 @@ fn render_impl(
15431543
}
15441544
}
15451545
if render_mode == RenderMode::Normal {
1546-
let is_implementing_trait = i.inner_impl().trait_.is_some();
15471546
let toggled = !impl_items.is_empty() || !default_impl_items.is_empty();
15481547
if toggled {
15491548
close_tags.insert_str(0, "</details>");
1550-
if is_implementing_trait {
1551-
write!(w, "<details class=\"rustdoc-toggle implementors-toggle\">");
1552-
} else {
1553-
write!(w, "<details class=\"rustdoc-toggle implementors-toggle\" open>");
1554-
}
1549+
write!(w, "<details class=\"rustdoc-toggle implementors-toggle\" open>");
15551550
}
15561551
if toggled {
15571552
write!(w, "<summary>")

src/librustdoc/html/static/main.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -779,25 +779,25 @@ function hideThemeButtonState() {
779779

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

785-
function openImplementors(id) {
785+
function setImplementorsTogglesOpen(id, open) {
786786
var list = document.getElementById(id);
787787
if (list !== null) {
788788
onEachLazy(list.getElementsByClassName("implementors-toggle"), function(e) {
789-
e.open = true;
789+
e.open = open;
790790
});
791791
}
792792
}
793793

794-
if (!hideImplementations) {
795-
openImplementors("trait-implementations-list");
796-
openImplementors("blanket-implementations-list");
794+
if (hideImplementations) {
795+
setImplementorsTogglesOpen("trait-implementations-list", false);
796+
setImplementorsTogglesOpen("blanket-implementations-list", false);
797797
}
798798

799799
if (!hideImplementors) {
800-
openImplementors("implementors-list");
800+
setImplementorsTogglesOpen("implementors-list", true);
801801
}
802802

803803
onEachLazy(document.getElementsByClassName("rustdoc-toggle"), function (e) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This tests that the "implementations" section on struct/enum pages
2+
// has all the implementations toggled open by default, so users can
3+
// find method names in those implementations with Ctrl-F.
4+
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
5+
assert: (".rustdoc-toggle.implementors-toggle", "open", "")

0 commit comments

Comments
 (0)