-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add option to collapse automatically implementors #74196
Conversation
Some changes occurred in HTML/CSS/JS. |
@@ -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 comment
The 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 #variant.X
for example) to be hidden. However, it has been long fixed and this code wasn't removed. And this case, it was a big issue in case you had #implementors
as page id because then it prevented the impl blocks to be collapsed. I tested without this check for all other cases and it works fine.
src/librustdoc/html/render.rs
Outdated
@@ -1291,6 +1291,7 @@ fn settings(root_path: &str, suffix: &str) -> String { | |||
("auto-hide-method-docs", "Auto-hide item methods' documentation", false).into(), | |||
("auto-hide-trait-implementations", "Auto-hide trait implementations documentation", true) | |||
.into(), | |||
("auto-collapse-implementors", "Auto-collapse implementors", true).into(), |
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:
- Auto-hide trait implementation documentation
- Auto-hide trait implementation items
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.
Updated! |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious - why do these use strings instead of true
and false
?
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.
When you use the local storage, it converts everything to string. As simple as that. :)
Updated! |
0c0eea6
to
cb8bdd5
Compare
src/librustdoc/html/render.rs
Outdated
.into(), | ||
("auto-collapse-implementors", "Auto-hide the types which implement a trait", true).into(), |
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.
"implementors of a trait"
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 that's funny, I just asked guillaume to change it from that to the current text. Why do you think 'implementors' is more clear?
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.
It's more concise without being ambiguous. Typically you don't want to use compound clauses in a setting name, it should be short but descriptive
@@ -1289,8 +1289,9 @@ fn settings(root_path: &str, suffix: &str) -> String { | |||
.into(), | |||
("auto-hide-attributes", "Auto-hide item attributes.", true).into(), |
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.
overall i think we might need to fix up the language used for all these settings in a separate issue, it seems very unclear (cc @jyn514 thoughts?)
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.
It's not terribly clear but it does say exactly what it does (attributes
is the technical term for #[some_macro]
, right?). I think it would be helpful to have screenshots before and after, then it's very clear to see.
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 thinking of the entire set of names, not just this one, though. This one is kinda fine.
cb8bdd5
to
40abdf7
Compare
Updated! |
ping |
Like I said, looks good to me. Not sure if you want to wait for other reviewers though. |
Sorry, didn't see your comment. Then let's go, thanks for your review! @bors: r=jyn514 |
📌 Commit 40abdf76ae572500f9c7cc50279a84b690fc500b has been approved by |
src/librustdoc/html/render.rs
Outdated
.into(), | ||
("auto-collapse-implementors", "Auto-hide implentors of a trait", true).into(), |
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.
implementors
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.
Outch, good catch!
@bors: r- |
Updated! (the commits are just now showing up apparently?) |
40abdf7
to
39d99ea
Compare
@bors r+ |
📌 Commit 39d99ea has been approved by |
…arth Rollup of 14 pull requests Successful merges: - rust-lang#72973 (RISC-V GNU/Linux as host platform) - rust-lang#73918 (Clean up E0715 explanation) - rust-lang#73959 (Clean up E0716 explanation) - rust-lang#74119 (Remove `Compiler::compile()`.) - rust-lang#74196 (Add option to collapse automatically implementors) - rust-lang#74218 (Add margin after doc search results) - rust-lang#74276 (improve DiscriminantKind handling) - rust-lang#74291 (Added docs for `From<c_int>` for `ExitStatus`) - rust-lang#74294 (Update cross-compilation README) - rust-lang#74337 (Handle case of incomplete local ty more gracefully) - rust-lang#74344 (Remove string comparison and use diagnostic item instead) - rust-lang#74347 (Initialize default providers only once) - rust-lang#74353 (Edit docs for rustc_middle::dep_graph::dep_node) - rust-lang#74374 (Add a 1.45 release note on lto vs. embed-bitcode) Failed merges: - rust-lang#74251 (Teach bootstrap about target files vs target triples) r? @ghost
Fixes #73403
It adds an option (enabled by default) which collapses all implementors impl blocks.
r? @kinnison
cc @rust-lang/rustdoc