diff options
author | Pacman99 | 2021-04-12 18:08:12 -0700 |
---|---|---|
committer | Pacman99 | 2021-04-13 10:10:40 -0700 |
commit | d12aba540657704a2b08ec8a1b953d9425dfe201 (patch) | |
tree | 98cd3426007253eaf3b853180f379d866084cce6 /nixos/lib | |
parent | 7289645071256c0026644dcdf0df759340b0bd77 (diff) |
nixosOptionsDoc: add markdown formatting
Diffstat (limited to 'nixos/lib')
-rw-r--r-- | nixos/lib/make-options-doc/default.nix | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/nixos/lib/make-options-doc/default.nix b/nixos/lib/make-options-doc/default.nix index a1161621f0d4..14015ab64abb 100644 --- a/nixos/lib/make-options-doc/default.nix +++ b/nixos/lib/make-options-doc/default.nix @@ -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 ]; |