aboutsummaryrefslogtreecommitdiff
path: root/doc/manual/generate-builtins.nix
blob: 813a287f52135f76d55867fa10ad5777bc646b1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
let
  inherit (builtins) concatStringsSep attrValues mapAttrs;
  inherit (import ./utils.nix) optionalString squash;
in

builtinsInfo:
let
  showBuiltin = name: { doc, args, arity, experimental-feature }:
    let
      experimentalNotice = optionalString (experimental-feature != null) ''
        This function is only available if the [${experimental-feature}](@docroot@/contributing/experimental-features.md#xp-feature-${experimental-feature}) experimental feature is enabled.
      '';
    in
    squash ''
      <dt id="builtins-${name}">
        <a href="#builtins-${name}"><code>${name} ${listArgs args}</code></a>
      </dt>
      <dd>

      ${doc}

      ${experimentalNotice}

      </dd>
    '';
  listArgs = args: concatStringsSep " " (map (s: "<var>${s}</var>") args);
in
concatStringsSep "\n" (attrValues (mapAttrs showBuiltin builtinsInfo))