Hide doc comments from inner function include doc comments on outer function
This commit is contained in:
parent
d1dd66cfca
commit
056eac998a
@ -1,6 +1,7 @@
|
|||||||
use darling::FromMeta;
|
use darling::FromMeta;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
|
use syn::{parse_quote, ItemFn};
|
||||||
|
|
||||||
use crate::util::ctxt::Ctxt;
|
use crate::util::ctxt::Ctxt;
|
||||||
|
|
||||||
@ -57,13 +58,7 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
|
|||||||
task_inner.vis = syn::Visibility::Inherited;
|
task_inner.vis = syn::Visibility::Inherited;
|
||||||
task_inner.sig.ident = task_inner_ident.clone();
|
task_inner.sig.ident = task_inner_ident.clone();
|
||||||
|
|
||||||
let result = quote! {
|
let mut task_outer: ItemFn = parse_quote! {
|
||||||
// This is the user's task function, renamed.
|
|
||||||
// We put it outside the #task_ident fn below, because otherwise
|
|
||||||
// the items defined there (such as POOL) would be in scope
|
|
||||||
// in the user's code.
|
|
||||||
#task_inner
|
|
||||||
|
|
||||||
#visibility fn #task_ident(#fargs) -> ::embassy_executor::SpawnToken<impl Sized> {
|
#visibility fn #task_ident(#fargs) -> ::embassy_executor::SpawnToken<impl Sized> {
|
||||||
type Fut = impl ::core::future::Future + 'static;
|
type Fut = impl ::core::future::Future + 'static;
|
||||||
static POOL: ::embassy_executor::raw::TaskPool<Fut, #pool_size> = ::embassy_executor::raw::TaskPool::new();
|
static POOL: ::embassy_executor::raw::TaskPool<Fut, #pool_size> = ::embassy_executor::raw::TaskPool::new();
|
||||||
@ -71,5 +66,18 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
task_outer.attrs.append(&mut task_inner.attrs.clone());
|
||||||
|
|
||||||
|
let result = quote! {
|
||||||
|
// This is the user's task function, renamed.
|
||||||
|
// We put it outside the #task_ident fn below, because otherwise
|
||||||
|
// the items defined there (such as POOL) would be in scope
|
||||||
|
// in the user's code.
|
||||||
|
#[doc(hidden)]
|
||||||
|
#task_inner
|
||||||
|
|
||||||
|
#task_outer
|
||||||
|
};
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user