Skip to content

Commit f17d9a7

Browse files
committed
feat: explain mapping of commands.<name> to commands.*
1 parent 4e8ddaf commit f17d9a7

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

modules/modules-docs.nix

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ let
4747
in
4848
map (p: repack (unpack p));
4949

50+
mkUrl = root: path: "${root.url}/tree/${root.branch}/${path}";
51+
5052
# Transforms a module path into a (path, url) tuple where path is relative
5153
# to the repo root, and URL points to an online view of the module.
5254
mkDeclaration =
@@ -69,7 +71,7 @@ let
6971
else
7072
rec {
7173
path = removePrefix root.prefix decl;
72-
url = "${root.url}/tree/${root.branch}/${path}";
74+
url = mkUrl root path;
7375
};
7476

7577
# Sort modules and put "enable" and "package" declarations first.
@@ -114,7 +116,11 @@ let
114116
)
115117
);
116118

117-
inherit (import ../nix/commands/lib.nix { inherit pkgs; }) mkLocLast nestedOptionsType;
119+
inherit (import ../nix/commands/lib.nix { inherit pkgs; })
120+
mkLocLast
121+
nestedOptionsType
122+
flatOptionsType
123+
;
118124

119125
# TODO: display values like TOML instead.
120126
toMarkdown = optionsDocs:
@@ -174,6 +180,16 @@ let
174180
doc = [
175181
"# `devshell` options\n"
176182
"## Available only in `Nix`\n"
183+
(
184+
let
185+
root = head cfg.roots;
186+
path = "nix/commands/examples.nix";
187+
mkLink = path: "[link](${mkUrl root path})";
188+
in
189+
''
190+
See how `commands.<name>` (${mkLink "nix/commands/examples.nix"}) maps to `commands.*` (${mkLink "tests/extra/lib.flattenCommands.nix"}).
191+
''
192+
)
177193
(concatStringsSep "\n" (map optToMd nixOnly_))
178194
"## Available in `Nix` and `TOML`\n"
179195
(concatStringsSep "\n" (map optToMd nixTOML))

0 commit comments

Comments
 (0)