mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-22 11:27:58 +00:00
codegen: Opt out of documentation (#843)
* codegen: Opt-out for API documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Add `--no-docs` flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Check no documentation was generated Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update cargo.lock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Adjust testing for the new codegen API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * macro: Ensure `subxt` macro does not contain documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * macro: Expose documentation flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * expose_documentation => generate_docs --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: James Wilson <james@jsdw.me>
This commit is contained in:
@@ -48,6 +48,7 @@ pub fn generate_constants(
|
||||
pallet: &PalletMetadata<PortableForm>,
|
||||
types_mod_ident: &syn::Ident,
|
||||
crate_path: &CratePath,
|
||||
should_gen_docs: bool,
|
||||
) -> TokenStream2 {
|
||||
// Early return if the pallet has no constants.
|
||||
if pallet.constants.is_empty() {
|
||||
@@ -64,9 +65,12 @@ pub fn generate_constants(
|
||||
|
||||
let return_ty = type_gen.resolve_type_path(constant.ty.id());
|
||||
let docs = &constant.docs;
|
||||
let docs = should_gen_docs
|
||||
.then_some(quote! { #( #[doc = #docs ] )* })
|
||||
.unwrap_or_default();
|
||||
|
||||
quote! {
|
||||
#( #[doc = #docs ] )*
|
||||
#docs
|
||||
pub fn #fn_name(&self) -> #crate_path::constants::StaticConstantAddress<#crate_path::metadata::DecodeStaticType<#return_ty>> {
|
||||
#crate_path::constants::StaticConstantAddress::new(
|
||||
#pallet_name,
|
||||
|
||||
Reference in New Issue
Block a user