Skip to content
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

Merged
merged 2 commits into from
Jul 16, 2020

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Jul 9, 2020

Fixes #73403

It adds an option (enabled by default) which collapses all implementors impl blocks.

r? @kinnison
cc @rust-lang/rustdoc

@rust-highfive
Copy link
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 9, 2020
@@ -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) {
Copy link
Member Author

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.

@@ -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(),
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member Author

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.

@GuillaumeGomez
Copy link
Member Author

Updated!

src/librustdoc/html/render.rs Outdated Show resolved Hide resolved
@@ -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";
Copy link
Member

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?

Copy link
Member Author

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. :)

@GuillaumeGomez
Copy link
Member Author

Updated!

.into(),
("auto-collapse-implementors", "Auto-hide the types which implement a trait", true).into(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"implementors of a trait"

Copy link
Member

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?

Copy link
Member

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(),
Copy link
Member

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?)

Copy link
Member

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.

Copy link
Member

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.

@GuillaumeGomez
Copy link
Member Author

Updated!

@GuillaumeGomez
Copy link
Member Author

ping

@jyn514
Copy link
Member

jyn514 commented Jul 15, 2020

Like I said, looks good to me. Not sure if you want to wait for other reviewers though.

@GuillaumeGomez
Copy link
Member Author

Sorry, didn't see your comment. Then let's go, thanks for your review!

@bors: r=jyn514

@bors
Copy link
Contributor

bors commented Jul 15, 2020

📌 Commit 40abdf76ae572500f9c7cc50279a84b690fc500b has been approved by jyn514

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 15, 2020
.into(),
("auto-collapse-implementors", "Auto-hide implentors of a trait", true).into(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implementors

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outch, good catch!

@GuillaumeGomez
Copy link
Member Author

@bors: r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 15, 2020
@GuillaumeGomez
Copy link
Member Author

Updated! (the commits are just now showing up apparently?)

@Manishearth
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 15, 2020

📌 Commit 39d99ea has been approved by Manishearth

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 15, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 16, 2020
…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
@bors bors merged commit efad203 into rust-lang:master Jul 16, 2020
@GuillaumeGomez GuillaumeGomez deleted the auto-collapse-implementors branch July 16, 2020 08:07
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustdoc: Add "Auto-hide trait implementors" to settings
7 participants