rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.16k stars 1.58k forks source link

Doc comment block should strip leading asterisk (*) #1759

Open kjeremy opened 5 years ago

kjeremy commented 5 years ago

In looking at struct ClientCapabilities of lsp-types defined as

/**
 * Where ClientCapabilities are currently empty:
 */
pub struct ClientCapabilities {
    // ...
}

I noticed that hover shows the comment as

  • Where ClientCapabilities are currently empty:

In looking at https://docs.rs/lsp-types/0.61.0/lsp_types/struct.ClientCapabilities.html we can see that it's rendered without the leading asterisk (or bullet in markdown).

My initial thought was that maybe we need to strip leading * off of block dock comments if present in DocCommentsOwner::doc_comment_text but that could also end up stripping markdown. Maybe it should be done in format_docs instead when we look for markdown... but by then we've lost all knowledge of the comment except for it's string contents.

lnicola commented 3 years ago

Triage: this still happens.

patowen commented 2 years ago

This was a bug in Rust nightly itself at some point as well (https://github.com/rust-lang/rust/issues/92872). Since this comment type is shorthand for the #[doc="..."] attribute, would it make sense to extract the string from that attribute instead? I assume we don't need any more information about how the comment was written for the help text on mouse hover.

Veykril commented 1 year ago

Relevant code is here https://github.com/rust-lang/rust-analyzer/blob/9814d798411a4b1b258c710f86626bd1997e406f/crates/hir-def/src/attr.rs#L208-L233 and here (though this we might be able to skip out on) https://github.com/rust-lang/rust-analyzer/blob/9814d798411a4b1b258c710f86626bd1997e406f/crates/hir-def/src/attr.rs#L449-L492