mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 12:11:09 +00:00
improve docs (#2068)
* improve decl_storage instance doc * use decl_event doc accordignly * automate doc and while allow to extend it on event * some missed ones * Update srml/example/src/lib.rs Co-Authored-By: thiolliere <gui.thiolliere@gmail.com> * Update srml/support/procedural/src/storage/transformation.rs
This commit is contained in:
@@ -500,6 +500,9 @@ fn decl_storage_items(
|
||||
}
|
||||
|
||||
impls.extend(quote! {
|
||||
/// Tag a type as an instance of a module.
|
||||
///
|
||||
/// Defines storage prefixes, they must be unique.
|
||||
pub trait #instantiable: 'static {
|
||||
#const_impls
|
||||
}
|
||||
@@ -510,12 +513,12 @@ fn decl_storage_items(
|
||||
.map(|i| {
|
||||
let name = format!("Instance{}", i);
|
||||
let ident = syn::Ident::new(&name, proc_macro2::Span::call_site());
|
||||
(name, ident)
|
||||
(name, ident, quote! {#[doc=r"Module instance"]})
|
||||
})
|
||||
.chain(default_instance.clone().map(|ident| (String::new(), ident)));
|
||||
.chain(default_instance.clone().map(|ident| (String::new(), ident, quote! {#[doc=r"Default module instance"]})));
|
||||
|
||||
// Impl Instance trait for instances
|
||||
for (prefix, ident) in instances {
|
||||
for (prefix, ident, doc) in instances {
|
||||
let mut const_impls = TokenStream2::new();
|
||||
|
||||
for (const_name, partial_const_value) in &const_names {
|
||||
@@ -529,6 +532,7 @@ fn decl_storage_items(
|
||||
// Those trait are derived because of wrong bounds for generics
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
#[derive(Clone, Eq, PartialEq, #scrate::codec::Encode, #scrate::codec::Decode)]
|
||||
#doc
|
||||
pub struct #ident;
|
||||
impl #instantiable for #ident {
|
||||
#const_impls
|
||||
|
||||
@@ -144,6 +144,8 @@ macro_rules! decl_event {
|
||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||
#[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
/// Events for this module.
|
||||
///
|
||||
$(#[$attr])*
|
||||
pub enum Event {
|
||||
$(
|
||||
@@ -277,9 +279,12 @@ macro_rules! __decl_generic_event {
|
||||
/// [`RawEvent`]: enum.RawEvent.html
|
||||
/// [`Trait`]: trait.Trait.html
|
||||
pub type Event<$event_generic_param $(, $instance $( = $event_default_instance)? )?> = RawEvent<$( $generic_type ),* $(, $instance)? >;
|
||||
|
||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||
#[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
/// Events for this module.
|
||||
///
|
||||
$(#[$attr])*
|
||||
pub enum RawEvent<$( $generic_param ),* $(, $instance)? > {
|
||||
$(
|
||||
|
||||
Reference in New Issue
Block a user