Skip to content

Commit

Permalink
Followup test for checking propagated documentation (#514)
Browse files Browse the repository at this point in the history
* codegen: Composite fields docs

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen: Propagate docs for Event type

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen: Propagate docs for calls module

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* subxt: Update polkadot.rs

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen: Propagate documentation for `TypeDefGenKind::Enum` kind

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* subxt: Update polkadot.rs

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen/tests: Recursively obtain raw metadata documentation

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen/tests: Generate runtime interface from node metadata

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen/tests: Obtain documentation from generated runtime API

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen/tests: Match raw documentation with the generated one

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Revert not longer needed "codegen: Composite fields docs"

This reverts commit 5460bbafc6262ac4f53e11d4ef11e44e1ce8296f.

* codegen/tests: Improve test regex documentation

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* subxt: Add integration-tests feature flag

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* subxt: Guard integration tests under feature flag

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* test-runtime: Place build.rs under feature flag

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* subxt: Pass `integration-tests` feature to `test-runtime`

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* CI: Use `integration-tests` feature to run all tests

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* subxt: Rely on `#[cfg(feature = "integration-tests")]` for integration

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* subxt/metadata: Manually construct test metadata

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* artifacts: Move scale binary blob to dedicated folder

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* examples: Update path to metadata blob

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* metadata: Rely on artifact metadata blob for benches

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* metadata: Remove `test-runtime` dependency

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* examples: Modify runtime path for `custom_type_derives`

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* subxt: Remove tests folder

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* test-runtime: Remove `integration-tests` feature flag

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* integration-tests: Add an integration test crate for subxt

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* subxt: Remove `test-runtime` dependency

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* subxt: Add comment for feature flags

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* integration-tests: Trim dependencies

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* integration-tests: Move dependencies under dev

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Revert "CI: Use `integration-tests` feature to run all tests"

This reverts commit 8e5f38b.

* codegen: Move documentation test to integration crate

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen_documentation: Add license + fmt

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Update `polkadot.rs`

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Move test under `testing` folder

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Update testing/integration-tests/src/codegen/codegen_documentation.rs

Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com>

Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com>
  • Loading branch information
lexnv and TarikGul authored Jun 17, 2022
1 parent cb18ad7 commit 0d67b80
Show file tree
Hide file tree
Showing 10 changed files with 565 additions and 688 deletions.
4 changes: 4 additions & 0 deletions codegen/src/api/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ pub fn generate_calls(
})
.unzip();

let call_ty = type_gen.resolve_type(call.ty.id());
let docs = call_ty.docs();

quote! {
#( #[doc = #docs ] )*
pub mod calls {
use super::root_mod;
use super::#types_mod_ident;
Expand Down
3 changes: 3 additions & 0 deletions codegen/src/api/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ pub fn generate_events(
}
});
let event_type = type_gen.resolve_type_path(event.ty.id(), &[]);
let event_ty = type_gen.resolve_type(event.ty.id());
let docs = event_ty.docs();

quote! {
#( #[doc = #docs ] )*
pub type Event = #event_type;
pub mod events {
use super::#types_mod_ident;
Expand Down
8 changes: 8 additions & 0 deletions codegen/src/types/type_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ pub struct TypeDefGen {
derives: Derives,
/// The kind of type to be generated.
ty_kind: TypeDefGenKind,
/// Type documentation.
ty_docs: TokenStream,
}

impl TypeDefGen {
Expand Down Expand Up @@ -119,10 +121,14 @@ impl TypeDefGen {
_ => TypeDefGenKind::BuiltIn,
};

let docs = ty.docs();
let ty_docs = quote! { #( #[doc = #docs ] )* };

Self {
type_params,
derives,
ty_kind,
ty_docs,
}
}
}
Expand Down Expand Up @@ -152,8 +158,10 @@ impl quote::ToTokens for TypeDefGen {
let enum_ident = format_ident!("{}", type_name);
let type_params = &self.type_params;
let derives = &self.derives;
let docs = &self.ty_docs;
let ty_toks = quote! {
#derives
#docs
pub enum #enum_ident #type_params {
#( #variants, )*
}
Expand Down
33 changes: 0 additions & 33 deletions integration-tests/Cargo.toml

This file was deleted.

38 changes: 0 additions & 38 deletions integration-tests/src/lib.rs

This file was deleted.

Loading

0 comments on commit 0d67b80

Please sign in to comment.