aboutsummaryrefslogtreecommitdiff
path: root/doc/manual
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-08-17 19:33:18 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-08-17 19:33:18 +0200
commit6f19c776db280a46e84d6e84d83814445869ef37 (patch)
tree6450cbf8137d25c696f1813271e1c69ed1814233 /doc/manual
parenta72a20d68fe6ae75f05f69e7de0bc3326d779144 (diff)
Start generation of the nix.1 manpage
Diffstat (limited to 'doc/manual')
-rw-r--r--doc/manual/generate-manpage.jq42
-rw-r--r--doc/manual/local.mk8
-rw-r--r--doc/manual/src/SUMMARY.md2
-rw-r--r--doc/manual/src/command-ref/experimental-commands.md8
4 files changed, 59 insertions, 1 deletions
diff --git a/doc/manual/generate-manpage.jq b/doc/manual/generate-manpage.jq
new file mode 100644
index 000000000..cf06da0c8
--- /dev/null
+++ b/doc/manual/generate-manpage.jq
@@ -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(""))
diff --git a/doc/manual/local.mk b/doc/manual/local.mk
index c9104ad7e..8f917316d 100644
--- a/doc/manual/local.mk
+++ b/doc/manual/local.mk
@@ -4,7 +4,7 @@ MANUAL_SRCS := $(call rwildcard, $(d)/src, *.md)
# Generate man pages.
man-pages := $(foreach n, \
- nix-env.1 nix-build.1 nix-shell.1 nix-store.1 nix-instantiate.1 \
+ nix-env.1 nix-build.1 nix-shell.1 nix-store.1 nix-instantiate.1 nix.1 \
nix-collect-garbage.1 \
nix-prefetch-url.1 nix-channel.1 \
nix-hash.1 nix-copy-closure.1 \
@@ -24,6 +24,12 @@ $(d)/%.8: $(d)/src/command-ref/%.md
$(d)/nix.conf.5: $(d)/src/command-ref/conf-file.md
$(trace-gen) lowdown -sT man $^ -o $@
+$(d)/src/command-ref/nix.md: $(d)/nix.json $(d)/generate-manpage.jq
+ jq -r -f doc/manual/generate-manpage.jq $< > $@
+
+$(d)/nix.json: $(bindir)/nix
+ $(trace-gen) $(bindir)/nix dump-args > $@
+
# Generate the HTML manual.
install: $(docdir)/manual/index.html
diff --git a/doc/manual/src/SUMMARY.md b/doc/manual/src/SUMMARY.md
index 5f6817674..4089caf8a 100644
--- a/doc/manual/src/SUMMARY.md
+++ b/doc/manual/src/SUMMARY.md
@@ -60,6 +60,8 @@
- [nix-hash](command-ref/nix-hash.md)
- [nix-instantiate](command-ref/nix-instantiate.md)
- [nix-prefetch-url](command-ref/nix-prefetch-url.md)
+ - [Experimental Commands](command-ref/experimental-commands.md)
+ - [nix](command-ref/nix.md)
- [Files](command-ref/files.md)
- [nix.conf](command-ref/conf-file.md)
- [Glossary](glossary.md)
diff --git a/doc/manual/src/command-ref/experimental-commands.md b/doc/manual/src/command-ref/experimental-commands.md
new file mode 100644
index 000000000..cfa6f8b73
--- /dev/null
+++ b/doc/manual/src/command-ref/experimental-commands.md
@@ -0,0 +1,8 @@
+# Experimental Commands
+
+This section lists experimental commands.
+
+> **Warning**
+>
+> These commands may be removed in the future, or their syntax may
+> change in incompatible ways.