Uh oh!
There was an error while loading. Please reload this page.
show in docs whether the return type of a function impls Iterator/Read/Write - #45039
Conversation
rust-highfive
commented
Oct 5, 2017
Some changes occurred in HTML/CSS. |
rust-highfive
commented
Oct 5, 2017
(rust_highfive has picked a reviewer for you, use r? to override) |
QuietMisdreavus
commented
Oct 5, 2017
@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? |
GuillaumeGomez
commented
Oct 5, 2017
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
52405d3CompareIf 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.) |
QuietMisdreavus
commented
Oct 5, 2017
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. |
bors
commented
Oct 5, 2017
☔ The latest upstream changes (presumably #45046) made this pull request unmergeable. Please resolve the merge conflicts. |
52405d3 to
fdac113CompareQuietMisdreavus
commented
Oct 5, 2017
Force-pushed to resolve linkchecker and the merge conflict. |
QuietMisdreavus
commented
Oct 10, 2017
GuillaumeGomez
commented
Oct 10, 2017
I have a lot of difficulties to appreciate this PR so I think I'll just let someone else handles all this. |
carols10cents
commented
Oct 16, 2017
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! |
QuietMisdreavus
commented
Oct 21, 2017
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. |
bors
commented
Oct 27, 2017
☔ The latest upstream changes (presumably #45285) made this pull request unmergeable. Please resolve the merge conflicts. |
carols10cents
commented
Nov 6, 2017
ping @QuietMisdreavus, looks like there are some merge conflicts in addition to the changes you wanted to make! |
QuietMisdreavus
commented
Nov 7, 2017
I think I cracked it. The @rust-lang/docs What do you think about this? |
fdac113 to
8c13d21CompareQuietMisdreavus
commented
Nov 7, 2017
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 |
GuillaumeGomez
commented
Nov 7, 2017
Will write the modal code starting monday. |
8c13d21 to
9f7ead8CompareQuietMisdreavus
commented
Nov 16, 2017
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 |
QuietMisdreavus
commented
Nov 17, 2017
Also, uh, it looks like htmldocck.py choked on the output? I'm not quite sure what's going on here. |
GuillaumeGomez
commented
Nov 17, 2017
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
8ec73ceCompareQuietMisdreavus
commented
Nov 18, 2017
@GuillaumeGomez I didn't want it to be a tooltip like this, i literally meant the Also the doc-spotlight test failed: |
8ec73ce to
dd73848Comparedd73848 to
6047a03CompareGuillaumeGomez
commented
Nov 18, 2017
Ok, fixed the test and added the wanted thing in the tooltip. |
QuietMisdreavus
commented
Nov 20, 2017
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 |
bors
commented
Nov 20, 2017
📌 Commit 6047a03 has been approved by |
bors
commented
Nov 21, 2017
…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>  </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>  </details>
bors
commented
Nov 21, 2017
☀️ 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 likeFuturecould 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.)whereclass 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
&mutreferences. Rustdoc currently treats a&mut Treference-to-a-generic as an impl on the reference primitive itself.&mut Selfcounts 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)