2023-05-03 07:16:29 +00:00
let
2023-05-13 17:52:45 +00:00
inherit ( builtins ) concatStringsSep attrValues mapAttrs ;
2023-11-30 20:41:47 +00:00
inherit ( import <nix/utils.nix> ) optionalString squash ;
2023-05-03 07:16:29 +00:00
in
builtinsInfo :
2022-11-24 12:47:08 +00:00
let
2024-07-07 19:57:23 +00:00
showBuiltin = name : { doc , type ? null , args ? [ ] , experimental-feature ? null , impure-only ? false }:
2022-11-24 12:47:08 +00:00
let
2024-07-07 19:57:23 +00:00
type' = optionalString ( type != null ) " ( ${ type } ) " ;
2023-05-13 17:52:45 +00:00
experimentalNotice = optionalString ( experimental-feature != null ) ''
2023-12-10 05:16:32 +00:00
> * * Note * *
>
2024-07-25 02:53:06 +00:00
> This function is only available if the [ ` $ { experimental-feature } ` experimental feature ] ( @ docroot @ /development/experimental-features.md #xp-feature-${experimental-feature}) is enabled.
2023-12-10 05:16:32 +00:00
>
> For example , include the following in [ ` nix . conf ` ] ( @ docroot @ /command-ref/conf-file.md ) :
>
> ` ` `
> extra-experimental-features = $ { experimental-feature }
> ` ` `
2023-05-13 17:52:45 +00:00
'' ;
2024-07-07 19:57:23 +00:00
impureNotice = optionalString impure-only ''
> * * Note * *
>
> Not available in [ pure evaluation mode ] ( @ docroot @ /command-ref/conf-file.md #conf-pure-eval).
'' ;
2022-11-24 12:47:08 +00:00
in
2023-05-13 17:52:45 +00:00
squash ''
2022-11-24 12:47:08 +00:00
< dt id = " b u i l t i n s - ${ name } " >
2024-07-07 19:57:23 +00:00
< a href = " # b u i l t i n s - ${ name } " > <code> $ { name } $ { listArgs args } < /code > < /a > $ { type' }
2022-11-24 12:47:08 +00:00
< /dt >
<dd>
2020-09-16 12:55:24 +00:00
2023-05-13 17:52:45 +00:00
$ { experimentalNotice }
2022-11-24 12:47:08 +00:00
2023-12-10 05:16:32 +00:00
$ { doc }
2024-07-07 19:57:23 +00:00
$ { impureNotice }
2022-11-24 12:47:08 +00:00
< /dd >
'' ;
2024-07-07 19:57:23 +00:00
listArgs = args : concatStringsSep " " ( map ( s : " < v a r > ${ s } < / v a r > " ) args ) ;
2022-11-24 12:47:08 +00:00
in
2023-05-13 17:52:45 +00:00
concatStringsSep " \n " ( attrValues ( mapAttrs showBuiltin builtinsInfo ) )