Skip to content

Commit ef293f7

Browse files
authored
CI - ci self-docs includes value names (#5152)
# Description of Changes the `README.md` (generated by `cargo ci self-docs`) now properly includes the value names passed to args. This change was made by AI. # API and ABI breaking changes None. CI only. # Expected complexity level and risk 1 # Testing CI, including the docs check, passes Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
1 parent ae9e8c8 commit ef293f7

2 files changed

Lines changed: 24 additions & 15 deletions

File tree

tools/ci/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Usage: cargo ci [OPTIONS] [COMMAND]
1919

2020
**Options:**
2121

22-
- `--skip`: Skip specified subcommands when running all
22+
- `--skip <SKIP>`: Skip specified subcommands when running all
2323

2424
When no subcommand is specified, all subcommands are run in sequence. This option allows specifying subcommands to skip when running all. For example, to skip the `unreal-tests` subcommand, use `--skip unreal-tests`.
2525

@@ -98,12 +98,12 @@ Usage: smoketests [OPTIONS] [ARGS]... [COMMAND]
9898

9999
**Options:**
100100

101-
- `--server`: Run tests against a remote server instead of spawning local servers.
101+
- `--server <SERVER>`: Run tests against a remote server instead of spawning local servers.
102102

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

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

109109
#### `prepare`
@@ -141,7 +141,7 @@ Usage: help [COMMAND]...
141141

142142
**Options:**
143143

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

146146
### `keynote-bench`
147147

@@ -171,7 +171,7 @@ Usage: update-flow [OPTIONS]
171171

172172
**Options:**
173173

174-
- `--target`: Target triple to build for, by default the current target. Used by github workflows to check the update flow on multiple platforms.
174+
- `--target <TARGET>`: Target triple to build for, by default the current target. Used by github workflows to check the update flow on multiple platforms.
175175
- `--github-token-auth`: Whether to enable github token authentication feature when building the update binary. By default this is disabled.
176176
- `--help`: Print help (see a summary with '-h')
177177

@@ -184,7 +184,7 @@ Usage: cli-docs [OPTIONS]
184184

185185
**Options:**
186186

187-
- `--spacetime-path`: specify a custom path to the SpacetimeDB repository root (where the main Cargo.toml is located)
187+
- `--spacetime-path <SPACETIME_PATH>`: specify a custom path to the SpacetimeDB repository root (where the main Cargo.toml is located)
188188
- `--help`: Print help (see a summary with '-h')
189189

190190
### `self-docs`
@@ -263,7 +263,7 @@ Usage: help [COMMAND]...
263263

264264
**Options:**
265265

266-
- `subcommand`: Print help for the subcommand(s)
266+
- `subcommand <COMMAND>`: Print help for the subcommand(s)
267267

268268

269269
---

tools/ci/src/ci_docs.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@ fn generate_markdown(cmd: &mut Command, heading_level: usize) -> String {
4141

4242
let mut options = String::new();
4343
for arg in cmd.get_arguments() {
44-
let names = arg
44+
let mut names = arg
4545
.get_long()
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+
if let Some(value_names) = arg.get_value_names().filter(|_| arg.get_action().takes_values()) {
50+
for value_name in value_names {
51+
names.push_str(&format!(" <{value_name}>"));
52+
}
53+
}
4954
let help = arg
5055
.get_long_help()
5156
.or_else(|| arg.get_help())
@@ -54,12 +59,16 @@ fn generate_markdown(cmd: &mut Command, heading_level: usize) -> String {
5459
eprintln!("Warning: argument `{}` is missing help text", arg.get_id());
5560
"".to_string()
5661
});
57-
options.push_str(&format!(
58-
"- `{}`: {}\n{}",
59-
names,
60-
help,
61-
if help.lines().count() > 1 { "\n" } else { "" }
62-
));
62+
if help.is_empty() {
63+
options.push_str(&format!("- `{names}`:\n"));
64+
} else {
65+
options.push_str(&format!(
66+
"- `{}`: {}\n{}",
67+
names,
68+
help,
69+
if help.lines().count() > 1 { "\n" } else { "" }
70+
));
71+
}
6372
}
6473

6574
if !options.is_empty() {

0 commit comments

Comments
 (0)