Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen: Opt out of documentation #843

Merged
merged 8 commits into from
Mar 2, 2023
Merged

Conversation

lexnv
Copy link
Collaborator

@lexnv lexnv commented Feb 28, 2023

This PR exposes the --no-docs flag by the CLI.

When the flag is active the generated subxt API will not include the documentation from the metadata.

While at it, have also modified the codegen tests to check that no documentation present in the metadata-v14 is extracted on the generated API.

Closes: #826.

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@@ -82,6 +82,7 @@ where
derives,
type_substitutes,
crate_path,
true,
Copy link
Collaborator

@jsdw jsdw Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon we should make sure that the #[subxt] macro doesn't generate any docs, in this case (since they are sortof unnecessary there by default). We can always expose a flag in the macro args then to add docs if IDE's can ever learn to ebnefit from it :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes total sense! I've disabled by default the documentation generation for the subxt macro and added a flag to its attributes: expose_documentation, that when present the generated code will expose the metadata documentation

lexnv added 2 commits March 1, 2023 14:36
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
macro/src/lib.rs Outdated
//! code, users must specify the `expose_documentation` flag:
//!
//! ```ignore
//! #[subxt::subxt(expose_documentation)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I feel like something like generate_docs would make more sense, since that's really what's happening here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that generate_docs is a better choice:)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tweaked this quickly via the in-browser editor :)

Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@lexnv lexnv merged commit 5320ca9 into master Mar 2, 2023
@lexnv lexnv deleted the lexnv/codegen_opt_out_docs branch March 2, 2023 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken ignored doctest in subxt macro output.
3 participants