git.iko.soy/typeable/nixpkgs
on master help sign in
make-options-doc: add asciidoc variant
commit6cf861c617d6a0a98129bf6c4d54874ff714636b authorDomen Kožar <domen@dev.si> dateSat 10 Aug 2019, 20:07 (7 years ago) parent3a93fcf
1 file changed+38
nixos/lib/make-options-doc/default.nix+38
nixos/lib/make-options-doc/default.nix+38
@@ -90,9 +90,47 @@ let
9090
9191 optionsNix = builtins.listToAttrs (map (o: { name = o.name; value = removeAttrs o ["name" "visible" "internal"]; }) optionsList);
9292
93+ # TODO: declarations: link to github
94+ singleAsciiDoc = name: value: ''
95+ == ${name}
96+
97+ ${value.description}
98+
99+ [discrete]
100+ === details
101+
102+ Type:: ${value.type}
103+ ${ if pkgs.lib.hasAttr "default" value
104+ then ''
105+ Default::
106+ +
107+ ----
108+ ${builtins.toJSON value.default}
109+ ----
110+ ''
111+ else "No Default:: {blank}"
112+ }
113+ ${ if value.readOnly
114+ then "Read Only:: {blank}"
115+ else ""
116+ }
117+ ${ if pkgs.lib.hasAttr "example" value
118+ then ''
119+ Example::
120+ +
121+ ----
122+ ${builtins.toJSON value.example}
123+ ----
124+ ''
125+ else "No Example:: {blank}"
126+ }
127+ '';
128+
93129in rec {
94130 inherit optionsNix;
95131
132+ optionsAsciiDoc = pkgs.lib.concatStringsSep "\n" (pkgs.lib.mapAttrsToList singleAsciiDoc optionsNix);
133+
96134 optionsJSON = pkgs.runCommand "options.json"
97135 { meta.description = "List of NixOS options in JSON format";
98136 }