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 4 commits 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

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.
@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.

done a bit awkwardly to try to avoid introducing
new whitespaces nodes, which could affect display
@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 and others added 2 commits June 4, 2025 10:56
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustdoc: Quick way to collapse all impl blocks
5 participants