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

rustdoc: make trait methods findable with Ctrl-F #85923

Closed
jsha opened this issue Jun 2, 2021 · 3 comments
Closed

rustdoc: make trait methods findable with Ctrl-F #85923

jsha opened this issue Jun 2, 2021 · 3 comments
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jsha
Copy link
Contributor

jsha commented Jun 2, 2021

When looking at a struct or enum page, it's common to look for a method with Ctrl-F. This works if the method is part of an inherent implementation (that is, a method on the struct or enum itself). But if the method is part of a trait implementation, Ctrl-F won't find it because trait implementations are toggled closed by default.

I'm not sure of a great way to do this. Some ideas:

  • Listen for Ctrl-F and temporarily open the toggles. Problems: This is probably flaky; it doesn't work when selecting "Find in page" from a menu; we probably wouldn't get any sort of even to know when to close them again.
  • Implement our own in-page search, and override Ctrl-F. Personally I find it really unpleasant when pages do this; I think the browser functionality shouldn't be overridden.
  • Make the trait implementation toggles opened by default. I don't know the pros/cons on this; I assume they are closed by default for a good reason.
@jsha jsha added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) labels Jun 2, 2021
@jyn514
Copy link
Member

jyn514 commented Jun 2, 2021

Make the trait implementation toggles opened by default. I don't know the pros/cons on this; I assume they are closed by default for a good reason.

This is my preference, people are often confused where to find functionality when it's hidden behind a trait.

@jsha
Copy link
Contributor Author

jsha commented Jun 2, 2021

It looks like this is the PR that added toggles for trait implementations, with links to some of the issues it was trying to solve: #47894. The PR has some discussion about hiding by default. It also links to some issues, like #40363.

JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 16, 2021
Open trait implementations' toggles by default.

This makes it possible to use Ctrl-F to find methods defined in traits.

As discussed in rust-lang#85923. This modifies the approach suggested in rust-lang#40363, but still achieves the goal of skimmability. For new users who aren't familiar with all the traits, their methods are readily visible and searchable. For experienced users who prefer to skim the list of all traits, there are two options: the "collapse all" shortcut, and the "auto hide trait implementations" setting.

Demo https://hoffman-andrews.com/rust/expand-methods/std/string/struct.String.html#trait-implementations

r? `@GuillaumeGomez`
@jsha
Copy link
Contributor Author

jsha commented Oct 9, 2021

Fixed in #86260

@jsha jsha closed this as completed Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants