mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-30 22:21:26 +00:00
Merge pull request #97042 from Infinisil/freeform-option-docs
Show sub options of freeform types
This commit is contained in:
commit
f73b762aac
@ -542,4 +542,30 @@ runTests {
|
||||
name = "";
|
||||
expected = "unknown";
|
||||
};
|
||||
|
||||
testFreeformOptions = {
|
||||
expr =
|
||||
let
|
||||
submodule = { lib, ... }: {
|
||||
freeformType = lib.types.attrsOf (lib.types.submodule {
|
||||
options.bar = lib.mkOption {};
|
||||
});
|
||||
options.bar = lib.mkOption {};
|
||||
};
|
||||
|
||||
module = { lib, ... }: {
|
||||
options.foo = lib.mkOption {
|
||||
type = lib.types.submodule submodule;
|
||||
};
|
||||
};
|
||||
|
||||
options = (evalModules {
|
||||
modules = [ module ];
|
||||
}).options;
|
||||
|
||||
locs = filter (o: ! o.internal) (optionAttrSetToDocList options);
|
||||
in map (o: o.loc) locs;
|
||||
expected = [ [ "foo" ] [ "foo" "<name>" "bar" ] [ "foo" "bar" ] ];
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -427,7 +427,12 @@ rec {
|
||||
# would be used, and use of `<` and `>` would break the XML document.
|
||||
# It shouldn't cause an issue since this is cosmetic for the manual.
|
||||
args.name = "‹name›";
|
||||
}).options;
|
||||
}).options // optionalAttrs (freeformType != null) {
|
||||
# Expose the sub options of the freeform type. Note that the option
|
||||
# discovery doesn't care about the attribute name used here, so this
|
||||
# is just to avoid conflicts with potential options from the submodule
|
||||
_freeformOptions = freeformType.getSubOptions prefix;
|
||||
};
|
||||
getSubModules = modules;
|
||||
substSubModules = m: submoduleWith (attrs // {
|
||||
modules = m;
|
||||
|
Loading…
Reference in New Issue
Block a user