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] Sort items alphabetically in the sidebar #57448

Closed
GuillaumeGomez opened this issue Jan 8, 2019 · 8 comments
Closed

[rustdoc] Sort items alphabetically in the sidebar #57448

GuillaumeGomez opened this issue Jan 8, 2019 · 8 comments
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@GuillaumeGomez
Copy link
Member

Currently, the items on the rustdoc pages are sorted in the order of apparition in the source code. I think it'd be nicer to have them sorted alphabetically.

cc @rust-lang/docs @rust-lang/rustdoc @Geal

@the8472
Copy link
Member

the8472 commented Jan 8, 2019

Items that are related may be grouped in the source, sorting would remove that association. E.g. you can find Vec::new and Vec::with_capacity next to each other and on top since those are likely the first method you'll need.

@QuietMisdreavus
Copy link
Member

Items on module pages are already sorted - the --sort-modules-by-appearance flag disables this behavior.

If we start sorting things on other pages - methods, fields, variants, etc - it needs to be more intelligent than "alphabetically". For example, there have been requests in the past for sorting "static methods" (that don't take self) above others. In this case we'd also have to account for the fact that associated methods are also groups up by impl block, and we treat separate impl blocks independently. If we're going to sort things between blocks, or group them in a different manner, we need to approach that first.

@estebank estebank added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 8, 2019
@QuietMisdreavus
Copy link
Member

One thing i would like to see is grouping things that aren't methods (e.g. associated consts, i don't know if there's anything else you can associate to a type right now) separately from methods. We already break out associated types for traits, it seems right to break out associated consts from the "Methods" section.

@nagisa
Copy link
Member

nagisa commented Jan 8, 2019

Re-sorting alphabetically something that is often carefully sorted by the author already (in source) seems… wrong. At the very least there is a good reason why constructing methods appear first in the source, then many of the deconstructing methods, then first and last, first_mut and last_mut etc close together, etc.

Adding extra heuristics will help with some of the groupings and orderings but not the others.

@GuillaumeGomez
Copy link
Member Author

That's a lot of things I didn't think about. Also, if there is already a flag to disable it, then it's all fine.

@Geal
Copy link
Contributor

Geal commented Jan 9, 2019

@GuillaumeGomez @QuietMisdreavus sorry I couldn't participate on this last night, but I have something to add: keeping the declaration order is nice, but what I would really like is that the index on the left of the page be sorted.
Keeping methods close to each other when they're related in the main content is useful. But an unsorted index is a bit awkward to use.

@GuillaumeGomez
Copy link
Member Author

@Geal On this point I agree. I reopen the issue with this purpose.

@GuillaumeGomez GuillaumeGomez reopened this Jan 9, 2019
@GuillaumeGomez GuillaumeGomez changed the title [rustdoc] Sort items alphabetically [rustdoc] Sort items alphabetically in the sidebar Jan 9, 2019
@nox
Copy link
Contributor

nox commented Jan 19, 2019

It would be nice to at least order trait implementations alphabetically, the current order doesn't even seem to relate in any way with the order of the things in source code.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Feb 7, 2019
…ebar, r=QuietMisdreavus

Sort elements in the sidebar

Fixes rust-lang#57448.

Not sorting fields or variants though.

r? @QuietMisdreavus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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