-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Improve associated constant rendering in rustdoc #39944
Conversation
LGTM. Gonna hold off on doing an r+ to see if others have feedback. |
Definitely nicer! My only remaining concern is that long definitions still look quite bad. As an example, see ContentType::JSON. If the definition remains on the same line as the name of the constant, the rendering won't look great. To ameliorate this, I propose that we adopt one of the following:
|
I feel a bit off for hiding type and value information by default. In your case, the indent will allow to make the reading easier (which is helped by the new style). |
Seems good to me too. |
Not quite a fan, but probably better than nothing. I like @SergioBenitez's suggestion 3, though I'm not sure how rustdoc receives the values of associated consts. It might take some finesse (read: duplicate code) to get it to render through the same pretty-print as a struct's definition. |
I just thought that moving associated consts in a "category" of their own might be problematic in case this value is only for certain implementation (I think about type parameters specialization). |
That's not what I'm proposing, @GuillaumeGomez. Keep the
A larger example:
You can play with the formatting and optionally hide the definition by default. |
Ok, sorry the misunderstanding! This way seems to be quite good indeed. I'll give it a try. |
abe2389
to
ba4a43c
Compare
@GuillaumeGomez I think we still want to know the type in the non-hidden version, right? |
Looking great @GuillaumeGomez, nice job :) |
ba4a43c
to
5ac7a03
Compare
Actually, if the definition is visible by default, maybe it's okay to not include the type in the hidden version? |
I'll need to add tests as well. |
So, I added all missing types in the "correct" output and added tests (and filed an ICE, so nice of me). |
@SergioBenitez what do you think? |
@bors r+ |
📌 Commit bd704ba has been approved by |
⌛ Testing commit bd704ba with merge 9b19645... |
@bors retry |
⌛ Testing commit bd704ba with merge f7cc0c6... |
@bors: retry Looks like travis missed this PR... |
…=frewsxcv Improve associated constant rendering in rustdoc Before: <img width="1440" alt="screen shot 2017-02-19 at 00 30 51" src="https://cloud.githubusercontent.com/assets/3050060/23097697/caeed80e-f63a-11e6-98c2-5d27e4efd76d.png"> After: <img width="1440" alt="screen shot 2017-02-19 at 00 30 39" src="https://cloud.githubusercontent.com/assets/3050060/23097698/cfb4874e-f63a-11e6-80cf-ffbf5c5c6162.png"> cc @SergioBenitez r? @rust-lang/docs
Before:
After:
cc @SergioBenitez
r? @rust-lang/docs