mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
parse doc comment for items
This commit is contained in:
parent
8a6d6ac132
commit
f604ff5b2f
3 changed files with 15 additions and 2 deletions
|
@ -115,6 +115,7 @@ pub trait DocCommentsOwner<'a>: AstNode<'a> {
|
|||
/// That is, strips leading `///` and joins lines
|
||||
fn doc_comment_text(self) -> RustString {
|
||||
self.doc_comments()
|
||||
.filter(|comment| comment.is_doc_comment())
|
||||
.map(|comment| {
|
||||
let prefix = comment.prefix();
|
||||
let trimmed = comment
|
||||
|
@ -206,6 +207,10 @@ impl<'a> Comment<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_doc_comment(&self) -> bool {
|
||||
self.flavor().is_doc_comment()
|
||||
}
|
||||
|
||||
pub fn prefix(&self) -> &'static str {
|
||||
self.flavor().prefix()
|
||||
}
|
||||
|
@ -237,6 +242,13 @@ impl CommentFlavor {
|
|||
Multiline => "/*",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_doc_comment(&self) -> bool {
|
||||
match self {
|
||||
CommentFlavor::Doc | CommentFlavor::ModuleDoc => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Whitespace<'a> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue