Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
RFC for rustdoc jump to definition #1
base: master
Are you sure you want to change the base?
RFC for rustdoc jump to definition #1
Changes from 1 commit
09e89eb
389d305
48babf5
b28ca08
521fc2f
56af431
a00ae18
10e5626
d4cd0aa
0f11efe
0a6fb7b
ba9881f
b7a206d
2dd4f6c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand the whole cross-crate links section correctly, you seem to be saying that it is not possible at all for rustdoc to detect if a to-be-generated link would point to a nonexistent location.
However, from the limited experience I've gathered from writing several A-cross-crate-reexport PRs, I've learned that rustdoc does know if a cross-crate link wouldn't resolve. Maybe that's not always the case but at least it is for code using
html::format::href()
.So from what I know, rustdoc should be able to “gray out” / not generate (most? all?) links that would otherwise be dead. Specifically, the following paragraph should be updated to mention this:
Or am I missing something major?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to mean not the cross-crate item itself but the actual HTML file destination. As I mentioned, you can run
cargo --no-deps
and in this case, only your crate will be documented and not its dependencies. As such, any link to any dependency will result in a 404. Does it clear the confusion? How could I rewrite it to make it less confusing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to improve the wording and explanations of this section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a particularly solid justification. It is important for rustdoc to know where dep docs are, and it already does! That does not explain why it needs to have it in its source view.
I might be misunderstanding this paragraph but it doesn't really seem to add new justification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually took it from this comment. I thought @jsha wanted me to add it to underline even further why it made more sense to have it in rustdoc directly. But maybe I misunderstood what they meant? Or maybe my transcription of what they said is a complete failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of this argument is: because rustdoc already knows where the dep docs are, and GitHub/Google Code Search probably never will (at least not with confidence), this is an advantage that code navigation within rustdoc's source view has over code navigation within GitHub/Google Code Search.
Here's a concrete example (unfortunately it will only work if you are in GitHub's Code Search preview):
Visit https://cs.github.com/servo/servo/blob/9901cb399320e67c3ad2d62bf3a51d6ca993667b/components/net/decoder.rs#L102, part of the servo source code. It defines a gzip decoder:
How do I get to the definition of
gzip::Decoder
? If I click on it, GitHub Code Search tells me the definition is in the same file, line 69. Well, that's just plain wrong - that's another struct that happens to share the name Decoder.But even setting aside that mistake - could GitHub Code Search find the source for
libflate::non_blocking::gzip::Decoder
and link me there? I think not; it's in a different repository, and I strongly suspect GitHub Code Search does not have any notion of cross-repository dependencies that follows Rust's package graph.In practice, hard to test because even clicking the link to search "all repos" fails to find
libflate::non_blocking::gzip::Decoder
, presumably because it is not yet indexed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is exactly what i'm worried about wrt scope expansion, fwiw.
Rustdoc is not a source code browser tool. It has source in its capacity to aid its purpose as a doc viewer. It is still insufficiently motivated (in this RFC) that better source code browsing is important for documentation viewing, because source is already very much a secondary purpose of rustdoc that it uses as an aid.
Going from there to reverse-search seems like an even bigger leap, and it only makes sense if we have presupposed that Rustdoc is equally a tool for browsing source. And if we are deciding that, we need to decide that very clearly in this RFC, and not have it just happen by accident.
The worry I have is that we are turning rustdoc from a tool designed for the users of a crate to a tool designed for the maintainers of a crate (and still the users, but now it's both). And that's a pretty big scope expansion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just like prior-art, I added it because it was mentioned as a possible extension. Accepting this RFC doesn't necessarily mean that the feature will evolve any further. But if you prefer that I don't mention it, it's just as fine for me.