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

Common well-known traits make "Trait Implementations" too verbose #40363

Open
kornelski opened this issue Mar 8, 2017 · 5 comments
Open

Common well-known traits make "Trait Implementations" too verbose #40363

kornelski opened this issue Mar 8, 2017 · 5 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. P-low Low priority T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@kornelski
Copy link
Contributor

kornelski commented Mar 8, 2017

I find the "Trait Implementations" section of Rustdoc very hard to follow. It has low signal to noise ratio:

  • Very common traits are displayed in full detail. For traits like Copy, Clone, Default, Display, Debug, Hash, etc. I don't need to see all the methods inline with their description. Just links to these traits would be enough. Generally I only need to know whether the type implements them or not.

  • Similarly, traits used via operators are also displayed in full detail. Eq, PartialEq, Add, Sub, Ord, PartialOrd, etc. flood the documentation page with documentation of the traits, and the specific methods are even less relevant. The long verbose list makes it hard to see which traits are supported.

  • If the type implements the same trait multiple times for slightly different types, the whole trait documentation is repeated multiple times. It is useful to know which type combinations are supported, but repeated function descriptions only lower signal to noise ratio. It's worst for primitive types where the list appears to be dominated by countless the variants of Shr and Shl, drowning out all other information.

The current layout does work well for less common/more specific traits, e.g. having entire trait documentation inlined is perfect for *Ext traits and makes sense in some cases like impl Read for File.

So I'm suggesting:

  • Implement collapsing widget for trait implementations, which collapses documentation of methods, leaving only [+] impl Trait for Foo line.

  • Collapse basic traits by default (Copy, Clone, Debug, std::ops::*, etc.). Not all traits in std are obvious, so the list of traits to display in a terse form would probably be manually curated.

  • Group implementations of the same trait together, and collapse all implementations except one. For example File displays all of Read docs twice, in two separate places. It makes the list longer and makes it harder to notice that there are two implementations. It would be clearer to display it as:

    [+] impl Read for File
    [-] impl<'a> Read for &'a File
    fn read(&mut self) …

@GuillaumeGomez
Copy link
Member

cc @rust-lang/docs

@GuillaumeGomez GuillaumeGomez added A-docs T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Mar 15, 2017
@steveklabnik steveklabnik added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Mar 23, 2017
@steveklabnik steveklabnik changed the title [rustdoc] Common well-known traits make "Trait Implementations" too verbose Common well-known traits make "Trait Implementations" too verbose Mar 23, 2017
@steveklabnik steveklabnik added the T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. label May 18, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 27, 2017
@steveklabnik steveklabnik added the P-low Low priority label Aug 30, 2017
@QuietMisdreavus QuietMisdreavus self-assigned this Oct 10, 2017
@vi
Copy link
Contributor

vi commented Jan 29, 2018

Implement collapsing widget for trait implementations, which collapses documentation of methods, leaving only [+] impl Trait for Foo line.

Thinking about implementing this.

vi added a commit to vi/rust that referenced this issue Jan 31, 2018
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.
@vi
Copy link
Contributor

vi commented Jan 31, 2018

Is there some exhausive list or traits (in std or maybe across the entire ecosystem) that should be collapsed by default?

@kornelski
Copy link
Contributor Author

I'd look through std::ops, as these are the noisiest.

@vi
Copy link
Contributor

vi commented Jan 31, 2018

It is also suggested just to collapse all impls items by default. It is simpler.

Manishearth added a commit to Manishearth/rust that referenced this issue Feb 25, 2018
…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?
bors added a commit that referenced this issue Feb 28, 2018
…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?
@steveklabnik steveklabnik removed the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label May 29, 2018
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`
@ehuss ehuss removed the T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. label Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. P-low Low priority 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

7 participants