-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Include a list of struct methods in reference sidebar on struct pages #41123
Comments
I think the info is too complex to display in the sidebar, and already now you can click the - icon to get an overview. |
cc @rust-lang/docs So, back in the halcyon days of December, I tried writing a table of contents like this. I didn't go to the point of writing out every single item, though; I just stopped at the headers. If this were accepted, I could just resurrect that branch. |
Just for reference, (and perhaps as a counter to the "too much to list" argument) other projects include functions in the sidebar as an expandable list. Here's Microsoft's documentation for the string class for comparison: And here's a screenshot with the functions list expanded, showing how they deal with overloads: |
@mqudsi just because they are bad you shouldn't imitate them. Also, C# has a much simpler type system and not all this bounds/trait stuff that we have. |
@est31 that's a little harsh, isn't it? C# developers seem happy with their ecosystem, and MSFT's documentation structure and layout has changed many times over the years... a more natural conclusion would be that they found this to work (for them, at least). |
@mqudsi I'm happy with what's present with rustdoc today, and I don't want us to regress. |
On the other hand, for several types in std, there's so many methods that having to navigate them all is fairly imposing. And the And for reference, several of .NET's core types have just as many items - methods, fields, etc - on them as several of Rust's, if not more. The expanding sidebar table of contents is how they chose to introduce discoverability into their documentation. One could say the in-doc search is how rustdoc introduces that, but that's more of a means to find something you already know. It's hard to browse through the search bar. |
I've finished up that code work and made a PR in #41280. |
…laumeGomez rustdoc: add a list of headings to the sidebar It's another misdreavus rustdoc PR, which means it's time for Bikeshed City once again! `:3` In an effort to aid navigation in long documentation pages, this PR adds a listing of headings to the sidebars of pages where such headings exist. For example, for structs, links to their fields, inherent methods, and trait implementations are available where applicable. Examples: * Modules/Crate roots ![image](https://cloud.githubusercontent.com/assets/5217170/25019930/1000fa3a-2052-11e7-98ff-ddf5af18b3e6.png) * Enums ![image](https://cloud.githubusercontent.com/assets/5217170/25019954/33497f9e-2052-11e7-88cf-df46f1b3b8a3.png) * Primitives ![image](https://cloud.githubusercontent.com/assets/5217170/25019978/4820bbc6-2052-11e7-8b5a-96a864eb2a5b.png) * Traits ![image](https://cloud.githubusercontent.com/assets/5217170/25020093/bd1bc9f2-2052-11e7-9cd1-00a0ad8007bc.png) * Structs ![image](https://cloud.githubusercontent.com/assets/5217170/25020145/d75206b0-2052-11e7-88cc-9e9525084775.png) Open questions: * Right now, these kinds of pages (and also unions) are the only pages that will receive the name header - pages for functions, constants, macros, etc, won't have the corresponding name in their sidebar. Should I print the name regardless and only add table-of-contents links for pages that have them? This would make them match, for example, a struct with no public fields, no methods, and no trait implementations. The latter would still have a "Struct MyStruct" line above the module contents, with no header links to speak of, whereas a function wouldn't even have "Function my\_function". * This is only a header listing, but there has been requests to include a more-complete listing of fields/methods/traits/etc, for example in rust-lang#41123.
This is a suggestion for the formatting of reference pages for structs in rustdoc, in particular, to discuss the addition of a linked table of
impl
to the sidebar which would serve asa) a quick way to identify methods a struct exposes which can be a great way to quickly find a function you know should exist but don't know the name of in rust, and
b) an easy way to navigate overly-long reference pages (currently, several parts of the rust book and documentation recommend "using ctrl+f to find the impl for xxxx"
As a concrete example, my suggestion would be for the string reference page to change like this:
There are of course several questions about the layout and formatting of such a table. Should arguments be included? If yes, they add not-inconsiderable visual clutter, if no, what about overloads? Are they presented in alphabetical order or in the order they appear in the document? Do we include functions from trait implementations? Do we put them in a separate list?
Thanks for considering.
The text was updated successfully, but these errors were encountered: