fix(derive): Remove helper for removed help_heading

This commit is contained in:
Ed Page 2022-09-02 09:58:08 -05:00
parent 5e69f92efc
commit 6d44106e76
2 changed files with 3 additions and 15 deletions

View file

@ -63,7 +63,6 @@ impl Parse for ClapAttr {
"skip" => Some(MagicAttrName::Skip), "skip" => Some(MagicAttrName::Skip),
"next_display_order" => Some(MagicAttrName::NextDisplayOrder), "next_display_order" => Some(MagicAttrName::NextDisplayOrder),
"next_help_heading" => Some(MagicAttrName::NextHelpHeading), "next_help_heading" => Some(MagicAttrName::NextHelpHeading),
"help_heading" => Some(MagicAttrName::HelpHeading),
"default_value_t" => Some(MagicAttrName::DefaultValueT), "default_value_t" => Some(MagicAttrName::DefaultValueT),
"default_values_t" => Some(MagicAttrName::DefaultValuesT), "default_values_t" => Some(MagicAttrName::DefaultValuesT),
"default_value_os_t" => Some(MagicAttrName::DefaultValueOsT), "default_value_os_t" => Some(MagicAttrName::DefaultValueOsT),
@ -145,7 +144,6 @@ pub enum MagicAttrName {
DefaultValuesOsT, DefaultValuesOsT,
NextDisplayOrder, NextDisplayOrder,
NextHelpHeading, NextHelpHeading,
HelpHeading,
} }
#[derive(Clone)] #[derive(Clone)]

View file

@ -46,7 +46,6 @@ pub struct Item {
verbatim_doc_comment: bool, verbatim_doc_comment: bool,
next_display_order: Option<Method>, next_display_order: Option<Method>,
next_help_heading: Option<Method>, next_help_heading: Option<Method>,
help_heading: Option<Method>,
is_enum: bool, is_enum: bool,
is_positional: bool, is_positional: bool,
kind: Sp<Kind>, kind: Sp<Kind>,
@ -415,7 +414,6 @@ impl Item {
verbatim_doc_comment: false, verbatim_doc_comment: false,
next_display_order: None, next_display_order: None,
next_help_heading: None, next_help_heading: None,
help_heading: None,
is_enum: false, is_enum: false,
is_positional: true, is_positional: true,
kind: Sp::new(Kind::Arg(Sp::new(Ty::Other, default_span)), default_span), kind: Sp::new(Kind::Arg(Sp::new(Ty::Other, default_span)), default_span),
@ -756,10 +754,6 @@ impl Item {
self.next_display_order = Some(Method::new(attr.name.clone(), quote!(#expr))); self.next_display_order = Some(Method::new(attr.name.clone(), quote!(#expr)));
} }
Some(MagicAttrName::HelpHeading) => {
let expr = attr.value_or_abort();
self.help_heading = Some(Method::new(attr.name.clone(), quote!(#expr)));
}
Some(MagicAttrName::NextHelpHeading) => { Some(MagicAttrName::NextHelpHeading) => {
let expr = attr.value_or_abort(); let expr = attr.value_or_abort();
self.next_help_heading = Some(Method::new(attr.name.clone(), quote!(#expr))); self.next_help_heading = Some(Method::new(attr.name.clone(), quote!(#expr)));
@ -851,11 +845,9 @@ impl Item {
pub fn initial_top_level_methods(&self) -> TokenStream { pub fn initial_top_level_methods(&self) -> TokenStream {
let next_display_order = self.next_display_order.as_ref().into_iter(); let next_display_order = self.next_display_order.as_ref().into_iter();
let next_help_heading = self.next_help_heading.as_ref().into_iter(); let next_help_heading = self.next_help_heading.as_ref().into_iter();
let help_heading = self.help_heading.as_ref().into_iter();
quote!( quote!(
#(#next_display_order)* #(#next_display_order)*
#(#next_help_heading)* #(#next_help_heading)*
#(#help_heading)*
) )
} }
@ -869,18 +861,17 @@ impl Item {
/// generate methods on top of a field /// generate methods on top of a field
pub fn field_methods(&self, supports_long_help: bool) -> proc_macro2::TokenStream { pub fn field_methods(&self, supports_long_help: bool) -> proc_macro2::TokenStream {
let methods = &self.methods; let methods = &self.methods;
let help_heading = self.help_heading.as_ref().into_iter();
match supports_long_help { match supports_long_help {
true => { true => {
let doc_comment = &self.doc_comment; let doc_comment = &self.doc_comment;
quote!( #(#doc_comment)* #(#help_heading)* #(#methods)* ) quote!( #(#doc_comment)* #(#methods)* )
} }
false => { false => {
let doc_comment = self let doc_comment = self
.doc_comment .doc_comment
.iter() .iter()
.filter(|mth| mth.name != "long_help"); .filter(|mth| mth.name != "long_help");
quote!( #(#doc_comment)* #(#help_heading)* #(#methods)* ) quote!( #(#doc_comment)* #(#methods)* )
} }
} }
} }
@ -892,8 +883,7 @@ impl Item {
pub fn next_help_heading(&self) -> TokenStream { pub fn next_help_heading(&self) -> TokenStream {
let next_help_heading = self.next_help_heading.as_ref().into_iter(); let next_help_heading = self.next_help_heading.as_ref().into_iter();
let help_heading = self.help_heading.as_ref().into_iter(); quote!( #(#next_help_heading)* )
quote!( #(#next_help_heading)* #(#help_heading)* )
} }
pub fn id(&self) -> TokenStream { pub fn id(&self) -> TokenStream {