From f6fdc4e127206bbc398482b930cf212e687ee398 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 14 Dec 2021 09:58:11 -0600 Subject: [PATCH] test(derive): Show current doc comment behavior Based on #2983 --- tests/derive/doc_comments_help.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/derive/doc_comments_help.rs b/tests/derive/doc_comments_help.rs index 000b98e5c6ad..c35718b91f26 100644 --- a/tests/derive/doc_comments_help.rs +++ b/tests/derive/doc_comments_help.rs @@ -14,7 +14,7 @@ use crate::utils; -use clap::{ArgEnum, Parser}; +use clap::{ArgEnum, IntoApp, Parser}; #[test] fn doc_comments() { @@ -214,3 +214,28 @@ fn argenum_multiline_doc_comment() { Bar, } } + +#[test] +fn doc_comment_about_handles_both_abouts() { + /// Opts doc comment summary + #[derive(Parser, Debug)] + pub struct Opts { + #[clap(subcommand)] + pub cmd: Sub, + } + + /// Sub doc comment summary + /// + /// Sub doc comment body + #[derive(Parser, PartialEq, Eq, Debug)] + pub enum Sub { + Compress { output: String }, + } + + let app = Opts::into_app(); + assert_eq!(app.get_about(), Some("Opts doc comment summary")); + assert_eq!( + app.get_long_about(), + Some("Sub doc comment summary\n\nSub doc comment body") + ); +}