Fix auto-hide for implementations and implementors.
This sets their toggles to be closed in the HTML (matching the default setting), and opens them if the setting indicates to do so. This distinguishes between implementations and implementors based on being descendants of certain named elements.
This commit is contained in:
parent
5dc8789e30
commit
5ebbed6cb0
3 changed files with 24 additions and 6 deletions
|
@ -1545,7 +1545,7 @@ fn render_impl(
|
||||||
let open_details = |close_tags: &mut String| {
|
let open_details = |close_tags: &mut String| {
|
||||||
if toggled {
|
if toggled {
|
||||||
close_tags.insert_str(0, "</details>");
|
close_tags.insert_str(0, "</details>");
|
||||||
"<details class=\"rustdoc-toggle implementors-toggle\" open><summary>"
|
"<details class=\"rustdoc-toggle implementors-toggle\"><summary>"
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
|
@ -776,12 +776,29 @@ 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 hideLargeItemContents = getSettingValue("auto-hide-large-items") !== "false";
|
var hideLargeItemContents = getSettingValue("auto-hide-large-items") !== "false";
|
||||||
|
|
||||||
onEachLazy(document.getElementsByTagName("details"), function (e) {
|
function openImplementors(id) {
|
||||||
var showLargeItem = !hideLargeItemContents && hasClass(e, "type-contents-toggle");
|
var list = document.getElementById(id);
|
||||||
var showImplementor = !hideImplementors && hasClass(e, "implementors-toggle");
|
if (list !== null) {
|
||||||
if (showLargeItem || showImplementor) {
|
onEachLazy(list.getElementsByClassName("implementors-toggle"), function(e) {
|
||||||
|
e.open = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hideImplementations) {
|
||||||
|
openImplementors("trait-implementations-list");
|
||||||
|
openImplementors("blanket-implementations-list");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hideImplementors) {
|
||||||
|
openImplementors("implementors-list");
|
||||||
|
}
|
||||||
|
|
||||||
|
onEachLazy(document.getElementsByClassName("rustdoc-toggle"), function (e) {
|
||||||
|
if (!hideLargeItemContents && hasClass(e, "type-contents-toggle")) {
|
||||||
e.open = true;
|
e.open = true;
|
||||||
}
|
}
|
||||||
if (hideMethodDocs && hasClass(e, "method-toggle")) {
|
if (hideMethodDocs && hasClass(e, "method-toggle")) {
|
||||||
|
|
|
@ -65,7 +65,8 @@ impl T for S2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// @has manual_impl/struct.S3.html '//*[@class="trait"]' 'T'
|
// @has manual_impl/struct.S3.html '//*[@class="trait"]' 'T'
|
||||||
// @has - '//details[@open=""]/div[@class="docblock"]' 'Docs associated with the S3 trait implementation.'
|
// @has - '//details/div[@class="docblock"]' 'Docs associated with the S3 trait implementation.'
|
||||||
|
// @!has - '//details[@open=""]/div[@class="docblock"]' 'Docs associated with the S3 trait implementation.'
|
||||||
// @has - '//details[@open=""]/div[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.'
|
// @has - '//details[@open=""]/div[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.'
|
||||||
// @!has - '//div[@class="impl-items"]/details[@open=""]//div[@class="docblock"]' 'Docs associated with the trait a_method definition.'
|
// @!has - '//div[@class="impl-items"]/details[@open=""]//div[@class="docblock"]' 'Docs associated with the trait a_method definition.'
|
||||||
// @has - '//div[@class="impl-items"]/details//div[@class="docblock"]' 'Docs associated with the trait a_method definition.'
|
// @has - '//div[@class="impl-items"]/details//div[@class="docblock"]' 'Docs associated with the trait a_method definition.'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue