-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Comments
cc @rust-lang/docs |
Thinking about implementing this. |
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.
Is there some exhausive list or traits (in |
I'd look through |
It is also suggested just to collapse all impls items by default. It is simpler. |
…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?
…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?
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`
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
andShl
, 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 likeimpl 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 instd
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 ofRead
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:The text was updated successfully, but these errors were encountered: