Merge pull request #194035 from Ma27/show-option-quoting
lib/options/showOption: fix quoting of attr-names that are not identifiers
This commit is contained in:
commit
6259b29f29
4 changed files with 15 additions and 9 deletions
|
@ -322,10 +322,16 @@ rec {
|
||||||
showOption = parts: let
|
showOption = parts: let
|
||||||
escapeOptionPart = part:
|
escapeOptionPart = part:
|
||||||
let
|
let
|
||||||
escaped = lib.strings.escapeNixString part;
|
# We assume that these are "special values" and not real configuration data.
|
||||||
in if escaped == "\"${part}\""
|
# If it is real configuration data, it is rendered incorrectly.
|
||||||
|
specialIdentifiers = [
|
||||||
|
"<name>" # attrsOf (submodule {})
|
||||||
|
"*" # listOf (submodule {})
|
||||||
|
"<function body>" # functionTo
|
||||||
|
];
|
||||||
|
in if builtins.elem part specialIdentifiers
|
||||||
then part
|
then part
|
||||||
else escaped;
|
else lib.strings.escapeNixIdentifier part;
|
||||||
in (concatStringsSep ".") (map escapeOptionPart parts);
|
in (concatStringsSep ".") (map escapeOptionPart parts);
|
||||||
showFiles = files: concatStringsSep " and " (map (f: "`${f}'") files);
|
showFiles = files: concatStringsSep " and " (map (f: "`${f}'") files);
|
||||||
|
|
||||||
|
|
|
@ -302,11 +302,11 @@ checkConfigOutput '^"baz"$' config.value.nested.bar.baz ./types-anything/mk-mods
|
||||||
## types.functionTo
|
## types.functionTo
|
||||||
checkConfigOutput '^"input is input"$' config.result ./functionTo/trivial.nix
|
checkConfigOutput '^"input is input"$' config.result ./functionTo/trivial.nix
|
||||||
checkConfigOutput '^"a b"$' config.result ./functionTo/merging-list.nix
|
checkConfigOutput '^"a b"$' config.result ./functionTo/merging-list.nix
|
||||||
checkConfigError 'A definition for option .fun.\[function body\]. is not of type .string.. Definition values:\n\s*- In .*wrong-type.nix' config.result ./functionTo/wrong-type.nix
|
checkConfigError 'A definition for option .fun.<function body>. is not of type .string.. Definition values:\n\s*- In .*wrong-type.nix' config.result ./functionTo/wrong-type.nix
|
||||||
checkConfigOutput '^"b a"$' config.result ./functionTo/list-order.nix
|
checkConfigOutput '^"b a"$' config.result ./functionTo/list-order.nix
|
||||||
checkConfigOutput '^"a c"$' config.result ./functionTo/merging-attrs.nix
|
checkConfigOutput '^"a c"$' config.result ./functionTo/merging-attrs.nix
|
||||||
checkConfigOutput '^"a bee"$' config.result ./functionTo/submodule-options.nix
|
checkConfigOutput '^"a bee"$' config.result ./functionTo/submodule-options.nix
|
||||||
checkConfigOutput '^"fun.\[function body\].a fun.\[function body\].b"$' config.optionsResult ./functionTo/submodule-options.nix
|
checkConfigOutput '^"fun.<function body>.a fun.<function body>.b"$' config.optionsResult ./functionTo/submodule-options.nix
|
||||||
|
|
||||||
# moduleType
|
# moduleType
|
||||||
checkConfigOutput '^"a b"$' config.resultFoo ./declare-variants.nix ./define-variant.nix
|
checkConfigOutput '^"a b"$' config.resultFoo ./declare-variants.nix ./define-variant.nix
|
||||||
|
|
|
@ -617,8 +617,8 @@ rec {
|
||||||
descriptionClass = "composite";
|
descriptionClass = "composite";
|
||||||
check = isFunction;
|
check = isFunction;
|
||||||
merge = loc: defs:
|
merge = loc: defs:
|
||||||
fnArgs: (mergeDefinitions (loc ++ [ "[function body]" ]) elemType (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs)).mergedValue;
|
fnArgs: (mergeDefinitions (loc ++ [ "<function body>" ]) elemType (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs)).mergedValue;
|
||||||
getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "[function body]" ]);
|
getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "<function body>" ]);
|
||||||
getSubModules = elemType.getSubModules;
|
getSubModules = elemType.getSubModules;
|
||||||
substSubModules = m: functionTo (elemType.substSubModules m);
|
substSubModules = m: functionTo (elemType.substSubModules m);
|
||||||
functor = (defaultFunctor "functionTo") // { wrapped = elemType; };
|
functor = (defaultFunctor "functionTo") // { wrapped = elemType; };
|
||||||
|
|
|
@ -40,8 +40,8 @@
|
||||||
concat($optionIdPrefix,
|
concat($optionIdPrefix,
|
||||||
translate(
|
translate(
|
||||||
attr[@name = 'name']/string/@value,
|
attr[@name = 'name']/string/@value,
|
||||||
'*< >[]:',
|
'*< >[]:"',
|
||||||
'_______'
|
'________'
|
||||||
))" />
|
))" />
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term xlink:href="#{$id}">
|
<term xlink:href="#{$id}">
|
||||||
|
|
Loading…
Reference in a new issue