diff options
author | Graham Christensen <graham@grahamc.com> | 2018-10-12 15:29:09 -0400 |
---|---|---|
committer | Graham Christensen <graham@grahamc.com> | 2018-10-12 16:06:11 -0400 |
commit | ef05e1057b91647b7c2662437fd658e8b0286e80 (patch) | |
tree | 23d57159bc6ffba8df72cd48d5fee0484e758149 /doc/functions | |
parent | d664b8f5e3aeff8d6cf826d103bca342a7cf81c2 (diff) |
nixpkgs docs: document genAttrs
Diffstat (limited to 'doc/functions')
-rw-r--r-- | doc/functions/library/attrsets.xml | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/doc/functions/library/attrsets.xml b/doc/functions/library/attrsets.xml index 7a8ce95fd030..78d05589aa8f 100644 --- a/doc/functions/library/attrsets.xml +++ b/doc/functions/library/attrsets.xml @@ -1172,4 +1172,63 @@ lib.attrsets.mapAttrsRecursiveCond </example> </section> + <section xml:id="function-library-lib.attrsets.genAttrs"> + <title><function>lib.attrsets.genAttrs</function></title> + + <subtitle><literal>genAttrs :: [ String ] -> (String -> Any) -> AttrSet</literal> + </subtitle> + + <xi:include href="./locations.xml" xpointer="lib.attrsets.genAttrs" /> + + <para> + Generate an attribute set by mapping a function over a list of attribute + names. + </para> + + <variablelist> + <varlistentry> + <term> + <varname>names</varname> + </term> + <listitem> + <para> + Names of values in the resulting attribute set. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <varname>f</varname> + </term> + <listitem> + <para> + <literal>String -> Any</literal> + </para> + <para> + Takes the name of the attribute and return the attribute's value. + </para> + <variablelist> + <varlistentry> + <term> + <varname>name</varname> + </term> + <listitem> + <para> + The name of the attribute to generate a value for. + </para> + </listitem> + </varlistentry> + </variablelist> + </listitem> + </varlistentry> + </variablelist> + + <example xml:id="function-library-lib.attrsets.genAttrs-example"> + <title>Generate an attrset based on names only</title> +<programlisting><![CDATA[ +lib.attrsets.genAttrs [ "foo" "bar" ] (name: "x_${name}") +=> { foo = "x_foo"; bar = "x_bar"; } + ]]></programlisting> + </example> + </section> </section> |