diff --git a/clap_derive/src/item.rs b/clap_derive/src/item.rs index 8b60b1f8428..68af9d62836 100644 --- a/clap_derive/src/item.rs +++ b/clap_derive/src/item.rs @@ -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); } @@ -155,6 +155,9 @@ impl Item { "methods are not allowed for flattened entry" ); } + + // ignore doc comments + res.doc_comment = vec![]; } Kind::Subcommand(_) @@ -228,6 +231,9 @@ impl Item { "methods are not allowed for flattened entry" ); } + + // ignore doc comments + res.doc_comment = vec![]; } Kind::Subcommand(_) => { diff --git a/tests/derive/doc_comments_help.rs b/tests/derive/doc_comments_help.rs index f655859e31e..d6d3db3d0a9 100644 --- a/tests/derive/doc_comments_help.rs +++ b/tests/derive/doc_comments_help.rs @@ -268,7 +268,7 @@ fn respect_subcommand_doc_comment() { Usage: cmd Commands: - child + child For child help Print this message or the help of the given subcommand(s) Options: