sp-api: Put frame-metadata behind some feature (#14398)

* sp-api: Put `frame-metadata` behind some feature

Closes: https://github.com/paritytech/substrate/issues/14296

* ".git/.scripts/commands/fmt/fmt.sh"

* Review feedback

---------

Co-authored-by: command-bot <>
This commit is contained in:
Bastian Köcher
2023-07-03 11:54:28 +02:00
committed by GitHub
parent d124c90734
commit 698a6d1aa8
8 changed files with 26 additions and 9 deletions
@@ -22,7 +22,7 @@ use syn::{
ImplItem, ItemImpl, Pat, Path, PathArguments, Result, ReturnType, Signature, Type, TypePath,
};
use quote::{format_ident, quote, ToTokens};
use quote::{format_ident, quote};
use proc_macro_crate::{crate_name, FoundCrate};
@@ -259,7 +259,10 @@ pub fn versioned_trait_name(trait_ident: &Ident, version: u64) -> Ident {
}
/// Extract the documentation from the provided attributes.
#[cfg(feature = "frame-metadata")]
pub fn get_doc_literals(attrs: &[syn::Attribute]) -> Vec<syn::Lit> {
use quote::ToTokens;
attrs
.iter()
.filter_map(|attr| {
@@ -275,6 +278,7 @@ pub fn get_doc_literals(attrs: &[syn::Attribute]) -> Vec<syn::Lit> {
}
/// Filters all attributes except the cfg ones.
#[cfg(feature = "frame-metadata")]
pub fn filter_cfg_attributes(attrs: &[syn::Attribute]) -> Vec<syn::Attribute> {
attrs.iter().filter(|a| a.path().is_ident("cfg")).cloned().collect()
}