improve modules doc generation by support macros (#1975)

This commit is contained in:
thiolliere
2019-03-14 16:35:52 +01:00
committed by GitHub
parent e89d6e66fc
commit b92b2cc29b
2 changed files with 37 additions and 36 deletions
+33 -36
View File
@@ -487,12 +487,10 @@ macro_rules! decl_module {
$(#[doc = $doc_attr:tt])*
$vis:vis fn $name:ident ( root $(, $param:ident : $param_ty:ty )* ) { $( $impl:tt )* }
) => {
impl<$trait_instance: $trait_name> $module<$trait_instance> {
$(#[doc = $doc_attr])*
$vis fn $name($( $param: $param_ty ),* ) -> $crate::dispatch::Result {
{ $( $impl )* }
Ok(())
}
$(#[doc = $doc_attr])*
$vis fn $name($( $param: $param_ty ),* ) -> $crate::dispatch::Result {
{ $( $impl )* }
Ok(())
}
};
@@ -505,11 +503,9 @@ macro_rules! decl_module {
root $(, $param:ident : $param_ty:ty )*
) -> $result:ty { $( $impl:tt )* }
) => {
impl<$trait_instance: $trait_name> $module<$trait_instance> {
$(#[doc = $doc_attr])*
$vis fn $name($( $param: $param_ty ),* ) -> $result {
$( $impl )*
}
$(#[doc = $doc_attr])*
$vis fn $name($( $param: $param_ty ),* ) -> $result {
$( $impl )*
}
};
@@ -522,14 +518,12 @@ macro_rules! decl_module {
$origin:ident $(, $param:ident : $param_ty:ty )*
) { $( $impl:tt )* }
) => {
impl<$trait_instance: $trait_name> $module<$trait_instance> {
$(#[doc = $doc_attr])*
$vis fn $name(
$origin: $origin_ty $(, $param: $param_ty )*
) -> $crate::dispatch::Result {
{ $( $impl )* }
Ok(())
}
$(#[doc = $doc_attr])*
$vis fn $name(
$origin: $origin_ty $(, $param: $param_ty )*
) -> $crate::dispatch::Result {
{ $( $impl )* }
Ok(())
}
};
@@ -542,11 +536,9 @@ macro_rules! decl_module {
$origin:ident $(, $param:ident : $param_ty:ty )*
) -> $result:ty { $( $impl:tt )* }
) => {
impl<$trait_instance: $trait_name> $module<$trait_instance> {
$(#[doc = $doc_attr])*
$vis fn $name($origin: $origin_ty $(, $param: $param_ty )* ) -> $result {
$( $impl )*
}
$(#[doc = $doc_attr])*
$vis fn $name($origin: $origin_ty $(, $param: $param_ty )* ) -> $result {
$( $impl )*
}
};
@@ -601,18 +593,23 @@ macro_rules! decl_module {
$( $deposit_event )*
}
$(
decl_module! {
@impl_function
$mod_type<$trait_instance: $trait_name>;
$origin_type;
$from;
$(#[doc = $doc_attr])*
$fn_vis fn $fn_name (
$from $(, $param_name : $param )*
) $( -> $result )* { $( $impl )* }
}
)*
/// Can also be called using [`Call`].
///
/// [`Call`]: enum.Call.html
impl<$trait_instance: $trait_name> $mod_type<$trait_instance> {
$(
decl_module! {
@impl_function
$mod_type<$trait_instance: $trait_name>;
$origin_type;
$from;
$(#[doc = $doc_attr])*
$fn_vis fn $fn_name (
$from $(, $param_name : $param )*
) $( -> $result )* { $( $impl )* }
}
)*
}
#[cfg(feature = "std")]
$(#[$attr])*
+4
View File
@@ -227,6 +227,10 @@ macro_rules! __decl_generic_event {
{ $( $events:tt )* };
{ ,$( $generic_param:ident = $generic_type:ty ),* };
) => {
/// [`RawEvent`] specialized for the configuration [`Trait`]
///
/// [`RawEvent`]: enum.RawEvent.html
/// [`Trait`]: trait.Trait.html
pub type Event<$event_generic_param> = RawEvent<$( $generic_type ),*>;
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
#[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)]