aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-20 22:30:32 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-20 22:30:32 +0200
commit76f43cc7817fafed2485ac975426eb2e97ea9986 (patch)
tree16629e6bceff4eb36f40b6f3ac2c0e8dcbfa9691 /scripts
parent62504dda1527490cb49e56dd9840031479d258f0 (diff)
downloadbokf-76f43cc7817fafed2485ac975426eb2e97ea9986.tar.gz
bokf-76f43cc7817fafed2485ac975426eb2e97ea9986.zip
docs: render enum args as type(values) in the generated catalogue
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gen_protocol.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/scripts/gen_protocol.c b/scripts/gen_protocol.c
index b39bb7d..6746973 100644
--- a/scripts/gen_protocol.c
+++ b/scripts/gen_protocol.c
@@ -66,23 +66,24 @@ static void render_args(struct buf *b, yyjson_val *args)
buf_cell(b, jstr(a, "name"));
buf_puts(b, ":");
buf_cell(b, jstr(a, "type"));
- if (jbool(a, "required"))
- buf_puts(b, "!");
- yyjson_val *def = yyjson_obj_get(a, "default");
- if (def) {
- buf_puts(b, "=");
- buf_cell(b, yyjson_get_str(def));
- }
yyjson_val *vals = yyjson_obj_get(a, "values");
if (vals && yyjson_is_arr(vals)) {
size_t vi, vmax;
yyjson_val *v;
- buf_puts(b, " enum ");
+ buf_puts(b, "(");
yyjson_arr_foreach(vals, vi, vmax, v) {
if (vi)
buf_puts(b, "\\|");
buf_cell(b, yyjson_get_str(v));
}
+ buf_puts(b, ")");
+ }
+ if (jbool(a, "required"))
+ buf_puts(b, "!");
+ yyjson_val *def = yyjson_obj_get(a, "default");
+ if (def) {
+ buf_puts(b, "=");
+ buf_cell(b, yyjson_get_str(def));
}
buf_puts(b, "`");
}
@@ -103,7 +104,7 @@ static char *render_block(void)
buf_puts(&b, BEGIN_MARK "\n");
buf_puts(&b, "## Command catalogue (generated)\n\n");
buf_puts(&b, "Generated by `make gen-protocol` from the command tables; do not "
- "edit by hand.\nArgs: `name:type[!][=default][ enum a\\|b]`, `!` = "
+ "edit by hand.\nArgs: `name:type(values)[!][=default]`, `!` = "
"required.\n\n");
buf_puts(&b, "| Command | Permission | Org | Mutating | Dry run | Args |\n");
buf_puts(&b, "|---|---|---|---|---|---|\n");