mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 17:05:47 +00:00
Cleanup rustdoc (#1965)
* Hide `__GetByteStruct*` types in the docs * Forward documentation to `GenesisConfig` * Hide `PhantomItem` in docs for `Call` * Hide public calls in `Module` * Forward documenation for storage functions * Hide auxiliary functions in documentation
This commit is contained in:
@@ -333,7 +333,7 @@ decl_module! {
|
|||||||
///
|
///
|
||||||
/// NOTE: This call must be made by the controller, not the stash.
|
/// NOTE: This call must be made by the controller, not the stash.
|
||||||
///
|
///
|
||||||
/// See also `withdraw_unbonded`.
|
/// See also [`Call::withdraw_unbonded`].
|
||||||
fn unbond(origin, #[compact] value: BalanceOf<T>) {
|
fn unbond(origin, #[compact] value: BalanceOf<T>) {
|
||||||
let controller = ensure_signed(origin)?;
|
let controller = ensure_signed(origin)?;
|
||||||
let mut ledger = Self::ledger(&controller).ok_or("not a controller")?;
|
let mut ledger = Self::ledger(&controller).ok_or("not a controller")?;
|
||||||
@@ -363,7 +363,7 @@ decl_module! {
|
|||||||
///
|
///
|
||||||
/// NOTE: This call must be made by the controller, not the stash.
|
/// NOTE: This call must be made by the controller, not the stash.
|
||||||
///
|
///
|
||||||
/// See also `unbond`.
|
/// See also [`Call::unbond`].
|
||||||
fn withdraw_unbonded(origin) {
|
fn withdraw_unbonded(origin) {
|
||||||
let controller = ensure_signed(origin)?;
|
let controller = ensure_signed(origin)?;
|
||||||
let ledger = Self::ledger(&controller).ok_or("not a controller")?;
|
let ledger = Self::ledger(&controller).ok_or("not a controller")?;
|
||||||
|
|||||||
@@ -130,18 +130,20 @@ pub fn decl_storage_impl(input: TokenStream) -> TokenStream {
|
|||||||
}
|
}
|
||||||
impl<#traitinstance: 'static + #traittype> #module_ident<#traitinstance> {
|
impl<#traitinstance: 'static + #traittype> #module_ident<#traitinstance> {
|
||||||
#impl_store_fns
|
#impl_store_fns
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn store_metadata() -> #scrate::storage::generator::StorageMetadata {
|
pub fn store_metadata() -> #scrate::storage::generator::StorageMetadata {
|
||||||
#scrate::storage::generator::StorageMetadata {
|
#scrate::storage::generator::StorageMetadata {
|
||||||
functions: #scrate::storage::generator::DecodeDifferent::Encode(#store_functions_to_metadata) ,
|
functions: #scrate::storage::generator::DecodeDifferent::Encode(#store_functions_to_metadata) ,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn store_metadata_functions() -> &'static [#scrate::storage::generator::StorageFunctionMetadata] {
|
pub fn store_metadata_functions() -> &'static [#scrate::storage::generator::StorageFunctionMetadata] {
|
||||||
#store_functions_to_metadata
|
#store_functions_to_metadata
|
||||||
}
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn store_metadata_name() -> &'static str {
|
pub fn store_metadata_name() -> &'static str {
|
||||||
#cratename_string
|
#cratename_string
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#extra_genesis
|
#extra_genesis
|
||||||
@@ -168,6 +170,7 @@ fn decl_store_extra_genesis(
|
|||||||
for sline in storage_lines.inner.iter() {
|
for sline in storage_lines.inner.iter() {
|
||||||
|
|
||||||
let DeclStorageLine {
|
let DeclStorageLine {
|
||||||
|
attrs,
|
||||||
name,
|
name,
|
||||||
getter,
|
getter,
|
||||||
config,
|
config,
|
||||||
@@ -188,7 +191,13 @@ fn decl_store_extra_genesis(
|
|||||||
let ident = &getter.getfn.content;
|
let ident = &getter.getfn.content;
|
||||||
quote!( #ident )
|
quote!( #ident )
|
||||||
} else {
|
} else {
|
||||||
return Err(syn::Error::new_spanned(name, format!("Invalid storage definiton, couldn't find config identifier: storage must either have a get identifier `get(ident)` or a defined config identifier `config(ident)`")));
|
return Err(
|
||||||
|
Error::new_spanned(
|
||||||
|
name,
|
||||||
|
"Invalid storage definiton, couldn't find config identifier: storage must either have a get identifier \
|
||||||
|
`get(ident)` or a defined config identifier `config(ident)`"
|
||||||
|
)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
if type_infos.kind.is_simple() && ext::has_parametric_type(type_infos.value_type, traitinstance) {
|
if type_infos.kind.is_simple() && ext::has_parametric_type(type_infos.value_type, traitinstance) {
|
||||||
is_trait_needed = true;
|
is_trait_needed = true;
|
||||||
@@ -199,13 +208,17 @@ fn decl_store_extra_genesis(
|
|||||||
if let DeclStorageTypeInfosKind::Map { key_type, .. } = type_infos.kind {
|
if let DeclStorageTypeInfosKind::Map { key_type, .. } = type_infos.kind {
|
||||||
serde_complete_bound.insert(key_type);
|
serde_complete_bound.insert(key_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Propagate doc attributes.
|
||||||
|
let attrs = attrs.inner.iter().filter_map(|a| a.parse_meta().ok()).filter(|m| m.name() == "doc");
|
||||||
|
|
||||||
let storage_type = type_infos.typ.clone();
|
let storage_type = type_infos.typ.clone();
|
||||||
config_field.extend(match type_infos.kind {
|
config_field.extend(match type_infos.kind {
|
||||||
DeclStorageTypeInfosKind::Simple => {
|
DeclStorageTypeInfosKind::Simple => {
|
||||||
quote!( pub #ident: #storage_type, )
|
quote!( #( #[ #attrs ] )* pub #ident: #storage_type, )
|
||||||
},
|
},
|
||||||
DeclStorageTypeInfosKind::Map {key_type, .. } => {
|
DeclStorageTypeInfosKind::Map {key_type, .. } => {
|
||||||
quote!( pub #ident: Vec<(#key_type, #storage_type)>, )
|
quote!( #( #[ #attrs ] )* pub #ident: Vec<(#key_type, #storage_type)>, )
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
opt_build = Some(build.as_ref().map(|b| &b.expr.content).map(|b|quote!( #b ))
|
opt_build = Some(build.as_ref().map(|b| &b.expr.content).map(|b|quote!( #b ))
|
||||||
@@ -475,8 +488,12 @@ fn impl_store_items(
|
|||||||
) -> TokenStream2 {
|
) -> TokenStream2 {
|
||||||
storage_lines.inner.iter().map(|sline| &sline.name)
|
storage_lines.inner.iter().map(|sline| &sline.name)
|
||||||
.fold(TokenStream2::new(), |mut items, name| {
|
.fold(TokenStream2::new(), |mut items, name| {
|
||||||
items.extend(quote!(type #name = #name<#traitinstance>;));
|
items.extend(
|
||||||
items
|
quote!(
|
||||||
|
type #name = #name<#traitinstance>;
|
||||||
|
)
|
||||||
|
);
|
||||||
|
items
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,6 +505,7 @@ fn impl_store_fns(
|
|||||||
let mut items = TokenStream2::new();
|
let mut items = TokenStream2::new();
|
||||||
for sline in storage_lines.inner.iter() {
|
for sline in storage_lines.inner.iter() {
|
||||||
let DeclStorageLine {
|
let DeclStorageLine {
|
||||||
|
attrs,
|
||||||
name,
|
name,
|
||||||
getter,
|
getter,
|
||||||
storage_type,
|
storage_type,
|
||||||
@@ -500,10 +518,14 @@ fn impl_store_fns(
|
|||||||
let type_infos = get_type_infos(storage_type);
|
let type_infos = get_type_infos(storage_type);
|
||||||
let value_type = type_infos.value_type;
|
let value_type = type_infos.value_type;
|
||||||
|
|
||||||
|
// Propagate doc attributes.
|
||||||
|
let attrs = attrs.inner.iter().filter_map(|a| a.parse_meta().ok()).filter(|m| m.name() == "doc");
|
||||||
|
|
||||||
let typ = type_infos.typ;
|
let typ = type_infos.typ;
|
||||||
let item = match type_infos.kind {
|
let item = match type_infos.kind {
|
||||||
DeclStorageTypeInfosKind::Simple => {
|
DeclStorageTypeInfosKind::Simple => {
|
||||||
quote!{
|
quote!{
|
||||||
|
#( #[ #attrs ] )*
|
||||||
pub fn #get_fn() -> #value_type {
|
pub fn #get_fn() -> #value_type {
|
||||||
<#name<#traitinstance> as #scrate::storage::generator::StorageValue<#typ>> :: get(&#scrate::storage::RuntimeStorage)
|
<#name<#traitinstance> as #scrate::storage::generator::StorageValue<#typ>> :: get(&#scrate::storage::RuntimeStorage)
|
||||||
}
|
}
|
||||||
@@ -511,6 +533,7 @@ fn impl_store_fns(
|
|||||||
},
|
},
|
||||||
DeclStorageTypeInfosKind::Map { key_type, .. } => {
|
DeclStorageTypeInfosKind::Map { key_type, .. } => {
|
||||||
quote!{
|
quote!{
|
||||||
|
#( #[ #attrs ] )*
|
||||||
pub fn #get_fn<K: #scrate::storage::generator::Borrow<#key_type>>(key: K) -> #value_type {
|
pub fn #get_fn<K: #scrate::storage::generator::Borrow<#key_type>>(key: K) -> #value_type {
|
||||||
<#name<#traitinstance> as #scrate::storage::generator::StorageMap<#key_type, #typ>> :: get(key.borrow(), &#scrate::storage::RuntimeStorage)
|
<#name<#traitinstance> as #scrate::storage::generator::StorageMap<#key_type, #typ>> :: get(key.borrow(), &#scrate::storage::RuntimeStorage)
|
||||||
}
|
}
|
||||||
@@ -579,7 +602,7 @@ fn store_functions_to_metadata (
|
|||||||
})
|
})
|
||||||
.unwrap_or_else(|| quote!( Default::default() ));
|
.unwrap_or_else(|| quote!( Default::default() ));
|
||||||
let mut docs = TokenStream2::new();
|
let mut docs = TokenStream2::new();
|
||||||
for attr in attrs.inner.iter().filter_map(|v| v.interpret_meta()) {
|
for attr in attrs.inner.iter().filter_map(|v| v.parse_meta().ok()) {
|
||||||
if let syn::Meta::NameValue(syn::MetaNameValue{
|
if let syn::Meta::NameValue(syn::MetaNameValue{
|
||||||
ref ident,
|
ref ident,
|
||||||
ref lit,
|
ref lit,
|
||||||
@@ -608,6 +631,7 @@ fn store_functions_to_metadata (
|
|||||||
};
|
};
|
||||||
items.extend(item);
|
items.extend(item);
|
||||||
let def_get = quote! {
|
let def_get = quote! {
|
||||||
|
#[doc(hidden)]
|
||||||
pub struct #struct_name<#traitinstance>(pub #scrate::rstd::marker::PhantomData<#traitinstance>);
|
pub struct #struct_name<#traitinstance>(pub #scrate::rstd::marker::PhantomData<#traitinstance>);
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
|
|||||||
@@ -487,6 +487,7 @@ macro_rules! decl_module {
|
|||||||
$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> {
|
impl<$trait_instance: $trait_name> $module<$trait_instance> {
|
||||||
|
#[doc(hidden)]
|
||||||
$vis fn $name($( $param: $param_ty ),* ) -> $crate::dispatch::Result {
|
$vis fn $name($( $param: $param_ty ),* ) -> $crate::dispatch::Result {
|
||||||
{ $( $impl )* }
|
{ $( $impl )* }
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -503,6 +504,7 @@ macro_rules! decl_module {
|
|||||||
) -> $result:ty { $( $impl:tt )* }
|
) -> $result:ty { $( $impl:tt )* }
|
||||||
) => {
|
) => {
|
||||||
impl<$trait_instance: $trait_name> $module<$trait_instance> {
|
impl<$trait_instance: $trait_name> $module<$trait_instance> {
|
||||||
|
#[doc(hidden)]
|
||||||
$vis fn $name($( $param: $param_ty ),* ) -> $result {
|
$vis fn $name($( $param: $param_ty ),* ) -> $result {
|
||||||
$( $impl )*
|
$( $impl )*
|
||||||
}
|
}
|
||||||
@@ -518,6 +520,7 @@ macro_rules! decl_module {
|
|||||||
) { $( $impl:tt )* }
|
) { $( $impl:tt )* }
|
||||||
) => {
|
) => {
|
||||||
impl<$trait_instance: $trait_name> $module<$trait_instance> {
|
impl<$trait_instance: $trait_name> $module<$trait_instance> {
|
||||||
|
#[doc(hidden)]
|
||||||
$vis fn $name(
|
$vis fn $name(
|
||||||
$origin: $origin_ty $(, $param: $param_ty )*
|
$origin: $origin_ty $(, $param: $param_ty )*
|
||||||
) -> $crate::dispatch::Result {
|
) -> $crate::dispatch::Result {
|
||||||
@@ -608,10 +611,11 @@ macro_rules! decl_module {
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
pub enum $call_type<$trait_instance: $trait_name> {
|
pub enum $call_type<$trait_instance: $trait_name> {
|
||||||
|
#[doc(hidden)]
|
||||||
__PhantomItem(::std::marker::PhantomData<$trait_instance>),
|
__PhantomItem(::std::marker::PhantomData<$trait_instance>),
|
||||||
__OtherPhantomItem(::std::marker::PhantomData<$trait_instance>),
|
|
||||||
$(
|
$(
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
|
$(#[doc = $doc_attr])*
|
||||||
$fn_name ( $( $param ),* ),
|
$fn_name ( $( $param ),* ),
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
@@ -619,10 +623,11 @@ macro_rules! decl_module {
|
|||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
pub enum $call_type<$trait_instance: $trait_name> {
|
pub enum $call_type<$trait_instance: $trait_name> {
|
||||||
|
#[doc(hidden)]
|
||||||
__PhantomItem(::core::marker::PhantomData<$trait_instance>),
|
__PhantomItem(::core::marker::PhantomData<$trait_instance>),
|
||||||
__OtherPhantomItem(::core::marker::PhantomData<$trait_instance>),
|
|
||||||
$(
|
$(
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
|
$(#[doc = $doc_attr])*
|
||||||
$fn_name ( $( $param ),* ),
|
$fn_name ( $( $param ),* ),
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
@@ -655,7 +660,6 @@ macro_rules! decl_module {
|
|||||||
} else {
|
} else {
|
||||||
match *_other {
|
match *_other {
|
||||||
$call_type::__PhantomItem(_) => unreachable!(),
|
$call_type::__PhantomItem(_) => unreachable!(),
|
||||||
$call_type::__OtherPhantomItem(_) => unreachable!(),
|
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -698,7 +702,6 @@ macro_rules! decl_module {
|
|||||||
fn encode_to<W: $crate::dispatch::Output>(&self, _dest: &mut W) {
|
fn encode_to<W: $crate::dispatch::Output>(&self, _dest: &mut W) {
|
||||||
$crate::__impl_encode!(_dest; *self; 0; $call_type; $( fn $fn_name( $( $(#[$codec_attr on type $param])* $param_name ),* ); )*);
|
$crate::__impl_encode!(_dest; *self; 0; $call_type; $( fn $fn_name( $( $(#[$codec_attr on type $param])* $param_name ),* ); )*);
|
||||||
if let $call_type::__PhantomItem(_) = *self { unreachable!() }
|
if let $call_type::__PhantomItem(_) = *self { unreachable!() }
|
||||||
if let $call_type::__OtherPhantomItem(_) = *self { unreachable!() }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<$trait_instance: $trait_name> $crate::dispatch::Dispatchable
|
impl<$trait_instance: $trait_name> $crate::dispatch::Dispatchable
|
||||||
@@ -717,7 +720,7 @@ macro_rules! decl_module {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
)*
|
)*
|
||||||
_ => { panic!("__PhantomItem should never be used.") },
|
$call_type::__PhantomItem(_) => { panic!("__PhantomItem should never be used.") },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -728,6 +731,7 @@ macro_rules! decl_module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<$trait_instance: $trait_name> $mod_type<$trait_instance> {
|
impl<$trait_instance: $trait_name> $mod_type<$trait_instance> {
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn dispatch<D: $crate::dispatch::Dispatchable<Trait = $trait_instance>>(d: D, origin: D::Origin) -> $crate::dispatch::Result {
|
pub fn dispatch<D: $crate::dispatch::Dispatchable<Trait = $trait_instance>>(d: D, origin: D::Origin) -> $crate::dispatch::Result {
|
||||||
d.dispatch(origin)
|
d.dispatch(origin)
|
||||||
}
|
}
|
||||||
@@ -944,6 +948,7 @@ macro_rules! __dispatch_impl_metadata {
|
|||||||
$($rest:tt)*
|
$($rest:tt)*
|
||||||
) => {
|
) => {
|
||||||
impl<$trait_instance: $trait_name> $mod_type<$trait_instance> {
|
impl<$trait_instance: $trait_name> $mod_type<$trait_instance> {
|
||||||
|
#[doc(hidden)]
|
||||||
pub fn call_functions() -> &'static [$crate::dispatch::FunctionMetadata] {
|
pub fn call_functions() -> &'static [$crate::dispatch::FunctionMetadata] {
|
||||||
$crate::__call_to_functions!($($rest)*)
|
$crate::__call_to_functions!($($rest)*)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user