diff --git a/node-template/runtime/src/template.rs b/node-template/runtime/src/template.rs index 92abe980f094c..fd122433daea3 100644 --- a/node-template/runtime/src/template.rs +++ b/node-template/runtime/src/template.rs @@ -55,7 +55,6 @@ decl_module! { } decl_event!( - /// An event in this module. pub enum Event where AccountId = ::AccountId { // Just a dummy event. // Event `Something` is declared with a parameter of the type `u32` and `AccountId` diff --git a/srml/assets/src/lib.rs b/srml/assets/src/lib.rs index 0ed4f7a309d63..9caa3dc20d542 100644 --- a/srml/assets/src/lib.rs +++ b/srml/assets/src/lib.rs @@ -82,9 +82,6 @@ decl_module! { } } -/// An event in this module. Events are simple means of reporting specific conditions and -/// circumstances that have happened that users, Dapps and/or chain explorers would find -/// interesting and otherwise difficult to detect. decl_event!( pub enum Event where ::AccountId, ::Balance { /// Some assets were issued. diff --git a/srml/council/src/motions.rs b/srml/council/src/motions.rs index 7d9783fd33bb5..3bbe463780c46 100644 --- a/srml/council/src/motions.rs +++ b/srml/council/src/motions.rs @@ -47,7 +47,6 @@ pub enum Origin { Members(u32), } -/// Event for this module. decl_event!( pub enum Event where ::Hash, ::AccountId { /// A motion (given hash) has been proposed (by given account) with a threshold (given u32). diff --git a/srml/council/src/seats.rs b/srml/council/src/seats.rs index 365214f32793f..210603b9f4a67 100644 --- a/srml/council/src/seats.rs +++ b/srml/council/src/seats.rs @@ -382,7 +382,6 @@ decl_storage! { } decl_event!( - /// An event in this module. pub enum Event where ::AccountId { /// reaped voter, reaper VoterReaped(AccountId, AccountId), diff --git a/srml/council/src/voting.rs b/srml/council/src/voting.rs index c365ea8021d7d..4c5c62dc838b5 100644 --- a/srml/council/src/voting.rs +++ b/srml/council/src/voting.rs @@ -125,7 +125,6 @@ decl_storage! { } } -/// An event in this module. decl_event!( pub enum Event where ::Hash { /// A voting tally has happened for a referendum cancellation vote. diff --git a/srml/democracy/src/lib.rs b/srml/democracy/src/lib.rs index b9538ed249cb8..118f8f189b0fe 100644 --- a/srml/democracy/src/lib.rs +++ b/srml/democracy/src/lib.rs @@ -242,7 +242,6 @@ decl_storage! { } decl_event!( - /// An event in this module. pub enum Event where Balance = BalanceOf, ::AccountId { Proposed(PropIndex, Balance), Tabled(PropIndex, Balance, Vec), diff --git a/srml/example/src/lib.rs b/srml/example/src/lib.rs index 81a4a7a4ef7bb..9182278b1f76b 100644 --- a/srml/example/src/lib.rs +++ b/srml/example/src/lib.rs @@ -72,10 +72,10 @@ decl_storage! { } } -/// An event in this module. Events are simple means of reporting specific conditions and -/// circumstances that have happened that users, Dapps and/or chain explorers would find -/// interesting and otherwise difficult to detect. decl_event!( + /// Events are a simple means of reporting specific conditions and + /// circumstances that have happened that users, Dapps and/or chain explorers would find + /// interesting and otherwise difficult to detect. pub enum Event where B = ::Balance { // Just a normal `enum`, here's a dummy event to ensure it compiles. /// Dummy event, just here so there's a generic type that's used. diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 0715ce034ad7b..3c85756e96ba6 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -176,7 +176,6 @@ impl Decode for StoredPendingChange where ::SessionKey { /// New authority set has been applied. diff --git a/srml/session/src/lib.rs b/srml/session/src/lib.rs index 956c8e03fed4a..29f50daca9f30 100644 --- a/srml/session/src/lib.rs +++ b/srml/session/src/lib.rs @@ -84,7 +84,6 @@ decl_module! { } } -/// An event in this module. decl_event!( pub enum Event where ::BlockNumber { /// New session has happened. Note that the argument is the session index, not the block diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 68e26a8e63da2..a5650cb791656 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -719,7 +719,6 @@ decl_module! { } } -// An event in this module. decl_event!( pub enum Event where Balance = BalanceOf, ::AccountId { /// All validators have been rewarded by the given balance. diff --git a/srml/sudo/src/lib.rs b/srml/sudo/src/lib.rs index e4dfa480e9e3e..b0650cf373ef7 100644 --- a/srml/sudo/src/lib.rs +++ b/srml/sudo/src/lib.rs @@ -58,7 +58,6 @@ decl_module! { } } -/// An event in this module. decl_event!( pub enum Event where AccountId = ::AccountId { /// A sudo just took place. diff --git a/srml/support/procedural/src/storage/transformation.rs b/srml/support/procedural/src/storage/transformation.rs index 1ab10c4e3fae8..817e42f508855 100644 --- a/srml/support/procedural/src/storage/transformation.rs +++ b/srml/support/procedural/src/storage/transformation.rs @@ -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 diff --git a/srml/support/src/event.rs b/srml/support/src/event.rs index 4ffa552168d30..f83e551183a3c 100644 --- a/srml/support/src/event.rs +++ b/srml/support/src/event.rs @@ -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)? > { $( diff --git a/srml/system/src/lib.rs b/srml/system/src/lib.rs index c1a5ff9d9a47a..05bccffc69c72 100644 --- a/srml/system/src/lib.rs +++ b/srml/system/src/lib.rs @@ -124,7 +124,6 @@ pub struct EventRecord { pub event: E, } -/// Event for the system module. decl_event!( pub enum Event { /// An extrinsic completed successfully. diff --git a/srml/treasury/src/lib.rs b/srml/treasury/src/lib.rs index 673f989a78137..f5c453849752c 100644 --- a/srml/treasury/src/lib.rs +++ b/srml/treasury/src/lib.rs @@ -31,11 +31,6 @@ type BalanceOf = <::Currency as Currency<::Ac type PositiveImbalanceOf = <::Currency as Currency<::AccountId>>::PositiveImbalance; type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; -/// Our module's configuration trait. All our types and consts go in here. If the -/// module is dependent on specific other modules, then their configuration traits -/// should be added to our implied traits list. -/// -/// `system::Trait` should always be included in our implied traits. pub trait Trait: system::Trait { /// The staking balance. type Currency: Currency; @@ -58,10 +53,7 @@ pub trait Trait: system::Trait { type ProposalIndex = u32; -// The module declaration. This states the entry points that we handle. The -// macro takes care of the marshalling of arguments and dispatch. decl_module! { - // Simple declaration of the `Module` type. Lets the macro know what its working on. pub struct Module for enum Call where origin: T::Origin { fn deposit_event() = default; /// Put forward a suggestion for spending. A deposit proportional to the value @@ -177,7 +169,6 @@ decl_storage! { } } -/// An event in this module. decl_event!( pub enum Event where