-
Notifications
You must be signed in to change notification settings - Fork 13k
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
show in docs whether the return type of a function impls Iterator/Read/Write #45039
Conversation
Some changes occurred in HTML/CSS. |
(rust_highfive has picked a reviewer for you, use r? to override) |
@rust-lang/docs Bikeshed request: Is this layout okay? Also which of the "Known shortcomings" above should i work to resolve before merging this, and which are okay to keep around while the spotlight parameter is still unstable? |
I don't like it. It feels like the function is implementing all this. We should try to think about how to give this information but not by default (the display is already very heavy). Maybe when we hover a little symbol close to the returned type? Or maybe even when hovering the returned type directly? |
28a8481
to
52405d3
Compare
If it's a matter of the layout on the final page, that can easily be changed. The problem with making it a hover on the return type directly is that it's not very discoverable. It's already a bit of a secret that those type names are links, so it feels like adding something that's not visible or easily explained would render this change much less useful. Making it a new icon (and putting the impl in a hover off that) at least provides some affordance, but risks being easily overlooked. There is some precedent here with the "warning" icon on unsafe functions, and now the extra CSS on ignored doc blocks. I'm not too familiar with how something like that would be implemented, if we want the links in this impl to be clickable? Maybe putting it in a separate docblock that's automatically hidden? That may create some strange interactions with the toggle wrapper, but saves on a bit of the noise you're talking about. (EDIT: Also i force-pushed to fix the test that broke travis.) |
New travis error: Turns out i was generating links wrong and created a lot of broken links. I think i have a fix, but i'm running linkchecker locally to make sure i solved it. |
☔ The latest upstream changes (presumably #45046) made this pull request unmergeable. Please resolve the merge conflicts. |
52405d3
to
fdac113
Compare
Force-pushed to resolve linkchecker and the merge conflict. |
I have a lot of difficulties to appreciate this PR so I think I'll just let someone else handles all this. |
Sounds like this pr is waiting for some feedback from @rust-lang/docs members? I'm going to change this to S-waiting-for-team, please adjust if that's not where this is at! |
We did talk about this in the docs team meeting last week, and it seemed like everyone would be better on board with this if the way it was laid out on the page was cleaned up some. I need to dig into the "toggle wrapper" logic in the rustdoc javascript to see if i can get my last screenshot to work the way i wanted, where it was foldable and automatically hidden. Haven't taken the chance to do that, though. |
☔ The latest upstream changes (presumably #45285) made this pull request unmergeable. Please resolve the merge conflicts. |
ping @QuietMisdreavus, looks like there are some merge conflicts in addition to the changes you wanted to make! |
I think I cracked it. The @rust-lang/docs What do you think about this? |
fdac113
to
8c13d21
Compare
I asked @GuillaumeGomez about the latest design during today's docs team meeting, and he offered to help out with designing a better display for this, basing it on the existing modal shown for the |
Will write the modal code starting monday. |
8c13d21
to
9f7ead8
Compare
imperio and i just walked through the design of the new spotlight modal, and here's what we came up with: Associated methods get a little circle-i next to their toggle wrapper if they return something that implements a spotlighted trait: Bare functions get the circle-i next to their definition: Clicking the circle-i opens up a modal window that shows the impl(s) of any spotlighted traits on the return type: The circle-i also shows up on trait pages: @GuillaumeGomez Before i start doing fine-grain code review, i have one more suggestion: Right now there's no |
Also, uh, it looks like htmldocck.py choked on the output? I'm not quite sure what's going on here.
|
Maybe a missing closing tag? I'll investigate. Also, I was thinking about the title as well. Can you come up with a text to put while I work on the title design? |
9f7ead8
to
8ec73ce
Compare
@GuillaumeGomez I didn't want it to be a tooltip like this, i literally meant the Also the doc-spotlight test failed:
|
8ec73ce
to
dd73848
Compare
dd73848
to
6047a03
Compare
Ok, fixed the test and added the wanted thing in the tooltip. |
Okay, so this is how it looks now: I think at this point i'm ready to call it good? The tooltip having a link in there is awkward, and possibly leads to bad contrast levels depending on what font gets pulled. (On a different machine it used the sans-serif font from the headers? Not sure what's going on on this one.) If it leads to problems, the fix is literally two additional characters, so i'm not all that concerned. Here we gooooooo~ @bors r=GuillaumeGomez,QuietMisdreavus |
📌 Commit 6047a03 has been approved by |
…z,QuietMisdreavus show in docs whether the return type of a function impls Iterator/Read/Write Closes #25928 This PR makes it so that when rustdoc documents a function, it checks the return type to see whether it implements a handful of specific traits. If so, it will print the impl and any associated types. Rather than doing this via a whitelist within rustdoc, i chose to do this by a new `#[doc]` attribute parameter, so things like `Future` could tap into this if desired. ### Known shortcomings ~~The printing of impls currently uses the `where` class over the whole thing to shrink the font size relative to the function definition itself. Naturally, when the impl has a where clause of its own, it gets shrunken even further:~~ (This is no longer a problem because the design changed and rendered this concern moot.) The lookup currently just looks at the top-level type, not looking inside things like Result or Option, which renders the spotlights on Read/Write a little less useful: <details><summary>`File::{open, create}` don't have spotlight info (pic of old design)</summary> ![image](https://user-images.githubusercontent.com/5217170/31209495-e59d027e-a950-11e7-9998-ceefceb71c07.png) </details> All three of the initially spotlighted traits are generically implemented on `&mut` references. Rustdoc currently treats a `&mut T` reference-to-a-generic as an impl on the reference primitive itself. `&mut Self` counts as a generic in the eyes of rustdoc. All this combines to create this lovely scene on `Iterator::by_ref`: <details><summary>`Iterator::by_ref` spotlights Iterator, Read, and Write (pic of old design)</summary> ![image](https://user-images.githubusercontent.com/5217170/31209554-50b271ca-a951-11e7-928b-4f83416c8681.png) </details>
☀️ Test successful - status-appveyor, status-travis |
Closes #25928
This PR makes it so that when rustdoc documents a function, it checks the return type to see whether it implements a handful of specific traits. If so, it will print the impl and any associated types. Rather than doing this via a whitelist within rustdoc, i chose to do this by a new
#[doc]
attribute parameter, so things likeFuture
could tap into this if desired.Known shortcomings
The printing of impls currently uses the(This is no longer a problem because the design changed and rendered this concern moot.)where
class over the whole thing to shrink the font size relative to the function definition itself. Naturally, when the impl has a where clause of its own, it gets shrunken even further:The lookup currently just looks at the top-level type, not looking inside things like Result or Option, which renders the spotlights on Read/Write a little less useful:
`File::{open, create}` don't have spotlight info (pic of old design)
All three of the initially spotlighted traits are generically implemented on
&mut
references. Rustdoc currently treats a&mut T
reference-to-a-generic as an impl on the reference primitive itself.&mut Self
counts as a generic in the eyes of rustdoc. All this combines to create this lovely scene onIterator::by_ref
:`Iterator::by_ref` spotlights Iterator, Read, and Write (pic of old design)