mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-25 21:07:56 +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:
@@ -79,9 +79,22 @@
|
||||
//!
|
||||
//! ```ignore
|
||||
//! #[subxt::subxt(crate = "crate::path::to::subxt")]
|
||||
//! pub mod polkadot {}
|
||||
//! ```
|
||||
//!
|
||||
//! By default the path `::subxt` is used.
|
||||
//!
|
||||
//! ### Expose documentation
|
||||
//!
|
||||
//! In order to expose the documentation from the runtime metadata on the generated
|
||||
//! code, users must specify the `generate_docs` flag:
|
||||
//!
|
||||
//! ```ignore
|
||||
//! #[subxt::subxt(generate_docs)]
|
||||
//! pub mod polkadot {}
|
||||
//! ```
|
||||
//!
|
||||
//! By default the documentation is not generated.
|
||||
|
||||
#![deny(unused_crate_dependencies)]
|
||||
|
||||
@@ -121,6 +134,8 @@ struct RuntimeMetadataArgs {
|
||||
substitute_type: Vec<SubstituteType>,
|
||||
#[darling(default, rename = "crate")]
|
||||
crate_path: Option<String>,
|
||||
#[darling(default)]
|
||||
generate_docs: darling::util::Flag,
|
||||
}
|
||||
|
||||
#[derive(Debug, FromMeta)]
|
||||
@@ -177,6 +192,7 @@ pub fn subxt(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
},
|
||||
));
|
||||
|
||||
let should_gen_docs = args.generate_docs.is_present();
|
||||
match (args.runtime_metadata_path, args.runtime_metadata_url) {
|
||||
(Some(rest_of_path), None) => {
|
||||
let root = std::env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".into());
|
||||
@@ -188,6 +204,7 @@ pub fn subxt(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
derives_registry,
|
||||
type_substitutes,
|
||||
crate_path,
|
||||
should_gen_docs,
|
||||
)
|
||||
.into()
|
||||
}
|
||||
@@ -201,6 +218,7 @@ pub fn subxt(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
derives_registry,
|
||||
type_substitutes,
|
||||
crate_path,
|
||||
should_gen_docs,
|
||||
)
|
||||
.into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user