Autocomplete cargo doc paths/links to types in doc comment
See original GitHub issueIf you write something like the following in a doc comment
/// An error returned by [`RefCell::try_borrow`](struct.RefCell.html#method.try_borrow).
#[stable(feature = "try_borrow", since = "1.13.0")]
pub struct BorrowError {
_private: (),
}
The struct.RefCell.html#method.try_borrow
your documentation site will link to the try_borrow
method when you click on the RefCell::try_borrow
link.
Since the naming convention for pages / links within a cargo doc generated site is consistent - could intellij-rust support autocomplete for these links?
This would make it much easier to write documentation that references other types/methods within your library.
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Autocomplete cargo doc paths/links to types in doc comment
I've opened this same issue in intellij-rust, but figured I'd also open it here since I'm interested in both tools.
Read more >1946-intra-rustdoc-links - The Rust RFC Book - GitHub Pages
Documentation comments at the module (or crate) level are used to give an overview of the module (or crate) and describe how the...
Read more >cargo doc - The Cargo Book
Build the documentation for the local package and all dependencies. The output is placed in target/doc in rustdoc's usual format.
Read more >Jedi - Read the Docs
Jedi is a static analysis tool for Python that is typically used in IDEs/editors plugins. Jedi has a focus on autocompletion and goto...
Read more >beyond documentation All the goodies packed in rustdoc, and ...
by Guillaume GomezAt: FOSDEM 2020https://video.fosdem.org/2020/K.3.401/rust_rustdoc.webmRust compiler comes with a few tools, rustdoc is one ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Kobzol
PsiReferenceContributor
can provide references inside element. For example, you recently implemented path completion inside string literals. And each path segment is a separate reference although it’s still a single string literal element. But from my point of view, the main problem is parsing. We need to parse markdown in doc comments to get proper PSI. And based on this PSI, we can provide features like name resolution, completion, inspections, etc. We discussed with @vlad20012 how to parse markdown not to implement parsing ourselves. One possible solution is to make the same approach that used in markdown plugin. There is platform (I mean IntelliJ platform) independent parser for markdown initially written for markdown plugin (we already use it for documentation rendering). And markdown plugin uses it to parse markdown file text to some tokens that are wrapped to PSI. We can do the same things only for doc comments. Of course, we need to solve problems that comment text contains prefixes like///
or//!
but looks like it’s possible.This would be a really useful feature indeed. @Undin we have the individual tokens that are part of a
PsiComment
from the doc comment lexer (RsDocElementTypes
), but I don’t know what API should be used to provide name resolution for the links. I looked atPsiReferenceContributor
, but it seems that it can only provide references for whole elements and not just their sub-parts.