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:
parent
a72a20d68f
commit
6f19c776db
6 changed files with 63 additions and 2 deletions
42
doc/manual/generate-manpage.jq
Normal file
42
doc/manual/generate-manpage.jq
Normal 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(""))
|
Loading…
Add table
Add a link
Reference in a new issue