-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustdoc: Foldable impl blocks #47894
Conversation
Addresses rust-lang#40363, rust-lang#45720, rust-lang#24483, rust-lang#23986 and so on * Expands and refactors collapseDocs and toggleAllDocs * Adds [-] toggle to all impls (including inherent impl) * Makes it hiding though main css file, not though element style May need to be addressed: * "[-]" and anchor link copier are overlaid a bit * Inherent methods are also hidden by the global [-] toggle. * Auto-collapsing "Iterator" and so on by default is not implemented yet * Tested only shallowly and only in Chromiuim * No tests. Are there tests for css/js part here? * The new implementation may be a bit slower.
Some changes occurred in HTML/CSS. |
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @GuillaumeGomez (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Thanks for the PR! We’ll periodically check in on it to make sure that @GuillaumeGomez or someone else from the team reviews it soon. |
src/librustdoc/html/static/main.js
Outdated
} | ||
} | ||
|
||
if(action == "show") { |
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.
Missing whitespace after if
.
src/librustdoc/html/static/main.js
Outdated
|
||
var action = mode; | ||
if (action == "toggle") { | ||
if(hasClass(relatedDoc, "fns-now-collapsed")) { |
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.
Missing whitespace after if
.
src/librustdoc/html/static/main.js
Outdated
relatedDoc = relatedDoc.nextElementSibling; | ||
} | ||
|
||
if (!relatedDoc) return; |
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.
Please don't do that. Use {}
, it makes reading easier.
src/librustdoc/html/static/main.js
Outdated
removeClass(n, "hidden-by-impl-hider"); | ||
} | ||
var ns = n.nextElementSibling; | ||
while(true) { |
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.
Missing whitespace after while
.
src/librustdoc/html/static/main.js
Outdated
// we are collapsing the impl block | ||
function implHider(addOrRemove) { | ||
return function(n) { | ||
if(hasClass(n, "method")) { |
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.
Missing whitespace after if
.
src/librustdoc/html/static/main.js
Outdated
if (hasClass(relatedDoc, "docblock")) { | ||
var action = mode; | ||
if (action == "toggle") { | ||
if(hasClass(relatedDoc, "hidden-by-usual-hider")) { |
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.
Missing whitespace after if
.
src/librustdoc/html/static/main.js
Outdated
} | ||
} | ||
|
||
if(action == "show") { |
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.
Also, please use ===
.
src/librustdoc/html/static/main.js
Outdated
var action = mode; | ||
if (action == "toggle") { | ||
if(hasClass(relatedDoc, "fns-now-collapsed")) { | ||
action="show"; |
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.
Missing whitespace around =
.
src/librustdoc/html/static/main.js
Outdated
if(hasClass(relatedDoc, "fns-now-collapsed")) { | ||
action="show"; | ||
} else { | ||
action="hide"; |
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.
Missing whitespace around =
.
src/librustdoc/html/static/main.js
Outdated
removeClass(relatedDoc, "fns-now-collapsed"); | ||
onEach(toggle.childNodes, adjustToggle(false)); | ||
onEach(relatedDoc.childNodes, implHider(false)); | ||
} else if (action == "hide") { |
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.
Please use ===
.
@@ -386,3 +386,8 @@ kbd { | |||
background: #353535; | |||
} | |||
} | |||
|
|||
.hidden-by-impl-hider, |
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.
This rule has nothing to do in themes. Please put in rustdoc.css
at the upper level.
@@ -383,3 +383,8 @@ kbd { | |||
background: #fff; | |||
} | |||
} | |||
|
|||
.hidden-by-impl-hider, |
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.
This rule has nothing to do in themes. Please put in rustdoc.css
at the upper level.
I made a first quick review. I'll test what it's doing this evening or tomorrow. Seems globally good otherwise (just nits mainly) . |
Is there maybe some automatic script that makes whitespace in javascript files meet the standard in one move? |
Where the list of collapsed-by-default traits should reside? In Rust part (marking html elements with a class like "collapsed-by-default") or in Javascript part? |
@vi Why not collapse all trait implementations by default? In most cases you want to visit the actual trait documentation anyway, since the documentation at the implementation only shows a single line or so per method. |
A good idea. Important things like associated types/consts or impl-level documentation are visible even when collapsed anyway. |
💔 Test failed - status-travis |
@bors retry 3 hour timeout in |
…umeGomez,QuietMisdreavus rustdoc: Foldable impl blocks Addresses rust-lang#40363, rust-lang#45720, rust-lang#24483, rust-lang#23986 and so on * Expands and refactors collapseDocs and toggleAllDocs * Adds [-] toggle to all impls (including inherent impl) * Makes it hiding though main css file, not though element inline style May need to be addressed: * "[-]" and anchor link copier are overlaid a bit * Inherent methods are also hidden by the global [-] toggle. * Auto-collapsing "Iterator" and so on by default is not implemented yet * Tested only shallowly and only in Chromiuim * No tests. Are there tests for css/js part here? * The new implementation may be a bit slower. What next steps are need to be done before the integration?
⌛ Testing commit df1b9a8 with merge 2452e2bfc1b92af2cb68e162a3cad0f9d473f177... |
💔 Test failed - status-travis |
@bors retry 3 hour timeout in Timing breakdown
41 minutes spent on compiling LLVM (for s390x), maybe sccache network error? |
…ietMisdreavus rustdoc: Foldable impl blocks Addresses #40363, #45720, #24483, #23986 and so on * Expands and refactors collapseDocs and toggleAllDocs * Adds [-] toggle to all impls (including inherent impl) * Makes it hiding though main css file, not though element inline style May need to be addressed: * "[-]" and anchor link copier are overlaid a bit * Inherent methods are also hidden by the global [-] toggle. * Auto-collapsing "Iterator" and so on by default is not implemented yet * Tested only shallowly and only in Chromiuim * No tests. Are there tests for css/js part here? * The new implementation may be a bit slower. What next steps are need to be done before the integration?
☀️ Test successful - status-appveyor, status-travis |
I often find the § disappearing as I move the cursor from the header to the § in order to copy the link, so I'd be in favor of fixing that ;-). |
It's been fixed in rustdoc already. |
Addresses #40363, #45720, #24483, #23986 and so on
May need to be addressed:
What next steps are need to be done before the integration?