Add custom derives for specific generated types (#520)

* WIP implement custom derives per type

* WIP wiring up specific type derives

* Fmt

* Rename GeneratedTypeDerives to Derives

* Fmt

* Fix errors

* Fix test runtime

* Make derives appear in alphabetic order

* Clippy

* Add derive_for_type attribute to example

* Add docs to example

* Rename GeneratedTypeDerive

* Rename ty to type in attribute

* Update darling

* Update codegen/src/types/derives.rs

Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com>

* Update codegen/src/types/mod.rs

Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com>

* Update codegen/src/types/mod.rs

Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com>

* review: update method name

* Add unit tests for combined derives

* Remove out of date docs

* Add macro usage docs

Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com>
This commit is contained in:
Andrew Jones
2022-04-28 14:26:34 +03:00
committed by GitHub
parent 1fd1eee72a
commit 24317b4311
13 changed files with 374 additions and 120 deletions
+3 -3
View File
@@ -43,7 +43,7 @@ use std::{
path::PathBuf,
};
use structopt::StructOpt;
use subxt_codegen::GeneratedTypeDerives;
use subxt_codegen::DerivesRegistry;
use subxt_metadata::{
get_metadata_hash,
get_pallet_hash,
@@ -288,8 +288,8 @@ fn codegen<I: Input>(
.iter()
.map(|raw| syn::parse_str(raw))
.collect::<Result<Vec<_>, _>>()?;
let mut derives = GeneratedTypeDerives::default();
derives.append(p.into_iter());
let mut derives = DerivesRegistry::default();
derives.extend_for_all(p.into_iter());
let runtime_api = generator.generate_runtime(item_mod, derives);
println!("{}", runtime_api);