Merge pull request #119277 from Pacman99/md-options

nixosOptionsDoc: add markdown formatting
This commit is contained in:
Domen Kožar 2021-04-13 19:13:09 +02:00 committed by GitHub
commit 6f7f5bacc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,11 +126,37 @@ let
}
'';
singleMDDoc = name: value: ''
## ${lib.escape [ "<" ">" ] name}
${value.description}
${lib.optionalString (value ? type) ''
*_Type_*:
${value.type}
''}
${lib.optionalString (value ? default) ''
*_Default_*
```
${builtins.toJSON value.default}
```
''}
${lib.optionalString (value ? example) ''
*_Example_*
```
${builtins.toJSON value.example}
```
''}
'';
in {
inherit optionsNix;
optionsAsciiDoc = lib.concatStringsSep "\n" (lib.mapAttrsToList singleAsciiDoc optionsNix);
optionsMDDoc = lib.concatStringsSep "\n" (lib.mapAttrsToList singleMDDoc optionsNix);
optionsJSON = pkgs.runCommand "options.json"
{ meta.description = "List of NixOS options in JSON format";
buildInputs = [ pkgs.brotli ];