frame/support: Link call documentation only in prod-modes (#14283)

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2023-06-01 19:08:25 +03:00
committed by GitHub
parent dc7161276d
commit 0910390b25
@@ -16,7 +16,10 @@
// limitations under the License.
use crate::{
pallet::{parse::call::CallWeightDef, Def},
pallet::{
parse::call::{CallVariantDef, CallWeightDef},
Def,
},
COUNTER,
};
use proc_macro2::TokenStream as TokenStream2;
@@ -113,13 +116,22 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream {
}
debug_assert_eq!(fn_weight.len(), methods.len());
let fn_doc = methods
.iter()
.map(|method| {
let map_fn_docs = if !def.dev_mode {
// Emit the [`Pallet::method`] documentation only for non-dev modes.
|method: &CallVariantDef| {
let reference = format!("See [`Pallet::{}`].", method.name);
quote!(#reference)
})
.collect::<Vec<_>>();
}
} else {
// For the dev-mode do not provide a documenation link as it will break the
// `cargo doc` if the pallet is private inside a test.
|method: &CallVariantDef| {
let reference = format!("See `Pallet::{}`.", method.name);
quote!(#reference)
}
};
let fn_doc = methods.iter().map(map_fn_docs).collect::<Vec<_>>();
let args_name = methods
.iter()