File tree Expand file tree Collapse file tree 2 files changed +56
-7
lines changed Expand file tree Collapse file tree 2 files changed +56
-7
lines changed Original file line number Diff line number Diff line change @@ -901,13 +901,26 @@ impl Item {
901901 let ( short_help, long_help) =
902902 format_doc_comment ( & lines, !self . verbatim_doc_comment , self . force_long_help ) ;
903903 let short_name = format_ident ! ( "{short_name}" ) ;
904- let short = Method :: new (
905- short_name,
906- short_help
907- . map ( |h| quote ! ( #h) )
908- . unwrap_or_else ( || quote ! ( None ) ) ,
909- ) ;
910- self . doc_comment . push ( short) ;
904+
905+ let is_value_kind = matches ! ( self . kind. get( ) , Kind :: Value ) ;
906+ let short_method = if is_value_kind && cfg ! ( feature = "unstable-v5" ) {
907+ Method :: new (
908+ short_name,
909+ long_help
910+ . clone ( )
911+ . or ( short_help)
912+ . map ( |h| quote ! ( #h) )
913+ . unwrap_or_else ( || quote ! ( None ) ) ,
914+ )
915+ } else {
916+ Method :: new (
917+ short_name,
918+ short_help
919+ . map ( |h| quote ! ( #h) )
920+ . unwrap_or_else ( || quote ! ( None ) ) ,
921+ )
922+ } ;
923+ self . doc_comment . push ( short_method) ;
911924 if let Some ( long_name) = long_name {
912925 let long_name = format_ident ! ( "{long_name}" ) ;
913926 let long = Method :: new (
Original file line number Diff line number Diff line change @@ -327,6 +327,42 @@ Options:
327327"# ] ] . raw( ) ) ;
328328}
329329
330+ #[ cfg( feature = "unstable-v5" ) ]
331+ #[ test]
332+ fn value_enum_multiline_doc_comment ( ) {
333+ #[ derive( Parser , Debug ) ]
334+ struct Command {
335+ x : LoremIpsum ,
336+ }
337+
338+ #[ derive( ValueEnum , Clone , PartialEq , Debug ) ]
339+ enum LoremIpsum {
340+ /// Doc comment summary
341+ ///
342+ /// The doc comment body is not ignored
343+ Bar ,
344+ }
345+
346+ let help = utils:: get_long_help :: < Command > ( ) ;
347+
348+ assert_data_eq ! ( help, str ![ [ r#"
349+ Usage: clap <X>
350+
351+ Arguments:
352+ <X>
353+ Possible values:
354+ - bar: Doc comment summary
355+
356+ The doc comment body is not ignored
357+
358+ Options:
359+ -h, --help
360+ Print help (see a summary with '-h')
361+
362+ "# ] ] . raw( ) ) ;
363+ }
364+
365+ #[ cfg( not( feature = "unstable-v5" ) ) ]
330366#[ test]
331367fn value_enum_multiline_doc_comment ( ) {
332368 #[ derive( Parser , Debug ) ]
You can’t perform that action at this time.
0 commit comments