-
Notifications
You must be signed in to change notification settings - Fork 261
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
Propagate documentation to runtime API #511
Conversation
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>
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>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@@ -78,6 +78,10 @@ pub fn generate_calls( | |||
let function_name = struct_def.name.to_string().to_snake_case(); | |||
let fn_name = format_ident!("{}", function_name); | |||
|
|||
// Propagate the documentation just to `TransactionApi` methods, while |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain the why the docs for the inner call structures are "drained" and generated for the wrappers only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My initial intuition was to keep the documentation on both the calling methods and inner structures.
The user should call the exposed API and not necessarily care about the inner structures used to construct the call.
pub struct Transfer {
...
pub value: ::core::primitive::u128,
}
/// Doc goes here
pub fn transfer( ... ) {
let call = Transfer { dest, value };
::subxt::SubmittableExtrinsic::new(self.client, call)
}
Although someone could potentially submit a manually constructed extrinsic (as the pub fn transfer
implementation), I think this is quite uncommon.
Would you think having documentation on both would also satisfy those manually constructed cases? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I agree the outer docs should be sufficient then.
I think someone constructs their own extrinsics I guess they are on their own anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks clean, is there a way to test that the docs are generated with a compile-time test such as #[deny(missing_docs)]
or something?
@niklasad1 Thanks for the feedback and review :D I don't think we could do a compile-time check with simply
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 👍
This PR propagates the documentation from the metadata blob to the generated API.
The documentation is propagated to either TransactionApi or StorageApi if the inspected type is a call or storage, instead of being placed directly on the generated object.
This is done mainly to document the paths by which the user interacts with the API, as opposed to documenting the inner details of the API. For other types, the metadata documentation is set in place for the generated object.
Examples
Inherited from generated object
Placed directly on the generated object
Closes #503 .