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
32
33
34
35
use super::SpanExt;
use proc_macro2::{Literal, Punct, Spacing, Span, TokenTree};
use syn::punctuated::Pair;
use syn::*;
pub fn comment<S>(s: S) -> Attribute
where
S: AsRef<str>,
{
let span = Span::call_site();
Attribute {
style: AttrStyle::Outer,
bracket_token: span.as_token(),
pound_token: span.as_token(),
path: Path {
leading_colon: None,
segments: vec![Pair::End(PathSegment {
ident: Ident::new("doc", span),
arguments: Default::default(),
})]
.into_iter()
.collect(),
},
tokens: vec![
TokenTree::Punct(Punct::new('=', Spacing::Alone)),
TokenTree::Literal(Literal::string(s.as_ref())),
]
.into_iter()
.collect(),
}
}