blob: 5db72c08a3e7c39c90a5b133d474e722f14db483 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
use ra_syntax::ast;
use crate::HirDatabase;
/// Holds documentation
#[derive(Debug, Clone)]
pub struct Documentation(String);
impl Documentation {
pub fn new(s: &str) -> Self {
Self(s.into())
}
pub fn contents(&self) -> &str {
&self.0
}
}
impl Into<String> for Documentation {
fn into(self) -> String {
self.contents().into()
}
}
pub trait Docs {
fn docs(&self, db: &impl HirDatabase) -> Option<Documentation>;
}
pub(crate) fn docs_from_ast(node: &impl ast::DocCommentsOwner) -> Option<Documentation> {
node.doc_comment_text().map(|it| Documentation::new(&it))
}
|