mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 04:08:40 +00:00
Open trait implementations' toggles by default.
This makes it possible to use Ctrl-F to find methods defined in traits.
This commit is contained in:
parent
8daad743c4
commit
62658bfc22
@ -488,7 +488,7 @@ fn settings(root_path: &str, suffix: &str, themes: &[StylePath]) -> Result<Strin
|
|||||||
.into(),
|
.into(),
|
||||||
("auto-hide-large-items", "Auto-hide item contents for large items.", true).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-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(),
|
.into(),
|
||||||
("auto-collapse-implementors", "Auto-hide implementors of a trait", true).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)
|
||||||
@ -1543,16 +1543,11 @@ fn render_impl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if render_mode == RenderMode::Normal {
|
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();
|
let toggled = !impl_items.is_empty() || !default_impl_items.is_empty();
|
||||||
if toggled {
|
if toggled {
|
||||||
close_tags.insert_str(0, "</details>");
|
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 {
|
if toggled {
|
||||||
write!(w, "<summary>")
|
write!(w, "<summary>")
|
||||||
}
|
}
|
||||||
|
@ -779,25 +779,25 @@ function hideThemeButtonState() {
|
|||||||
|
|
||||||
var hideMethodDocs = getSettingValue("auto-hide-method-docs") === "true";
|
var hideMethodDocs = getSettingValue("auto-hide-method-docs") === "true";
|
||||||
var hideImplementors = getSettingValue("auto-collapse-implementors") !== "false";
|
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";
|
var hideLargeItemContents = getSettingValue("auto-hide-large-items") !== "false";
|
||||||
|
|
||||||
function openImplementors(id) {
|
function setImplementorsTogglesOpen(id, open) {
|
||||||
var list = document.getElementById(id);
|
var list = document.getElementById(id);
|
||||||
if (list !== null) {
|
if (list !== null) {
|
||||||
onEachLazy(list.getElementsByClassName("implementors-toggle"), function(e) {
|
onEachLazy(list.getElementsByClassName("implementors-toggle"), function(e) {
|
||||||
e.open = true;
|
e.open = open;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hideImplementations) {
|
if (hideImplementations) {
|
||||||
openImplementors("trait-implementations-list");
|
setImplementorsTogglesOpen("trait-implementations-list", false);
|
||||||
openImplementors("blanket-implementations-list");
|
setImplementorsTogglesOpen("blanket-implementations-list", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hideImplementors) {
|
if (!hideImplementors) {
|
||||||
openImplementors("implementors-list");
|
setImplementorsTogglesOpen("implementors-list", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
onEachLazy(document.getElementsByClassName("rustdoc-toggle"), function (e) {
|
onEachLazy(document.getElementsByClassName("rustdoc-toggle"), function (e) {
|
||||||
|
5
src/test/rustdoc-gui/toggled-open-implementations.goml
Normal file
5
src/test/rustdoc-gui/toggled-open-implementations.goml
Normal file
@ -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", "")
|
Loading…
Reference in New Issue
Block a user