Skip to content

Commit e2a74b5

Browse files
authored
cargo ci self-docs uses doc comments as well as explicit helptext (#4860)
# Description of Changes Several args for `cargo ci` had empty helptext, because we were only printing the explicitly-annotated helptext. This PR updates it so that inline helptext also shows in the README. # API and ABI breaking changes None. CI only. # Expected complexity level and risk 1 # Testing - [x] Updated README has more helptext --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
1 parent 2d67d76 commit e2a74b5

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

tools/ci/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Usage: smoketests [OPTIONS] [ARGS]... [COMMAND]
103103
When specified, tests will connect to the given URL instead of starting local server instances. Tests that require local server control (like restart tests) will be skipped.
104104

105105
- `--dotnet`:
106-
- `args`:
106+
- `args`: Additional arguments to pass to the test runner
107107
- `--help`: Print help (see a summary with '-h')
108108

109109
#### `prepare`
@@ -130,7 +130,7 @@ Usage: check-mod-list
130130

131131
**Options:**
132132

133-
- `--help`:
133+
- `--help`: Print help
134134

135135
#### `help`
136136

@@ -141,7 +141,7 @@ Usage: help [COMMAND]...
141141

142142
**Options:**
143143

144-
- `subcommand`:
144+
- `subcommand`: Print help for the subcommand(s)
145145

146146
### `update-flow`
147147

@@ -193,7 +193,7 @@ Usage: global-json-policy
193193

194194
**Options:**
195195

196-
- `--help`:
196+
- `--help`: Print help
197197

198198
### `help`
199199

@@ -204,7 +204,7 @@ Usage: help [COMMAND]...
204204

205205
**Options:**
206206

207-
- `subcommand`:
207+
- `subcommand`: Print help for the subcommand(s)
208208

209209

210210
---

tools/ci/src/ci_docs.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,19 @@ fn generate_markdown(cmd: &mut Command, heading_level: usize) -> String {
4646
.map(|l| format!("--{}", l))
4747
.or_else(|| arg.get_short().map(|s| format!("-{}", s)))
4848
.unwrap_or_else(|| arg.get_id().to_string());
49-
let help = arg.get_long_help().unwrap_or_default();
49+
let help = arg
50+
.get_long_help()
51+
.or_else(|| arg.get_help())
52+
.map(|help| help.to_string())
53+
.unwrap_or_else(|| {
54+
eprintln!("Warning: argument `{}` is missing help text", arg.get_id());
55+
"".to_string()
56+
});
5057
options.push_str(&format!(
5158
"- `{}`: {}\n{}",
5259
names,
5360
help,
54-
if help.to_string().lines().count() > 1 { "\n" } else { "" }
61+
if help.lines().count() > 1 { "\n" } else { "" }
5562
));
5663
}
5764

0 commit comments

Comments
 (0)