mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-23 10:48:00 +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:
@@ -40,6 +40,11 @@ pub struct Opts {
|
||||
/// Defaults to `::subxt`.
|
||||
#[clap(long = "crate")]
|
||||
crate_path: Option<String>,
|
||||
/// Do not generate documentation for the runtime API code.
|
||||
///
|
||||
/// Defaults to `false` (documentation is generated).
|
||||
#[clap(long, action)]
|
||||
no_docs: bool,
|
||||
}
|
||||
|
||||
fn derive_for_type_parser(src: &str) -> Result<(String, String), String> {
|
||||
@@ -69,7 +74,13 @@ pub async fn run(opts: Opts) -> color_eyre::Result<()> {
|
||||
subxt_codegen::utils::fetch_metadata_bytes(&url).await?
|
||||
};
|
||||
|
||||
codegen(&bytes, opts.derives, opts.derives_for_type, opts.crate_path)?;
|
||||
codegen(
|
||||
&bytes,
|
||||
opts.derives,
|
||||
opts.derives_for_type,
|
||||
opts.crate_path,
|
||||
opts.no_docs,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -78,6 +89,7 @@ fn codegen(
|
||||
raw_derives: Vec<String>,
|
||||
derives_for_type: Vec<(String, String)>,
|
||||
crate_path: Option<String>,
|
||||
no_docs: bool,
|
||||
) -> color_eyre::Result<()> {
|
||||
let item_mod = syn::parse_quote!(
|
||||
pub mod api {}
|
||||
@@ -100,12 +112,14 @@ fn codegen(
|
||||
|
||||
let type_substitutes = TypeSubstitutes::new(&crate_path);
|
||||
|
||||
let should_gen_docs = !no_docs;
|
||||
let runtime_api = subxt_codegen::generate_runtime_api_from_bytes(
|
||||
item_mod,
|
||||
metadata_bytes,
|
||||
derives,
|
||||
type_substitutes,
|
||||
crate_path,
|
||||
should_gen_docs,
|
||||
);
|
||||
println!("{runtime_api}");
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user