Skip to content

Commit 1cbc935

Browse files
authored
Rename #[doc] attributes to #[description] for groups (#1245)
This copies the rename action for the `#[doc]` attribute from commands to groups, allowing a user to describe a group with documentation comments.
1 parent 1ab52a0 commit 1cbc935

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

command_attr/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,10 @@ pub fn group(attr: TokenStream, input: TokenStream) -> TokenStream {
628628
options.prefixes = vec![propagate_err!(attributes::parse(values))];
629629
},
630630
"description" => {
631-
let arg: String = propagate_err!(attributes::parse(values));
631+
let mut arg: String = propagate_err!(attributes::parse(values));
632+
if arg.starts_with(' ') {
633+
arg.remove(0);
634+
}
632635

633636
if let Some(desc) = &mut options.description.0 {
634637
use std::fmt::Write;

command_attr/src/structures.rs

+2
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,8 @@ impl Parse for GroupStruct {
581581
fn parse(input: ParseStream<'_>) -> Result<Self> {
582582
let mut attributes = input.call(Attribute::parse_outer)?;
583583

584+
util::rename_attributes(&mut attributes, "doc", "description");
585+
584586
let cooked = remove_cooked(&mut attributes);
585587

586588
let visibility = input.parse()?;

0 commit comments

Comments
 (0)