Skip to content
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

Add support for intra-doc links #6168

Closed
Veetaha opened this issue Oct 7, 2020 · 4 comments
Closed

Add support for intra-doc links #6168

Veetaha opened this issue Oct 7, 2020 · 4 comments
Labels
E-has-instructions Issue has some instructions and pointers to code to get started E-medium S-actionable Someone could pick this issue up and work on it right now

Comments

@Veetaha
Copy link
Contributor

Veetaha commented Oct 7, 2020

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?

@Veetaha Veetaha changed the title Add goto declaration for intra-doc links Add support for intra-doc links Oct 7, 2020
@matklad matklad added E-has-instructions Issue has some instructions and pointers to code to get started E-medium S-actionable Someone could pick this issue up and work on it right now labels Oct 14, 2020
@kjeremy
Copy link
Contributor

kjeremy commented Dec 11, 2020

I think textDocument/documentLink might be a good alternate approach to this.

@sasurau4
Copy link
Contributor

I'll try it.

bors bot added a commit that referenced this issue Jan 10, 2021
6980: Implement to support intra-doc link r=matklad a=sasurau4

Helps with #6168 

This PR is very limited implementation to support intra-doc. It only support links indicate same file function.

I want someone to feedback me about this implementation. If the approach is good, I will continue this PR to support other symbols like enum and struct. 

Co-authored-by: Daiki Ihara <sasurau4@gmail.com>
@matklad
Copy link
Member

matklad commented May 21, 2021

I think we have the basic support for this already? There are bugs, and the code needs to be refactored for a proper doc pipeline, but that merits separate tracking.

@matklad matklad closed this as completed May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-has-instructions Issue has some instructions and pointers to code to get started E-medium S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

4 participants