aboutsummaryrefslogtreecommitdiff
path: root/doc/manual/generate-manpage.nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-01-25 18:19:32 +0100
committerEelco Dolstra <edolstra@gmail.com>2021-01-25 18:19:32 +0100
commit807d963ee8d23e88f09e28365b045d322530c5aa (patch)
tree69a055b564097daa62b15a84aa3458b1c80df178 /doc/manual/generate-manpage.nix
parent3ba98ba8f08523e60310cf75ec809bd21d0ce977 (diff)
Group subcommands by category
Diffstat (limited to 'doc/manual/generate-manpage.nix')
-rw-r--r--doc/manual/generate-manpage.nix23
1 files changed, 19 insertions, 4 deletions
diff --git a/doc/manual/generate-manpage.nix b/doc/manual/generate-manpage.nix
index c2c748464..30152088d 100644
--- a/doc/manual/generate-manpage.nix
+++ b/doc/manual/generate-manpage.nix
@@ -13,12 +13,27 @@ let
+ showSynopsis { inherit command; args = def.args; }
+ (if def.commands or {} != {}
then
+ let
+ categories = sort (x: y: x.id < y.id) (unique (map (cmd: cmd.category) (attrValues def.commands)));
+ listCommands = cmds:
+ concatStrings (map (name:
+ "* [`${command} ${name}`](./${appendName filename name}.md) - ${cmds.${name}.description}\n")
+ (attrNames cmds));
+ in
"where *subcommand* is one of the following:\n\n"
# FIXME: group by category
- + concatStrings (map (name:
- "* [`${command} ${name}`](./${appendName filename name}.md) - ${def.commands.${name}.description}\n")
- (attrNames def.commands))
- + "\n"
+ + (if length categories > 1
+ then
+ concatStrings (map
+ (cat:
+ "**${toString cat.description}:**\n\n"
+ + listCommands (filterAttrs (n: v: v.category == cat) def.commands)
+ + "\n"
+ ) categories)
+ + "\n"
+ else
+ listCommands def.commands
+ + "\n")
else "")
+ (if def ? doc
then def.doc + "\n\n"