Skip to content

Commit

Permalink
test(derive): Show current doc comment behavior
Browse files Browse the repository at this point in the history
Based on clap-rs#2983
  • Loading branch information
epage committed Dec 14, 2021
1 parent 8ec6f2e commit f6fdc4e
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tests/derive/doc_comments_help.rs
Expand Up @@ -14,7 +14,7 @@

use crate::utils;

use clap::{ArgEnum, Parser};
use clap::{ArgEnum, IntoApp, Parser};

#[test]
fn doc_comments() {
Expand Down Expand Up @@ -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")
);
}

0 comments on commit f6fdc4e

Please sign in to comment.