Skip to content

rustdoc: add ways of collapsing all impl blocks #141663

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lolbinarycat
Copy link
Contributor

either shift+click the Summary button,
or use the _ key.

this collapses everything,
including (inherent) impl blocks.

no need for a special "expand all impl blocks"
method, as impl blocks are expanded during regular "expand all".
doing "expand all" -> "collapse all" will always
result in only impl blocks being expaned.

not sure the best way to add a GUI test.

fixes #134429

@rustbot
Copy link
Collaborator

rustbot commented May 27, 2025

r? @notriddle

rustbot has assigned @notriddle.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels May 27, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 27, 2025

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @jsha, @lolbinarycat

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member

I'm neutral about this. I don't see the need but I suppose if someone opened the issue, there is one...

cc @rust-lang/rustdoc-frontend

@lolbinarycat
Copy link
Contributor Author

It's a small improvement, but I think it is helpful, especially for internal docs. For example, if I had this, I might not have made the mistake of initially adding BufReader::peek to the wrong impl block. The feature also seems very trivial to implement and maintain.

@notriddle
Copy link
Contributor

It wouldn't be hard to test the _ keyboard shortcut using the GUI test runner (it's the same way the - keyboard shortcut is tested).

Anyway, 👍 this feature.

collapseAllDocs();
collapseAllDocs(false);
break;
case "_":
Copy link
Member

Choose a reason for hiding this comment

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

I don't think adding a new key to handle it is a good idea. What you suggested with shift+minus sounds like a better approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

doesn't shift + minus send _ on a standard US keyboard? or is there something I don't know about JS events?

Copy link
Contributor

Choose a reason for hiding this comment

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

It does, yes. getVirtualKey uses event.key, which sends the printable representation of the text.

Copy link
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

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

I don't have opinion on the feature, however I think we should definitely talk about the new key binding (_).

@lolbinarycat
Copy link
Contributor Author

I think it's also worth asking if we should make a way of doing this on mobile, but i don't see an easy way, it seems like we would have to manually implement a double tap delay or something similar.

@GuillaumeGomez GuillaumeGomez removed the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jun 16, 2025
@GuillaumeGomez
Copy link
Member

@rfcbot merge

@rfcbot
Copy link
Collaborator

rfcbot commented Jun 16, 2025

Team member @GuillaumeGomez has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jun 16, 2025
either shift+click the Summary button,
or use the `_` key.

this collapses everything,
including (inherent) impl blocks.

no need for a special "expand all impl blocks"
method, as impl blocks are expanded during regular
"expand all".
doing "expand all" -> "collapse all" will always
result in only impl blocks being expaned.

some of the html is split up a bit awkwardly to
try to avoid introducing new whitespaces nodes,
which could affect display.

Co-authored-by: Guillaume Gomez <[email protected]>
@lolbinarycat lolbinarycat force-pushed the rustdoc-collapse-impl-134429 branch from 8861980 to b676f55 Compare June 16, 2025 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustdoc: Quick way to collapse all impl blocks
6 participants