aboutsummaryrefslogtreecommitdiff
path: root/doc/manual/generate-builtin-constants.nix
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-05-13 13:52:45 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-06-27 09:37:54 -0400
commit22b278e011ab9c1328749a126514c57b89a39173 (patch)
tree0920c88b6bc996502f5ebf153fcb4c8956321e6e /doc/manual/generate-builtin-constants.nix
parentd40f0e534d657e619634ba204fb8970f4a01fbc5 (diff)
Automatically document builtin constants
This is done in roughly the same way builtin functions are documented. Also auto-link experimental features for primops, subsuming PR #8371. Co-authored-by: Eelco Dolstra <edolstra@gmail.com> Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Diffstat (limited to 'doc/manual/generate-builtin-constants.nix')
-rw-r--r--doc/manual/generate-builtin-constants.nix29
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/manual/generate-builtin-constants.nix b/doc/manual/generate-builtin-constants.nix
new file mode 100644
index 000000000..3fc1fae42
--- /dev/null
+++ b/doc/manual/generate-builtin-constants.nix
@@ -0,0 +1,29 @@
+let
+ inherit (builtins) concatStringsSep attrValues mapAttrs;
+ inherit (import ./utils.nix) optionalString squash;
+in
+
+builtinsInfo:
+let
+ showBuiltin = name: { doc, type, impure-only }:
+ let
+ type' = optionalString (type != null) " (${type})";
+
+ impureNotice = optionalString impure-only ''
+ Not available in [pure evaluation mode](@docroot@/command-ref/conf-file.md#conf-pure-eval).
+ '';
+ in
+ squash ''
+ <dt id="builtin-constants-${name}">
+ <a href="#builtin-constants-${name}"><code>${name}</code>${type'}</a>
+ </dt>
+ <dd>
+
+ ${doc}
+
+ ${impureNotice}
+
+ </dd>
+ '';
+in
+concatStringsSep "\n" (attrValues (mapAttrs showBuiltin builtinsInfo))