-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
always show anchors on setting listings
refactor the templates for readability
- Loading branch information
1 parent
9428d7d
commit c5b4959
Showing
5 changed files
with
124 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
let | ||
inherit (builtins) attrValues concatStringsSep isAttrs isBool mapAttrs; | ||
inherit (import ./utils.nix) concatStrings indent optionalString squash; | ||
in | ||
|
||
prefix: settingsInfo: | ||
|
||
let | ||
|
||
showSetting = prefix: setting: { description, documentDefault, defaultValue, aliases, value, experimentalFeature }: | ||
let | ||
result = squash '' | ||
- <span id="${prefix}-${setting}">[`${setting}`](#${prefix}-${setting})</span> | ||
${indent " " body} | ||
''; | ||
|
||
# separate body to cleanly handle indentation | ||
body = '' | ||
${description} | ||
${experimentalFeatureNote} | ||
**Default:** ${showDefault documentDefault defaultValue} | ||
${showAliases aliases} | ||
''; | ||
|
||
experimentalFeatureNote = optionalString (experimentalFeature != null) '' | ||
> **Warning** | ||
> This setting is part of an | ||
> [experimental feature](@docroot@/contributing/experimental-features.md). | ||
To change this setting, you need to make sure the corresponding experimental feature, | ||
[`${experimentalFeature}`](@docroot@/contributing/experimental-features.md#xp-feature-${experimentalFeature}), | ||
is enabled. | ||
For example, include the following in [`nix.conf`](#): | ||
``` | ||
extra-experimental-features = ${experimentalFeature} | ||
${setting} = ... | ||
``` | ||
''; | ||
|
||
showDefault = documentDefault: defaultValue: | ||
if documentDefault then | ||
# a StringMap value type is specified as a string, but | ||
# this shows the value type. The empty stringmap is `null` in | ||
# JSON, but that converts to `{ }` here. | ||
if defaultValue == "" || defaultValue == [] || isAttrs defaultValue | ||
then "*empty*" | ||
else if isBool defaultValue then | ||
if defaultValue then "`true`" else "`false`" | ||
else "`${toString defaultValue}`" | ||
else "*machine-specific*"; | ||
|
||
showAliases = aliases: | ||
optionalString (aliases != []) | ||
"**Deprecated alias:** ${(concatStringsSep ", " (map (s: "`${s}`") aliases))}"; | ||
|
||
in result; | ||
|
||
in concatStrings (attrValues (mapAttrs (showSetting prefix) settingsInfo)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
let | ||
inherit (builtins) attrValues mapAttrs; | ||
inherit (import ./utils.nix) concatStrings optionalString; | ||
showSettings = import ./generate-settings.nix; | ||
in | ||
|
||
storesInfo: | ||
|
||
let | ||
|
||
showStore = name: { settings, doc, experimentalFeature }: | ||
let | ||
|
||
result = '' | ||
## ${name} | ||
${doc} | ||
${experimentalFeatureNote} | ||
### Settings | ||
${showSettings "store-${slug}" settings} | ||
''; | ||
|
||
# markdown doesn't like spaces in URLs | ||
slug = builtins.replaceStrings [ " " ] [ "-" ] name; | ||
|
||
experimentalFeatureNote = optionalString (experimentalFeature != null) '' | ||
> **Warning** | ||
> This store is part of an | ||
> [experimental feature](@docroot@/contributing/experimental-features.md). | ||
To use this store, you need to make sure the corresponding experimental feature, | ||
[`${experimentalFeature}`](@docroot@/contributing/experimental-features.md#xp-feature-${experimentalFeature}), | ||
is enabled. | ||
For example, include the following in [`nix.conf`](#): | ||
``` | ||
extra-experimental-features = ${experimentalFeature} | ||
``` | ||
''; | ||
in result; | ||
|
||
in concatStrings (attrValues (mapAttrs showStore storesInfo)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters