make-options-doc: Filter options after transformOptions

This allows the user-supplied function to change the visibility
of options.
This commit is contained in:
Robert Hensing 2022-05-25 12:49:26 +02:00
parent 90df13c161
commit 75bc6da237

View file

@ -47,8 +47,11 @@ let
else if lib.isFunction x then "<function>"
else x;
optionsList = lib.flip map optionsListVisible
(opt: transformOptions opt
rawOpts = lib.optionAttrSetToDocList options;
transformedOpts = map transformOptions rawOpts;
filteredOpts = lib.filter (opt: opt.visible && !opt.internal) transformedOpts;
optionsList = lib.flip map filteredOpts
(opt: opt
// lib.optionalAttrs (opt ? example) { example = substSpecial opt.example; }
// lib.optionalAttrs (opt ? default) { default = substSpecial opt.default; }
// lib.optionalAttrs (opt ? type) { type = substSpecial opt.type; }
@ -90,9 +93,6 @@ let
'';
in "<itemizedlist>${lib.concatStringsSep "\n" (map (p: describe (unpack p)) packages)}</itemizedlist>";
# Remove invisible and internal options.
optionsListVisible = lib.filter (opt: opt.visible && !opt.internal) (lib.optionAttrSetToDocList options);
optionsNix = builtins.listToAttrs (map (o: { name = o.name; value = removeAttrs o ["name" "visible" "internal"]; }) optionsList);
in rec {