parse doc comment for items
This commit is contained in:
parent
8a6d6ac132
commit
f604ff5b2f
3 changed files with 15 additions and 2 deletions
|
|
@ -394,7 +394,7 @@ impl Analysis {
|
|||
pub fn doc_text_for(&self, nav: NavigationTarget) -> Cancelable<Option<String>> {
|
||||
self.db.doc_text_for(nav)
|
||||
}
|
||||
/// Returns a `mod name;` declaration whihc created the current module.
|
||||
/// Returns a `mod name;` declaration which created the current module.
|
||||
pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<NavigationTarget>> {
|
||||
self.db.parent_module(position)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,7 +249,8 @@ fn bar() {
|
|||
fn test_fn_signature_with_docs_simple() {
|
||||
let (desc, param) = get_signature(
|
||||
r#"
|
||||
// test
|
||||
/// test
|
||||
// non-doc-comment
|
||||
fn foo(j: u32) -> u32 {
|
||||
j
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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