RFC: Links to Rust items in documentation text #9864
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
(The syntax should be decided on.
<<<>>>
is just a bad-by-design placeholder so that it gets changed.)The text in
<<<...>>>
would be interpreted as a module-relative path (unless prefixed by::
which makes it crate-relative), since I imagine intra-module links are the most common. And each<<<foo::bar>>>
would get replaced by either[
bar](rustdoc generated link)
or[
foo::bar](rustdoc generated link)
or something (possibly/preferably linking each component of the path in the latter case).Issues
I'm very unsure about:
use
proposal below doesn't work withuse Trait::static_method
or with types either);<<<foo.method>>>
and fields<<<foo.field>>>
.Other tools
'Foo.Bar'
:py:mod:
foo``{@link #foo(type, type)}
{text here][rdoc-ref:Foo::Bar]
(These aren't necessarily correct, and I'm sure there are many many more possible syntaxes.)
Implementation
One possibility for implementation by rustdoc just throwing the contents of each
<<<>>>
into a use statement in the current module like (from the top of the example above):where
unique_name_...
would be designed in so that it can never occur in user code (e.g. containing non-ident characters). After running resolve, rustdoc could go in an extract the value of each name. Notably, the optional.<ident>
gets stripped, and has to be extracted by the rustdoc code itself, and this would also mean that documentation could result in a compile error if any of these links doesn't resolve properly (which is quite sensible IMO).A nicer method would be if resolve could be queried for individual items after running as a whole.
The text was updated successfully, but these errors were encountered: