Skip to content

Commit

Permalink
fix(derive): Apply doc comments for #[command(subcommand)]
Browse files Browse the repository at this point in the history
This was broken in 8a5a9ba.  I had
missed this case for parsing doc comments.
  • Loading branch information
epage committed Oct 3, 2022
1 parent 39b1ef0 commit 7ceb08a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion clap_derive/src/item.rs
Expand Up @@ -143,7 +143,7 @@ impl Item {
let parsed_attrs = ClapAttr::parse_all(&variant.attrs);
res.infer_kind(&parsed_attrs);
res.push_attrs(&parsed_attrs);
if matches!(&*res.kind, Kind::Command(_)) {
if matches!(&*res.kind, Kind::Command(_) | Kind::Subcommand(_)) {
res.push_doc_comment(&variant.attrs, "about", true);
}

Expand All @@ -155,6 +155,9 @@ impl Item {
"methods are not allowed for flattened entry"
);
}

// ignore doc comments
res.doc_comment = vec![];
}

Kind::Subcommand(_)
Expand Down Expand Up @@ -228,6 +231,9 @@ impl Item {
"methods are not allowed for flattened entry"
);
}

// ignore doc comments
res.doc_comment = vec![];
}

Kind::Subcommand(_) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/derive/doc_comments_help.rs
Expand Up @@ -268,7 +268,7 @@ fn respect_subcommand_doc_comment() {
Usage: cmd <COMMAND>
Commands:
child
child For child
help Print this message or the help of the given subcommand(s)
Options:
Expand Down

0 comments on commit 7ceb08a

Please sign in to comment.