Skip to content

Commit aae9fe4

Browse files
committed
✨ interface to forward doc attributes to proxy
1 parent b50e7a4 commit aae9fe4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

zbus_macros/src/iface.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ struct MethodInfo {
169169
output: ReturnType,
170170
/// The cfg attributes of the method.
171171
cfg_attrs: Vec<Attribute>,
172+
/// The doc attributes of the method.
173+
doc_attrs: Vec<Attribute>,
172174
}
173175

174176
impl MethodInfo {
@@ -177,6 +179,7 @@ impl MethodInfo {
177179
method: &ImplItemFn,
178180
attrs: &MethodAttrs,
179181
cfg_attrs: &[&Attribute],
182+
doc_attrs: &[&Attribute],
180183
) -> syn::Result<MethodInfo> {
181184
let is_async = method.sig.asyncness.is_some();
182185
let Signature {
@@ -319,6 +322,7 @@ impl MethodInfo {
319322
proxy_attrs,
320323
output: output.clone(),
321324
cfg_attrs: cfg_attrs.iter().cloned().cloned().collect(),
325+
doc_attrs: doc_attrs.iter().cloned().cloned().collect(),
322326
})
323327
}
324328
}
@@ -420,8 +424,13 @@ pub fn expand<T: AttrParse + Into<ImplAttrs>, M: AttrParse + Into<MethodAttrs>>(
420424
.iter()
421425
.filter(|a| a.path().is_ident("cfg"))
422426
.collect();
427+
let doc_attrs: Vec<_> = method
428+
.attrs
429+
.iter()
430+
.filter(|a| a.path().is_ident("doc"))
431+
.collect();
423432

424-
let method_info = MethodInfo::new(&zbus, method, &attrs, &cfg_attrs)?;
433+
let method_info = MethodInfo::new(&zbus, method, &attrs, &cfg_attrs, &doc_attrs)?;
425434
let attr_property = match attrs {
426435
MethodAttrs::Old(o) => o.property.map(|op| PropertyAttributes {
427436
emits_changed_signal: op.emits_changed_signal,
@@ -1384,8 +1393,10 @@ impl Proxy {
13841393
}
13851394
let cfg_attrs = method_info.cfg_attrs;
13861395
let zbus = &self.zbus;
1396+
let doc_attrs = method_info.doc_attrs;
13871397
self.methods.extend(quote! {
13881398
#(#cfg_attrs)*
1399+
#(#doc_attrs)*
13891400
#[zbus(#proxy_method_attrs)]
13901401
fn #ident(&self, #inputs) -> #zbus::Result<#ret>;
13911402
});

0 commit comments

Comments
 (0)