Skip to content

Commit 488be21

Browse files
gui1117MTDK1
authored andcommitted
improve modules doc generation by support macros (paritytech#1975)
1 parent dcfe4a0 commit 488be21

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

srml/support/src/dispatch.rs

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -487,12 +487,10 @@ macro_rules! decl_module {
487487
$(#[doc = $doc_attr:tt])*
488488
$vis:vis fn $name:ident ( root $(, $param:ident : $param_ty:ty )* ) { $( $impl:tt )* }
489489
) => {
490-
impl<$trait_instance: $trait_name> $module<$trait_instance> {
491-
$(#[doc = $doc_attr])*
492-
$vis fn $name($( $param: $param_ty ),* ) -> $crate::dispatch::Result {
493-
{ $( $impl )* }
494-
Ok(())
495-
}
490+
$(#[doc = $doc_attr])*
491+
$vis fn $name($( $param: $param_ty ),* ) -> $crate::dispatch::Result {
492+
{ $( $impl )* }
493+
Ok(())
496494
}
497495
};
498496

@@ -505,11 +503,9 @@ macro_rules! decl_module {
505503
root $(, $param:ident : $param_ty:ty )*
506504
) -> $result:ty { $( $impl:tt )* }
507505
) => {
508-
impl<$trait_instance: $trait_name> $module<$trait_instance> {
509-
$(#[doc = $doc_attr])*
510-
$vis fn $name($( $param: $param_ty ),* ) -> $result {
511-
$( $impl )*
512-
}
506+
$(#[doc = $doc_attr])*
507+
$vis fn $name($( $param: $param_ty ),* ) -> $result {
508+
$( $impl )*
513509
}
514510
};
515511

@@ -522,14 +518,12 @@ macro_rules! decl_module {
522518
$origin:ident $(, $param:ident : $param_ty:ty )*
523519
) { $( $impl:tt )* }
524520
) => {
525-
impl<$trait_instance: $trait_name> $module<$trait_instance> {
526-
$(#[doc = $doc_attr])*
527-
$vis fn $name(
528-
$origin: $origin_ty $(, $param: $param_ty )*
529-
) -> $crate::dispatch::Result {
530-
{ $( $impl )* }
531-
Ok(())
532-
}
521+
$(#[doc = $doc_attr])*
522+
$vis fn $name(
523+
$origin: $origin_ty $(, $param: $param_ty )*
524+
) -> $crate::dispatch::Result {
525+
{ $( $impl )* }
526+
Ok(())
533527
}
534528
};
535529

@@ -542,11 +536,9 @@ macro_rules! decl_module {
542536
$origin:ident $(, $param:ident : $param_ty:ty )*
543537
) -> $result:ty { $( $impl:tt )* }
544538
) => {
545-
impl<$trait_instance: $trait_name> $module<$trait_instance> {
546-
$(#[doc = $doc_attr])*
547-
$vis fn $name($origin: $origin_ty $(, $param: $param_ty )* ) -> $result {
548-
$( $impl )*
549-
}
539+
$(#[doc = $doc_attr])*
540+
$vis fn $name($origin: $origin_ty $(, $param: $param_ty )* ) -> $result {
541+
$( $impl )*
550542
}
551543
};
552544

@@ -601,18 +593,23 @@ macro_rules! decl_module {
601593
$( $deposit_event )*
602594
}
603595

604-
$(
605-
decl_module! {
606-
@impl_function
607-
$mod_type<$trait_instance: $trait_name>;
608-
$origin_type;
609-
$from;
610-
$(#[doc = $doc_attr])*
611-
$fn_vis fn $fn_name (
612-
$from $(, $param_name : $param )*
613-
) $( -> $result )* { $( $impl )* }
614-
}
615-
)*
596+
/// Can also be called using [`Call`].
597+
///
598+
/// [`Call`]: enum.Call.html
599+
impl<$trait_instance: $trait_name> $mod_type<$trait_instance> {
600+
$(
601+
decl_module! {
602+
@impl_function
603+
$mod_type<$trait_instance: $trait_name>;
604+
$origin_type;
605+
$from;
606+
$(#[doc = $doc_attr])*
607+
$fn_vis fn $fn_name (
608+
$from $(, $param_name : $param )*
609+
) $( -> $result )* { $( $impl )* }
610+
}
611+
)*
612+
}
616613

617614
#[cfg(feature = "std")]
618615
$(#[$attr])*

srml/support/src/event.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ macro_rules! __decl_generic_event {
227227
{ $( $events:tt )* };
228228
{ ,$( $generic_param:ident = $generic_type:ty ),* };
229229
) => {
230+
/// [`RawEvent`] specialized for the configuration [`Trait`]
231+
///
232+
/// [`RawEvent`]: enum.RawEvent.html
233+
/// [`Trait`]: trait.Trait.html
230234
pub type Event<$event_generic_param> = RawEvent<$( $generic_type ),*>;
231235
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
232236
#[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)]

0 commit comments

Comments
 (0)