mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 01:57:56 +00:00
handle doc on type_value (#10132)
This commit is contained in:
committed by
GitHub
parent
15406835a8
commit
2755a97fa3
@@ -38,6 +38,8 @@ pub struct TypeValueDef {
|
||||
pub where_clause: Option<syn::WhereClause>,
|
||||
/// The span of the pallet::type_value attribute.
|
||||
pub attr_span: proc_macro2::Span,
|
||||
/// Docs on the item.
|
||||
pub docs: Vec<syn::Lit>,
|
||||
}
|
||||
|
||||
impl TypeValueDef {
|
||||
@@ -53,9 +55,18 @@ impl TypeValueDef {
|
||||
return Err(syn::Error::new(item.span(), msg))
|
||||
};
|
||||
|
||||
if !item.attrs.is_empty() {
|
||||
let msg = "Invalid pallet::type_value, unexpected attribute";
|
||||
return Err(syn::Error::new(item.attrs[0].span(), msg))
|
||||
let mut docs = vec![];
|
||||
for attr in &item.attrs {
|
||||
if let Ok(syn::Meta::NameValue(meta)) = attr.parse_meta() {
|
||||
if meta.path.get_ident().map_or(false, |ident| ident == "doc") {
|
||||
docs.push(meta.lit);
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
let msg = "Invalid pallet::type_value, unexpected attribute, only doc attribute are \
|
||||
allowed";
|
||||
return Err(syn::Error::new(attr.span(), msg))
|
||||
}
|
||||
|
||||
if let Some(span) = item
|
||||
@@ -106,6 +117,7 @@ impl TypeValueDef {
|
||||
type_,
|
||||
instances,
|
||||
where_clause,
|
||||
docs,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user