-
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
rustdoc: Unify where
clause styling
#113043
Conversation
I cannot find a reason for this `truncate` call, and all tests pass with it removed. I assume it was added to reduce the allocation size (capacity) of the `String`, but the docs explicitly say it has no effect on capacity.
It was never used.
This commit (or one of the prior ones) mostly fixes rust-lang#112901, though it causes one case (item-decl for trait assoc ty) to regress in that issue.
EDIT: see #113043 (comment) for full-page before/after comparison Screenshot (will post more later): |
It's a lot of snapshots, but it's quite hard to test this sort of formatting with other ways.
I think your change breaks alignment starting from the second bound if you have more than one bound since you changed the font size. For example: pub struct Foo<A, B>(A, B)
where
A: Display,
B: Clone; We should add a GUI test for that. For the broken indent (more than 4 whitespace characters diff between As for this indent: pub trait Foo {
fn bar<T>(t: T)
where T: Clone;
} I thought it was voluntary so I left it as is. But you can fix it by removing |
I get where you're coming from with wanting to follow the style guide, but I do not want to endlessly re-litigate this. Whichever of these two options you don't like, I'm sure you agree that thrashing between the two every few months is even worse. I'm not going to approve a PR that reverts #102842 (comment) unless something has happened since then to make bringing it up again worthwhile. There are plenty of things that could invalidate the decision: a field report from some educator showing that the current behavior is confusing to new users, a redesign that makes it less important to format where clauses in a compact way, or a new proposal that wasn't evaluated at the time, just as a few examples. |
I'm fine with switching the formatting back to what it was before. I went with this style guide–based formatting initially because it was unclear to me what the intended style was, since there were inconsistencies. |
The specific case that this PR fixes was not handled by that PR. |
So just to make sure I understand the formatting:
EDIT: specifically, trait methods and assoc items that are in the item-decl get the special formatting. Outside of the item-decl, it seems they're currently formatted the same way as everything else |
You mean removing the 3 whitespace characters indent? |
No, #112901 is that some items have a 9-space indent for their where-clause. |
It has to be normal font, because the three space indentation is designed to line these up:
That's probably a good idea. |
Aye, makes sense. I didn't notice that this decision was FCP'ed. All good then, I defo don't want to needlessly reopen the case. I'm happy as long as where-clauses outside of |
Agree. It makes no sense to try to hyper-optimize the docblocks for compactness. That only makes sense for item-decl. They should probably be different functions. |
@camelid any updates on this? thanks |
Sorry, I haven't had a chance to work on this since June. I think the main thing is for us (T-rustdoc) to agree on what we want our
@GuillaumeGomez @notriddle (and anyone else who's interested) does this sound good to you? |
Sounds good to me. |
☔ The latest upstream changes (presumably #116408) made this pull request unmergeable. Please resolve the merge conflicts. |
@camelid any updates on this? |
Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks |
Fixes #112901 (and other inconsistencies).
After this change, all
where
clauses are rendered the same (except for endingin commas versus semicolons in some cases). They look like this (note that the
where
clause will also be in a slightly-smaller font size than is used for therest of the docs):
r? @GuillaumeGomez