mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nix/lib/make-options-doc: remove nix-level sorting
there are no remaining users of sorted option lists except the docbook build, which sorts its input separately.
This commit is contained in:
parent
c533b01863
commit
9b97a2ea88
2 changed files with 2 additions and 17 deletions
|
@ -31,7 +31,7 @@ let
|
||||||
else if lib.isFunction x then "<function>"
|
else if lib.isFunction x then "<function>"
|
||||||
else x;
|
else x;
|
||||||
|
|
||||||
optionsListDesc = lib.flip map optionsListVisible
|
optionsList = lib.flip map optionsListVisible
|
||||||
(opt: transformOptions opt
|
(opt: transformOptions opt
|
||||||
// lib.optionalAttrs (opt ? example) { example = substFunction opt.example; }
|
// lib.optionalAttrs (opt ? example) { example = substFunction opt.example; }
|
||||||
// lib.optionalAttrs (opt ? default) { default = substFunction opt.default; }
|
// lib.optionalAttrs (opt ? default) { default = substFunction opt.default; }
|
||||||
|
@ -69,27 +69,13 @@ let
|
||||||
+ "</listitem>";
|
+ "</listitem>";
|
||||||
in "<itemizedlist>${lib.concatStringsSep "\n" (map (p: describe (unpack p)) packages)}</itemizedlist>";
|
in "<itemizedlist>${lib.concatStringsSep "\n" (map (p: describe (unpack p)) packages)}</itemizedlist>";
|
||||||
|
|
||||||
# Custom "less" that pushes up all the things ending in ".enable*"
|
|
||||||
# and ".package*"
|
|
||||||
optionLess = a: b:
|
|
||||||
let
|
|
||||||
ise = lib.hasPrefix "enable";
|
|
||||||
isp = lib.hasPrefix "package";
|
|
||||||
cmp = lib.splitByAndCompare ise lib.compare
|
|
||||||
(lib.splitByAndCompare isp lib.compare lib.compare);
|
|
||||||
in lib.compareLists cmp a.loc b.loc < 0;
|
|
||||||
|
|
||||||
# Remove invisible and internal options.
|
# Remove invisible and internal options.
|
||||||
optionsListVisible = lib.filter (opt: opt.visible && !opt.internal) (lib.optionAttrSetToDocList options);
|
optionsListVisible = lib.filter (opt: opt.visible && !opt.internal) (lib.optionAttrSetToDocList options);
|
||||||
|
|
||||||
# Customly sort option list for the man page.
|
|
||||||
# Always ensure that the sort order matches sortXML.py!
|
|
||||||
optionsList = lib.sort optionLess optionsListDesc;
|
|
||||||
|
|
||||||
# Convert the list of options into an XML file.
|
# Convert the list of options into an XML file.
|
||||||
# This file is *not* sorted sorted to save on eval time, since the docbook XML
|
# This file is *not* sorted sorted to save on eval time, since the docbook XML
|
||||||
# and the manpage depend on it and thus we evaluate this on every system rebuild.
|
# and the manpage depend on it and thus we evaluate this on every system rebuild.
|
||||||
optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsListDesc);
|
optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList);
|
||||||
|
|
||||||
optionsNix = builtins.listToAttrs (map (o: { name = o.name; value = removeAttrs o ["name" "visible" "internal"]; }) optionsList);
|
optionsNix = builtins.listToAttrs (map (o: { name = o.name; value = removeAttrs o ["name" "visible" "internal"]; }) optionsList);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ def sortKey(opt):
|
||||||
for p in opt.findall('attr[@name="loc"]/list/string')
|
for p in opt.findall('attr[@name="loc"]/list/string')
|
||||||
]
|
]
|
||||||
|
|
||||||
# always ensure that the sort order matches the order used in the nix expression!
|
|
||||||
options.sort(key=sortKey)
|
options.sort(key=sortKey)
|
||||||
|
|
||||||
doc = ET.Element("expr")
|
doc = ET.Element("expr")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue