From 76a016a0836351d9faef9c6329c1be70fd40f88a Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 4 Aug 2025 09:15:01 -0500 Subject: [PATCH] refactor(man): Allow possible values to output Roff --- clap_mangen/src/render.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/clap_mangen/src/render.rs b/clap_mangen/src/render.rs index ce1fcb331..fa43a0253 100644 --- a/clap_mangen/src/render.rs +++ b/clap_mangen/src/render.rs @@ -206,7 +206,7 @@ fn possible_options(roff: &mut Roff, arg: &Arg, arg_help_written: bool) { roff.control("RS", ["14"]); for line in possible_values_text { roff.control("IP", ["\\(bu", "2"]); - roff.text([roman(line)]); + roff.extend([line]); } roff.control("RE", []); } @@ -346,7 +346,7 @@ fn option_default_values(opt: &Arg) -> Option { None } -fn get_possible_values(arg: &Arg) -> Option> { +fn get_possible_values(arg: &Arg) -> Option> { if arg.is_hide_possible_values_set() { return None; } @@ -361,14 +361,20 @@ fn get_possible_values(arg: &Arg) -> Option> { None } -fn format_possible_values(possibles: &Vec<&clap::builder::PossibleValue>) -> Vec { +fn format_possible_values(possibles: &Vec<&clap::builder::PossibleValue>) -> Vec { let mut lines = vec![]; for value in possibles { + let mut roff = Roff::default(); let val_name = value.get_name(); match value.get_help() { - Some(help) => lines.push(format!("{val_name}: {help}")), - None => lines.push(val_name.to_owned()), + Some(help) => { + roff.text([roman(format!("{val_name}: {help}"))]); + } + None => { + roff.text([roman(val_name.to_owned())]); + } } + lines.push(roff); } lines }