parse doc comment for items
This commit is contained in:
parent
8a6d6ac132
commit
f604ff5b2f
@ -394,7 +394,7 @@ pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, T
|
||||
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 @@ fn doc_comments(self) -> AstChildren<'a, Comment<'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 @@ pub fn flavor(&self) -> CommentFlavor {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ pub fn prefix(&self) -> &'static str {
|
||||
Multiline => "/*",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_doc_comment(&self) -> bool {
|
||||
match self {
|
||||
CommentFlavor::Doc | CommentFlavor::ModuleDoc => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Whitespace<'a> {
|
||||
|
Loading…
Reference in New Issue
Block a user