-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Add option to collapse automatically implementors #74196
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2241,8 +2241,7 @@ function defocusSearchBar() { | |
relatedDoc = relatedDoc.nextElementSibling; | ||
} | ||
|
||
if ((!relatedDoc && hasClass(docblock, "docblock") === false) || | ||
(pageId && document.getElementById(pageId))) { | ||
if (!relatedDoc && hasClass(docblock, "docblock") === false) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Little note about this change for the reviewers: it was to prevent an element targetted by the url hash (so |
||
return; | ||
} | ||
|
||
|
@@ -2362,6 +2361,7 @@ function defocusSearchBar() { | |
(function() { | ||
var toggle = createSimpleToggle(false); | ||
var hideMethodDocs = getCurrentValue("rustdoc-auto-hide-method-docs") === "true"; | ||
var hideImplementors = getCurrentValue("rustdoc-auto-collapse-implementors") !== "false"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious - why do these use strings instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you use the local storage, it converts everything to string. As simple as that. :) |
||
var pageId = getPageId(); | ||
|
||
var func = function(e) { | ||
|
@@ -2391,7 +2391,13 @@ function defocusSearchBar() { | |
if (hasClass(e, "impl") && | ||
(next.getElementsByClassName("method").length > 0 || | ||
next.getElementsByClassName("associatedconstant").length > 0)) { | ||
insertAfter(toggle.cloneNode(true), e.childNodes[e.childNodes.length - 1]); | ||
var newToggle = toggle.cloneNode(true); | ||
insertAfter(newToggle, e.childNodes[e.childNodes.length - 1]); | ||
// In case the option "auto-collapse implementors" is not set to false, we collapse | ||
// all implementors. | ||
if (hideImplementors === true && e.parentNode.id === "implementors-list") { | ||
collapseDocs(newToggle, "hide", pageId); | ||
} | ||
} | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is confusing, I wonder if we can just merge this with the previous option?
Or perhaps two settings:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum... Maybe a rewording? But I think it'd be nice trying to make settings more obvious more generally. In this case, we target just the implementors (the section and its children), not the trait implementations generally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I just think that when you have so many it gets confusing. Definitely when I look at the page I'm unsure as to what some of the options do.
Rewording seems fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to suggestions then! Btw: should I do it in this PR directly or should I open a new one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do it here itself. I suggested options for the wording above for the two settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh indeed! Thanks, sending an update shortly.