-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 should use fully-qualified names sometimes #2004
Comments
(Some previous discussion of the idea here: #356 (comment)) It sounds like always using full paths for anything from a different crate would be a good idea, but it may also sometimes be warranted intra-crate, e.g. to more clearly distinguish Couldn't we also (even as we try to choose a sensible default) expose the choice in the rendered rustdocs themselves, e.g. as a "show full paths" checkbox (or a 3-way always/never/sometimes)? There's no rule that the generated pages have to be static. |
@glaebhoerl I think we should try to avoid ambiguities but otherwise keep the paths short. |
It shows the full path on mouse over already. An option would be showing |
That's true, but I think there was some discussion before about how javascript is required for rustdocs... I personally don't mind one way or the other since I use chrome or firefox, but maybe something to keep in mind? |
@mark-i-m Yes, you can get a feel for this when looking at types in error messages, it's quite bad. I'd like only to prefix what's overlapping with the prelude, i.e. |
@eddyb Hmm... that seems a bit unsatisfying to me, though. I don't know libraries well enough to know off-hand that I went and did a case study with a recent error message I got:
You are right that the second is a lot easier to read if I know where all the types come from, but unfortunately, I don't (and I wrote this code 2 days ago). Something did occur to me as I was looking at this though... Currently rustdocs has this nifty expand/collapse feature. It's great if you just want to do a quick lookup for the name of method or argument order or something. Then if you want a closer look, you can just expand that item. Taking inspiration from @glaebhoerl's suggestion above, we might consider showing the full name of a type for expanded items and only the condensed type for collapsed ones. |
I've previously wanted a tool to recommend optimizations to |
I'm not quite sure I followed that. Could you give an example of how rustdocs would change? Are you saying that rustdocs should include the |
No. I think docs cannot use the actual I suppose "go up levels until all ambiguities get resolved" sounds fine, maybe along with "stop early if only this item appears under its own name in a |
Well, yeah, but it could figure out what names a user would have to
After thinking some more about this, I am not sure this would work after all. The reason is that a name might be unambiguous without it being obvious. For example, suppose I actually am using |
@eddyb Did any of these suggestions/arguments seem convincing to you? I'm inclined to open an actual RFC, but I don't want to suggest a feature that will make half of rust programmers annoyed at the other half 😛 |
Going to close this since there is an actual RFC to reduce clutter |
Suggestion: rustdoc should use fully-qualified names for anything not declared in the documented crate.
Here is an example from Tokio that I just came across:
Notice the
<Error=Error>
parts? I propose that they should be fully-qualified as<Error=std::io::Error>
, which is a lot clearer, IMHO.The text was updated successfully, but these errors were encountered: