mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 06:11:07 +00:00
improve modules doc generation by support macros (#1975)
This commit is contained in:
@@ -487,12 +487,10 @@ macro_rules! decl_module {
|
|||||||
$(#[doc = $doc_attr:tt])*
|
$(#[doc = $doc_attr:tt])*
|
||||||
$vis:vis fn $name:ident ( root $(, $param:ident : $param_ty:ty )* ) { $( $impl: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])*
|
||||||
$(#[doc = $doc_attr])*
|
$vis fn $name($( $param: $param_ty ),* ) -> $crate::dispatch::Result {
|
||||||
$vis fn $name($( $param: $param_ty ),* ) -> $crate::dispatch::Result {
|
{ $( $impl )* }
|
||||||
{ $( $impl )* }
|
Ok(())
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -505,11 +503,9 @@ macro_rules! decl_module {
|
|||||||
root $(, $param:ident : $param_ty:ty )*
|
root $(, $param:ident : $param_ty:ty )*
|
||||||
) -> $result:ty { $( $impl:tt )* }
|
) -> $result:ty { $( $impl:tt )* }
|
||||||
) => {
|
) => {
|
||||||
impl<$trait_instance: $trait_name> $module<$trait_instance> {
|
$(#[doc = $doc_attr])*
|
||||||
$(#[doc = $doc_attr])*
|
$vis fn $name($( $param: $param_ty ),* ) -> $result {
|
||||||
$vis fn $name($( $param: $param_ty ),* ) -> $result {
|
$( $impl )*
|
||||||
$( $impl )*
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -522,14 +518,12 @@ macro_rules! decl_module {
|
|||||||
$origin:ident $(, $param:ident : $param_ty:ty )*
|
$origin:ident $(, $param:ident : $param_ty:ty )*
|
||||||
) { $( $impl:tt )* }
|
) { $( $impl:tt )* }
|
||||||
) => {
|
) => {
|
||||||
impl<$trait_instance: $trait_name> $module<$trait_instance> {
|
$(#[doc = $doc_attr])*
|
||||||
$(#[doc = $doc_attr])*
|
$vis fn $name(
|
||||||
$vis fn $name(
|
$origin: $origin_ty $(, $param: $param_ty )*
|
||||||
$origin: $origin_ty $(, $param: $param_ty )*
|
) -> $crate::dispatch::Result {
|
||||||
) -> $crate::dispatch::Result {
|
{ $( $impl )* }
|
||||||
{ $( $impl )* }
|
Ok(())
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -542,11 +536,9 @@ macro_rules! decl_module {
|
|||||||
$origin:ident $(, $param:ident : $param_ty:ty )*
|
$origin:ident $(, $param:ident : $param_ty:ty )*
|
||||||
) -> $result:ty { $( $impl:tt )* }
|
) -> $result:ty { $( $impl:tt )* }
|
||||||
) => {
|
) => {
|
||||||
impl<$trait_instance: $trait_name> $module<$trait_instance> {
|
$(#[doc = $doc_attr])*
|
||||||
$(#[doc = $doc_attr])*
|
$vis fn $name($origin: $origin_ty $(, $param: $param_ty )* ) -> $result {
|
||||||
$vis fn $name($origin: $origin_ty $(, $param: $param_ty )* ) -> $result {
|
$( $impl )*
|
||||||
$( $impl )*
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -601,18 +593,23 @@ macro_rules! decl_module {
|
|||||||
$( $deposit_event )*
|
$( $deposit_event )*
|
||||||
}
|
}
|
||||||
|
|
||||||
$(
|
/// Can also be called using [`Call`].
|
||||||
decl_module! {
|
///
|
||||||
@impl_function
|
/// [`Call`]: enum.Call.html
|
||||||
$mod_type<$trait_instance: $trait_name>;
|
impl<$trait_instance: $trait_name> $mod_type<$trait_instance> {
|
||||||
$origin_type;
|
$(
|
||||||
$from;
|
decl_module! {
|
||||||
$(#[doc = $doc_attr])*
|
@impl_function
|
||||||
$fn_vis fn $fn_name (
|
$mod_type<$trait_instance: $trait_name>;
|
||||||
$from $(, $param_name : $param )*
|
$origin_type;
|
||||||
) $( -> $result )* { $( $impl )* }
|
$from;
|
||||||
}
|
$(#[doc = $doc_attr])*
|
||||||
)*
|
$fn_vis fn $fn_name (
|
||||||
|
$from $(, $param_name : $param )*
|
||||||
|
) $( -> $result )* { $( $impl )* }
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
|
|||||||
@@ -227,6 +227,10 @@ macro_rules! __decl_generic_event {
|
|||||||
{ $( $events:tt )* };
|
{ $( $events:tt )* };
|
||||||
{ ,$( $generic_param:ident = $generic_type:ty ),* };
|
{ ,$( $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 ),*>;
|
pub type Event<$event_generic_param> = RawEvent<$( $generic_type ),*>;
|
||||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||||
#[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)]
|
#[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)]
|
||||||
|
|||||||
Reference in New Issue
Block a user