1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 06:53:54 +02:00

Start generation of the nix.1 manpage

This commit is contained in:
Eelco Dolstra 2020-08-17 19:33:18 +02:00
parent a72a20d68f
commit 6f19c776db
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
6 changed files with 63 additions and 2 deletions

View file

@ -0,0 +1,42 @@
def show_flags:
.flags
| map_values(select(.category != "config"))
| to_entries
| map(
" - `--" + .key + "`"
+ (if .value.shortName then " / `" + .value.shortName + "`" else "" end)
+ (if .value.labels then " " + (.value.labels | map("*" + . + "*") | join(" ")) else "" end)
+ " \n"
+ " " + .value.description + "\n\n")
| join("")
;
def show_synopsis:
"`" + .command + "` " + (.args | map("*" + .label + "*" + (if has("arity") then "" else "..." end)) | join(" ")) + "\n"
;
"# Synopsis\n\n"
+ ({"command": "nix", "args": .args} | show_synopsis)
+ "\n"
+ "# Common flags\n\n"
+ show_flags
+ (.commands | to_entries | map(
"# Operation `" + .key + "`\n\n"
+ "## Synopsis\n\n"
+ ({"command": ("nix " + .key), "args": .value.args} | show_synopsis)
+ "\n"
+ "## Description\n\n"
+ .value.description + "\n\n"
+ (if (.value.flags | length) > 0 then
"## Flags\n\n"
+ (.value | show_flags)
else "" end)
+ (if (.value.examples | length) > 0 then
"## Examples\n\n"
+ (.value.examples | map("- " + .description + "\n\n ```console\n " + .command + "\n ```\n" ) | join("\n"))
+ "\n"
else "" end)
) | join(""))