Skip to content

Add support for intra-doc links #6168

Closed
@Veetaha

Description

@Veetaha

Intra-doc links rustdoc feature is soon to be shipped with the stable rust toolchain: rust-lang/rust#43466

I propose to add a feature for their support in ide.
The simplest and useful thing that I miss is the ability to navigate to the linked symbol definition in the source code.
Suppose we have the following:

/// Blah, .. [`foo`]
pub fn bar() { }

/// You might want to see [`std::fs::read()`] too.
pub fn foo() { }

I suggest that when we hover over [`foo`] symbol in the doc comment we can use goto-declaration/definition and the editor should open the file and the line where the referenced symbol is located, in this case it should be the same file, function foo.
The link in pub fn foo() documentation should also be actionable and direct us to the source code of std::fs::read function.
We might also want to highlight (via semantic tokens) that the given link is an intra-doc link (maybe even preserving the information about the symbol kind (function/variable/struct/trait...)).

The initial implementation of this feature might just use the current path resolving instrumentation of rust-analyzer and this will already be very useful, after that we might also support path disambiguation syntax of intra-doc links, maybe even suggest completions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-has-instructionsIssue has some instructions and pointers to code to get startedE-mediumS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions