Repository: clap-rs/clap (rust)

Issue:
Generated man pages still claim that flag options take values
### Please complete the following tasks

- [X] I have searched the [discussions](https://github.com/clap-rs/clap/discussions)
- [X] I have searched the [open](https://github.com/clap-rs/clap/issues) and [rejected](https://github.com/clap-rs/clap/issues?q=is%3Aissue+label%3AS-wont-fix+is%3Aclosed) issues

### Rust Version

rustc 1.64.0 (Fedora 1.64.0-1.fc36)

### Clap Version

4.0.18, clap_mangen 0.2.4

### Minimal reproducible code

```rust
use clap::{CommandFactory, Parser};

#[derive(Parser)]
/// Command to do things
pub struct Cmd {
    /// Do thing
    #[clap(long)]
    thing: bool,
}

fn main() {
    Cmd::parse();
    clap_mangen::Man::new(Cmd::command())
        .render(&mut std::io::stdout())
        .unwrap();
}
```

Cargo.toml:

```toml
[package]
name = "clap-man"
version = "0.0.0"
edition = "2021"

[dependencies]
clap = { version = "4", features = ["derive"] }
clap_mangen = "0.2"
```

### Steps to reproduce the bug with the above code

```command
cargo run | man -l -
```

### Actual Behaviour

The option description for `--thing` claims that it takes an argument:

```
clap-man(1)                 General Commands Manual                clap-man(1)

NAME
       clap-man - Command to do things

SYNOPSIS
       clap-man [--thing] [-h|--help]

DESCRIPTION
       Command to do things

OPTIONS
       --thing=THING
              Do thing

       -h, --help
              Print help information

                                   clap-man                        clap-man(1)
```

It doesn't:

```command
$ cargo run -- --thing=true
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/clap-man --thing=true`
error: The value 'true' was provided to '--thing' but it wasn't expecting any more values

Usage: clap-man --thing

For more information try '--help'
```

### Expected Behaviour

The man page lists the option without any argument, as it did in clap 3.2 / clap_mangen 0.1:

```
clap-man(1)                 General Commands Manual                clap-man(1)

NAME
       clap-man - Command to do things

SYNOPSIS
       clap-man [--thing] [-h|--help]

DESCRIPTION
       Command to do things

OPTIONS
       --thing
              Do thing

       -h, --help
              Print help information

                                   clap-man                        clap-man(1)
```

### Additional Context

This is a followup to https://github.com/clap-rs/clap/issues/4410.  clap_mangen 0.2.4 improved the situation but didn't fix it.

### Debug Output

_No response_

Pull request:
fix(mangen): Avoid spurious value names for derive args without values
derive arguments like this:

    #[arg(long)]
    pub flag: bool,

were producing option descriptions like this:

    --flag=FLAG

`FLAG` is spurious.  It turns out that derive always sets a value name, for simplicity, even when there are no arguments.  Check for this case.

Fixes #4443.

Patch:
diff --git a/clap_mangen/src/render.rs b/clap_mangen/src/render.rs
index ab9c9ec7..ea3dffbe 100644
--- a/clap_mangen/src/render.rs
+++ b/clap_mangen/src/render.rs
@@ -99,9 +99,11 @@ pub(crate) fn options(roff: &mut Roff, cmd: &clap::Command) {
             (None, None) => vec![],
         };
 
-        if let Some(value) = &opt.get_value_names() {
-            header.push(roman("="));
-            header.push(italic(value.join(" ")));
+        if opt.get_action().takes_values() {
+            if let Some(value) = &opt.get_value_names() {
+                header.push(roman("="));
+                header.push(italic(value.join(" ")));
+            }
         }
 
         if let Some(defs) = option_default_values(opt) {


Test patch:
diff --git a/clap_mangen/tests/common.rs b/clap_mangen/tests/common.rs
index ca9f1f9b..029098c0 100644
--- a/clap_mangen/tests/common.rs
+++ b/clap_mangen/tests/common.rs
@@ -312,3 +312,12 @@ pub fn possible_values_command(name: &'static str) -> clap::Command {
                 ]),
         )
 }
+
+pub fn value_name_without_arg(name: &'static str) -> clap::Command {
+    clap::Command::new(name).arg(
+        clap::Arg::new("flag")
+            .long("flag")
+            .value_name("SPURIOUS")
+            .action(clap::ArgAction::SetTrue),
+    )
+}
diff --git a/clap_mangen/tests/roff.rs b/clap_mangen/tests/roff.rs
index 223196c3..38d1aef1 100644
--- a/clap_mangen/tests/roff.rs
+++ b/clap_mangen/tests/roff.rs
@@ -83,3 +83,10 @@ fn sub_subcommands_help() {
         common::assert_matches_path("tests/snapshots/sub_subcommand_help.roff", cmd.clone());
     }
 }
+
+#[test]
+fn value_name_without_arg() {
+    let name = "my-app";
+    let cmd = common::value_name_without_arg(name);
+    common::assert_matches_path("tests/snapshots/value_name_without_arg.bash.roff", cmd);
+}
diff --git a/clap_mangen/tests/snapshots/value_name_without_arg.bash.roff b/clap_mangen/tests/snapshots/value_name_without_arg.bash.roff
new file mode 100644
index 00000000..2ffbe021
--- /dev/null
+++ b/clap_mangen/tests/snapshots/value_name_without_arg.bash.roff
@@ -0,0 +1,15 @@
+.ie /n(.g .ds Aq /(aq
+.el .ds Aq '
+.TH my-app 1  "my-app " 
+.SH NAME
+my/-app
+.SH SYNOPSIS
+/fBmy/-app/fR [/fB/-/-flag/fR] [/fB/-h/fR|/fB/-/-help/fR] 
+.SH DESCRIPTION
+.SH OPTIONS
+.TP
+/fB/-/-flag/fR
+
+.TP
+/fB/-h/fR, /fB/-/-help/fR
+Print help