mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
lib.modules: Add error context to rendered default and example attrs
This commit is contained in:
parent
1dba7adaf3
commit
5fb20d2f8c
1 changed files with 14 additions and 3 deletions
|
@ -221,9 +221,10 @@ rec {
|
||||||
optionAttrSetToDocList' = _: options:
|
optionAttrSetToDocList' = _: options:
|
||||||
concatMap (opt:
|
concatMap (opt:
|
||||||
let
|
let
|
||||||
|
name = showOption opt.loc;
|
||||||
docOption = rec {
|
docOption = rec {
|
||||||
loc = opt.loc;
|
loc = opt.loc;
|
||||||
name = showOption opt.loc;
|
inherit name;
|
||||||
description = opt.description or null;
|
description = opt.description or null;
|
||||||
declarations = filter (x: x != unknownModule) opt.declarations;
|
declarations = filter (x: x != unknownModule) opt.declarations;
|
||||||
internal = opt.internal or false;
|
internal = opt.internal or false;
|
||||||
|
@ -234,8 +235,18 @@ rec {
|
||||||
readOnly = opt.readOnly or false;
|
readOnly = opt.readOnly or false;
|
||||||
type = opt.type.description or "unspecified";
|
type = opt.type.description or "unspecified";
|
||||||
}
|
}
|
||||||
// optionalAttrs (opt ? example) { example = renderOptionValue opt.example; }
|
// optionalAttrs (opt ? example) {
|
||||||
// optionalAttrs (opt ? default) { default = renderOptionValue (opt.defaultText or opt.default); }
|
example =
|
||||||
|
builtins.addErrorContext "while evaluating the example of option `${name}`" (
|
||||||
|
renderOptionValue opt.example
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// optionalAttrs (opt ? default) {
|
||||||
|
default =
|
||||||
|
builtins.addErrorContext "while evaluating the default value of option `${name}`" (
|
||||||
|
renderOptionValue (opt.defaultText or opt.default)
|
||||||
|
);
|
||||||
|
}
|
||||||
// optionalAttrs (opt ? relatedPackages && opt.relatedPackages != null) { inherit (opt) relatedPackages; };
|
// optionalAttrs (opt ? relatedPackages && opt.relatedPackages != null) { inherit (opt) relatedPackages; };
|
||||||
|
|
||||||
subOptions =
|
subOptions =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue