parse doc comment for items

This commit is contained in:
csmoe 2019-01-04 21:29:00 +08:00
parent 8a6d6ac132
commit f604ff5b2f
3 changed files with 15 additions and 2 deletions

View file

@ -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> {