File tree 2 files changed +36
-2
lines changed
2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ impl Item {
143
143
let parsed_attrs = ClapAttr :: parse_all ( & variant. attrs ) ;
144
144
res. infer_kind ( & parsed_attrs) ;
145
145
res. push_attrs ( & parsed_attrs) ;
146
- if matches ! ( & * res. kind, Kind :: Command ( _) ) {
146
+ if matches ! ( & * res. kind, Kind :: Command ( _) | Kind :: Subcommand ( _ ) ) {
147
147
res. push_doc_comment ( & variant. attrs , "about" , true ) ;
148
148
}
149
149
@@ -155,6 +155,9 @@ impl Item {
155
155
"methods are not allowed for flattened entry"
156
156
) ;
157
157
}
158
+
159
+ // ignore doc comments
160
+ res. doc_comment = vec ! [ ] ;
158
161
}
159
162
160
163
Kind :: Subcommand ( _)
@@ -228,6 +231,9 @@ impl Item {
228
231
"methods are not allowed for flattened entry"
229
232
) ;
230
233
}
234
+
235
+ // ignore doc comments
236
+ res. doc_comment = vec ! [ ] ;
231
237
}
232
238
233
239
Kind :: Subcommand ( _) => {
Original file line number Diff line number Diff line change 14
14
15
15
use crate :: utils;
16
16
17
- use clap:: { CommandFactory , Parser , ValueEnum } ;
17
+ use clap:: { CommandFactory , Parser , Subcommand , ValueEnum } ;
18
18
19
19
#[ test]
20
20
fn doc_comments ( ) {
@@ -248,3 +248,31 @@ fn doc_comment_about_handles_both_abouts() {
248
248
// comment.
249
249
assert_eq ! ( cmd. get_long_about( ) , None ) ;
250
250
}
251
+
252
+ #[ test]
253
+ fn respect_subcommand_doc_comment ( ) {
254
+ #[ derive( Parser , Debug ) ]
255
+ pub enum Cmd {
256
+ /// For child
257
+ #[ command( subcommand) ]
258
+ Child ( Child ) ,
259
+ }
260
+
261
+ #[ derive( Subcommand , Debug ) ]
262
+ pub enum Child {
263
+ One ,
264
+ Twp ,
265
+ }
266
+
267
+ const OUTPUT : & str = "\
268
+ Usage: cmd <COMMAND>
269
+
270
+ Commands:
271
+ child For child
272
+ help Print this message or the help of the given subcommand(s)
273
+
274
+ Options:
275
+ -h, --help Print help information
276
+ " ;
277
+ utils:: assert_output :: < Cmd > ( "cmd --help" , OUTPUT , false ) ;
278
+ }
You can’t perform that action at this time.
0 commit comments