|
19 | 19 | prefix,
|
20 | 20 | inlineHTML ? true,
|
21 | 21 | }:
|
22 |
| -settingsInfo: |
23 | 22 |
|
24 | 23 | let
|
25 | 24 |
|
26 | 25 | showSetting =
|
27 | 26 | prefix: setting:
|
28 | 27 | {
|
29 | 28 | description,
|
30 |
| - documentDefault, |
31 |
| - defaultValue, |
32 |
| - aliases, |
33 |
| - value, |
| 29 | + |
34 | 30 | experimentalFeature,
|
| 31 | + |
| 32 | + # Whether we document the default, because it is machine agostic, |
| 33 | + # or don't because because it is machine-specific. |
| 34 | + documentDefault ? true, |
| 35 | + |
| 36 | + # The default value is JSON for new-style config, rather than then |
| 37 | + # a string or boolean, for old-style config. |
| 38 | + isJson ? false, |
| 39 | + |
| 40 | + defaultValue ? null, |
| 41 | + |
| 42 | + subSettings ? null, |
| 43 | + |
| 44 | + aliases ? [ ], |
| 45 | + |
| 46 | + # The current value for this setting. Purposefully unused. |
| 47 | + value ? null, |
35 | 48 | }:
|
36 | 49 | let
|
37 | 50 | result = squash ''
|
|
50 | 63 |
|
51 | 64 | ${description}
|
52 | 65 |
|
53 |
| - **Default:** ${showDefault documentDefault defaultValue} |
| 66 | + ${showDefaultOrSubSettings} |
54 | 67 |
|
55 | 68 | ${showAliases aliases}
|
56 | 69 | '';
|
|
72 | 85 | > ```
|
73 | 86 | '';
|
74 | 87 |
|
| 88 | + showDefaultOrSubSettings = |
| 89 | + if !isAttrs subSettings then |
| 90 | + # No subsettings, instead single setting. Show the default value. |
| 91 | + '' |
| 92 | + **Default:** ${showDefault} |
| 93 | + '' |
| 94 | + else |
| 95 | + # Indent the nested sub-settings, and append the outer setting name onto the prefix |
| 96 | + indent " " '' |
| 97 | + **Nullable sub-settings**: ${if subSettings.nullable then "true" else "false"} |
| 98 | + ${builtins.trace prefix (showSettings "${prefix}-${setting}" subSettings.map)} |
| 99 | + ''; |
| 100 | + |
75 | 101 | showDefault =
|
76 |
| - documentDefault: defaultValue: |
77 | 102 | if documentDefault then
|
| 103 | + if isJson then |
| 104 | + "`${builtins.toJSON defaultValue}`" |
| 105 | + else |
78 | 106 | # a StringMap value type is specified as a string, but
|
79 | 107 | # this shows the value type. The empty stringmap is `null` in
|
80 | 108 | # JSON, but that converts to `{ }` here.
|
|
95 | 123 | in
|
96 | 124 | result;
|
97 | 125 |
|
| 126 | + showSettings = |
| 127 | + prefix: settingsInfo: concatStrings (attrValues (mapAttrs (showSetting prefix) settingsInfo)); |
98 | 128 | in
|
99 |
| -concatStrings (attrValues (mapAttrs (showSetting prefix) settingsInfo)) |
| 129 | +showSettings prefix |
0 commit comments