aboutsummaryrefslogtreecommitdiff
path: root/lib/options.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-28 14:25:58 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-28 22:45:56 +0100
commit89bd18b3affc6612ad6402c05cc4d80a59efe9b8 (patch)
tree14a313a7bd2d405668f737754756c503bf93a2b2 /lib/options.nix
parent7cf0e0bda87a1b71aac70d4eaf04aceda3dc3188 (diff)
Fix manual generation
Diffstat (limited to 'lib/options.nix')
-rw-r--r--lib/options.nix48
1 files changed, 23 insertions, 25 deletions
diff --git a/lib/options.nix b/lib/options.nix
index d94a9fad3888..480837fd1cf1 100644
--- a/lib/options.nix
+++ b/lib/options.nix
@@ -87,31 +87,28 @@ rec {
# Generate documentation template from the list of option declaration like
# the set generated with filterOptionSets.
- optionAttrSetToDocList = attrs:
- let options = collect isOption attrs; in
- fold (opt: rest:
- let
- docOption = {
- inherit (opt) name;
- description = opt.description or (throw "Option ${opt.name}: No description.");
- declarations = map (x: toString x.source) opt.declarations;
- #definitions = map (x: toString x.source) opt.definitions;
- internal = opt.internal or false;
- visible = opt.visible or true;
- }
- // optionalAttrs (opt ? example) { example = scrubOptionValue opt.example; }
- // optionalAttrs (opt ? default) { default = scrubOptionValue opt.default; }
- // optionalAttrs (opt ? defaultText) { default = opt.defaultText; };
-
- subOptions =
- if opt ? options then
- optionAttrSetToDocList opt.options
- else
- [];
- in
- # FIXME: expensive (O(n^2)
- [ docOption ] ++ subOptions ++ rest
- ) [] options;
+ optionAttrSetToDocList = optionAttrSetToDocList' [];
+
+ optionAttrSetToDocList' = prefix: options:
+ fold (opt: rest:
+ let
+ docOption = rec {
+ name = showOption opt.loc;
+ description = opt.description or (throw "Option `${name}' has no description.");
+ declarations = filter (x: x != unknownModule) opt.declarations;
+ internal = opt.internal or false;
+ visible = opt.visible or true;
+ }
+ // optionalAttrs (opt ? example) { example = scrubOptionValue opt.example; }
+ // optionalAttrs (opt ? default) { default = scrubOptionValue opt.default; }
+ // optionalAttrs (opt ? defaultText) { default = opt.defaultText; };
+
+ subOptions =
+ let ss = opt.type.getSubOptions opt.loc;
+ in if ss != {} then optionAttrSetToDocList' opt.loc ss else [];
+ in
+ # FIXME: expensive, O(n^2)
+ [ docOption ] ++ subOptions ++ rest) [] (collect isOption options);
/* This function recursively removes all derivation attributes from
@@ -135,5 +132,6 @@ rec {
/* Helper functions. */
showOption = concatStringsSep ".";
+ unknownModule = "<unknown-file>";
}