Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upIntra Rustdoc Links #1946
Conversation
This comment has been minimized.
This comment has been minimized.
|
Awesome! \o/ |
This comment has been minimized.
This comment has been minimized.
fbstj
commented
Mar 7, 2017
|
Bikeshed: would it be useful to have an additional |
This comment has been minimized.
This comment has been minimized.
Hm, I'm wary of adding more cases, and even more so to add magical new syntax. I'd prefer to go with explicit links if you want to set the link text to something other than the full path. (But: If |
This comment has been minimized.
This comment has been minimized.
|
This will need a way to disambiguate between functions, traits, etc. It's completely valid to have a struct and function with the same name. Perhaps we could use URIs for this? Also should this specify whether |
This comment has been minimized.
This comment has been minimized.
|
Previous discussions
|
This comment has been minimized.
This comment has been minimized.
|
Relevant rust-lang/rust issues: rust-lang/rust#36417, rust-lang/rust#38400 |
This comment has been minimized.
This comment has been minimized.
|
@sgrif It only needs to distinguish between values (functions, constants) and types (structs, enums, traits, modules, type-aliases, primitives). Maybe:
|
This comment has been minimized.
This comment has been minimized.
Oh, I had completely missed that this is valid (damn you, Rust!). Is there are an existing way to disambiguate this in paths? Or is it always resolved by the position it appears in? Playing around on the playpen a bit, it seems that (assuming all have the same name):
I think @kennytm idea with a
Good point, that's totally missing from the RFC. Path are relative to the position of item in whose documentation they appear. (See complex example for relative paths.)
Thanks, @kennytm! Reading #1661 (comment), it only feels right to cc @JohnHeitmann. |
This comment has been minimized.
This comment has been minimized.
|
There is talk about extending CommonMark to support syntactic extensions, but it looks like progress has stalled a bit. If we're going to design our own hyperlink destinations (as proposed in this RFC and the comments above), I'd strongly recommend staying within the bounds of what is acceptable for a "link destination" as defined by CommonMark. |
frewsxcv
added
T-doc
T-dev-tools
labels
Mar 7, 2017
This comment has been minimized.
This comment has been minimized.
|
How will cross-crate links be handled? Like,
BTW there is also this thread on talk.commonmark.org discussing the issue from the Markdown side, but it is pretty inconclusive (one suggestion to |
This comment has been minimized.
This comment has been minimized.
@kennytm, rustdoc is already able to generate links to other crates' types, and I would assume we can use this mechanism. For std (and core), it links to an official URL, e.g. https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html. For other external crates, it links to the docs it generated for the crate itself. Update: Sorry, I totally missed
I'm not sure how to approach this best. I'd say we don't generate the link and issue a warning. Rendered docs should probably always contain all possible features. It will be difficult to do this when features are exclusive, i.e. you can't use both |
This comment has been minimized.
This comment has been minimized.
|
Updated the RFC with sections on
I don't think we need to use a potential Markdown extension for this.
I think Rust paths already comply with that. Even the
|
killercup
force-pushed the
killercup:intra-rustdoc-links
branch
from
cacaa79
to
2dd1ed2
Mar 7, 2017
This comment has been minimized.
This comment has been minimized.
|
/cc @jonathandturner who has been working on a rough rustdoc re-write |
This comment has been minimized.
This comment has been minimized.
This is a problem for docs that get cross-included by |
This comment has been minimized.
This comment has been minimized.
Can you give an example? I found Including docs from traits should lead to the docs being evaluated relative to the trait item they are defined on, i.e. relative to |
This comment has been minimized.
This comment has been minimized.
Rust has three namespaces - values, types, and macros. Everything is in one of those three and you don't need any more namespaces than that (it is a bit more complicated because some things can be in more than one namespace, tuple structs, iirc can be used both as type names and as function names). There are already alternate URLs in Rustdoc that use this scheme, unfortunately via redirects (I would love to deprecate the crazy ones with |
This comment has been minimized.
This comment has been minimized.
|
Thanks @killercup ! Here's some thoughts....
That's all (lol, I feel like it's a lot) I've got at the moment, I'm sure I'll have more eventually... |
This comment has been minimized.
This comment has been minimized.
|
For example, there is a link from It's definitely solvable, but it could require "absolute" (i.e. crate-relative) paths in some places. |
This comment has been minimized.
This comment has been minimized.
FWIW, the RLS already creates concrete URLs from paths like this so that when you have a reference to something from std, you can go to the rustdoc page. It might not work exactly how you need it to for this application though. |
This comment has been minimized.
This comment has been minimized.
|
How should Rustdoc know that |
This comment has been minimized.
This comment has been minimized.
|
That's great! Thanks for the ping. I think for a "rustdoc 2.0" idea, we're still a little ways off, yet. Yeah, it will probably consume metadata rather than trying to work against the compiler directly, but there's still a fair bit of research we need to do to explore what we can do there. That said, I'm currently doing the I say go for it and keep improving this rustdoc. It just sets the bar that much higher for the next one (which is a good thing!) |
This comment has been minimized.
This comment has been minimized.
|
@jonathandturner IMO, instead of trying to serialize piecewise, we could have sources for everything, which combined with warm incremental recompilation caches would allow introspecting entire crates. Even if we don't get incremental reparsing, we could still skip parsing and expansion for, say, a |
This comment has been minimized.
This comment has been minimized.
@killercup Markdown has another trick that would make this even sweeter at the use sites:
|
This comment has been minimized.
This comment has been minimized.
|
The 'easy' alternative is to auto-link all items in scope, as in |
This comment has been minimized.
This comment has been minimized.
ollie27
commented
Jun 19, 2017
|
I'm pretty sure rustc special cases the primitive types, I know rustdoc does. rustdoc already has code specifically for generating links to the primitive types so I doubt there will be any issues. As long as there are no types or module named |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp cancel |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jun 20, 2017
|
@nrc proposal cancelled. |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp merge |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jun 20, 2017
•
|
Team member @nrc has proposed to merge this. The next step is review by the rest of the tagged teams:
No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
withoutboats
added
the
proposed-final-comment-period
label
Jun 21, 2017
This comment has been minimized.
This comment has been minimized.
|
@rfcbot reviewed |
2 similar comments
This comment has been minimized.
This comment has been minimized.
michaelwoerister
commented
Jun 22, 2017
|
@rfcbot reviewed |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot reviewed |
This comment has been minimized.
This comment has been minimized.
|
ping @brson for fcp approval |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jul 13, 2017
|
|
rfcbot
added
final-comment-period
and removed
proposed-final-comment-period
labels
Jul 13, 2017
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Jul 23, 2017
|
The final comment period is now complete. |
nrc
referenced this pull request
Jul 25, 2017
Open
Tracking issue for RFC 1946 - intra-rustdoc links #43466
nrc
merged commit 6af994d
into
rust-lang:master
Jul 25, 2017
This comment has been minimized.
This comment has been minimized.
|
Just came up:
should probably not be rendered as a link inside a code block. |
Mange
referenced this pull request
Dec 19, 2017
Closed
RFC: Links to Rust items in documentation text #792
Manishearth
referenced this pull request
Dec 28, 2017
Merged
Implement RFC 1946 - intra-rustdoc links #47046
This comment has been minimized.
This comment has been minimized.
|
We're proposing some amendments in #2285 |
killercup commentedMar 7, 2017
•
edited by mbrubeck
Add a notation how to create relative links in documentation comments (based on Rust item paths) and extend Rustdoc to automatically turn this into working links.
The important bits:
Additions to the documentation syntax
[Iterator](std::iter::Iterator)[Iterator][iter], and somewhere else in the document:[iter]: std::iter::Iterator[Iterator]or[`Iterator`]with automatically generated link reference definitionAll additions are valid CommonMark syntax.
Rendered
Revisions
March 9: Dropped
<Iterator>-style links, added implied reference links (#1946 (comment))May 28: Add more possible extensions, add more syntax for dealing with path ambiguities (#1946 (comment))