|
29 | 29 | set_val = lib.${set}; |
30 | 30 | documentedFunctions = filterDocumentedFunctions set_val; |
31 | 31 | in map (n: {name = ["lib" set n]; docs = mkDocs set_val.${n}; }) documentedFunctions; |
| 32 | + |
| 33 | + makeDocChapter = topLevel: categorized: |
| 34 | + let |
| 35 | + prefix = '' |
| 36 | + <chapter xmlns="http://docbook.org/ns/docbook" |
| 37 | + xmlns:xlink="http://www.w3.org/1999/xlink" |
| 38 | + xml:id="chap-lib-functions"> |
| 39 | +
|
| 40 | + <title>Library functions</title> |
| 41 | + <para>This paragraph describes the available library functions.</para> |
| 42 | + ''; |
| 43 | + postfix = "</chapter>"; |
| 44 | + toplevel.prefix = '' |
| 45 | + <section xml:id="sec-lib-functions-top-level"> |
| 46 | + <title>Top level functions</title> |
| 47 | + <para>These functions are available under <varname>pkgs.lib</varname></para> |
| 48 | + ''; |
| 49 | + toplevel.postfix = "</section>"; |
| 50 | + categories.prefix = '' |
| 51 | + <section xml:id="sec-lib-functions-all"> |
| 52 | + <title>All library functions</title> |
| 53 | + <para>These functions are available under <varname>pkgs.$category.$name</varname></para> |
| 54 | + ''; |
| 55 | + categories.postfix = "</section>"; |
| 56 | + makeDocExample = example: |
| 57 | + "<para><emphasis>Example:</emphasis><programlisting>${example}</programlisting></para>"; |
| 58 | + makeDocFn = { docs, name }: '' |
| 59 | + <varlistentry> |
| 60 | + <term><option>${concatStringsSep "." name}</option></term> |
| 61 | + <listitem> |
| 62 | + <para>${docs.description}</para> |
| 63 | + ${ |
| 64 | + lib.concatStrings (map makeDocExample docs.examples) |
| 65 | + } |
| 66 | + </listitem> |
| 67 | + </varlistentry> |
| 68 | + ''; |
| 69 | + makeDocFns = fns: "<variablelist>" + (lib.concatStrings (map makeDocFn fns)) + "</variablelist>"; |
| 70 | + in |
| 71 | + prefix + |
| 72 | + toplevel.prefix + (makeDocFns topLevel) + toplevel.postfix + |
| 73 | + categories.prefix + (makeDocFns categorized) + categories.postfix + |
| 74 | + postfix; |
32 | 75 | in |
33 | | -{ |
| 76 | +rec { |
34 | 77 | categorized = concatLists (map find_functions sets); |
35 | 78 | topLevel = topLevelDocumentedFunctions; |
| 79 | + docChapter = makeDocChapter topLevel categorized; |
36 | 80 | } |
0 commit comments