typhoon_metadata_extractor/
doc.rs1use syn::{Attribute, Expr, ExprLit, Lit};
2
3#[derive(Default, Debug)]
4pub struct Docs(Vec<String>);
5
6impl From<&[Attribute]> for Docs {
7 fn from(value: &[Attribute]) -> Self {
8 let docs = value
9 .iter()
10 .filter(|attr| attr.path().is_ident("doc"))
11 .filter_map(|attr| {
12 if let syn::Meta::NameValue(v) = &attr.meta {
13 if let Expr::Lit(ExprLit {
14 lit: Lit::Str(str_lit),
15 ..
16 }) = &v.value
17 {
18 return Some(str_lit.value().trim().to_string());
19 }
20 }
21 None
22 })
23 .collect();
24
25 Docs(docs)
26 }
27}
28
29impl Docs {
30 pub fn into_vec(self) -> Vec<String> {
31 self.0
32 }
33}