Unverified Commit 6259b29f authored by Robert Hensing's avatar Robert Hensing Committed by GitHub
Browse files

Merge pull request #194035 from Ma27/show-option-quoting

lib/options/showOption: fix quoting of attr-names that are not identifiers
parents 46e516e4 2480532b
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -322,10 +322,16 @@ rec {
  showOption = parts: let
    escapeOptionPart = part:
      let
        escaped = lib.strings.escapeNixString part;
      in if escaped == "\"${part}\""
        # We assume that these are "special values" and not real configuration data.
        # 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
         else escaped;
         else lib.strings.escapeNixIdentifier part;
    in (concatStringsSep ".") (map escapeOptionPart parts);
  showFiles = files: concatStringsSep " and " (map (f: "`${f}'") files);

+2 −2
Original line number Diff line number Diff line
@@ -302,11 +302,11 @@ checkConfigOutput '^"baz"$' config.value.nested.bar.baz ./types-anything/mk-mods
## types.functionTo
checkConfigOutput '^"input is input"$' config.result ./functionTo/trivial.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 '^"a c"$' config.result ./functionTo/merging-attrs.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
checkConfigOutput '^"a b"$' config.resultFoo ./declare-variants.nix ./define-variant.nix
+2 −2
Original line number Diff line number Diff line
@@ -617,8 +617,8 @@ rec {
      descriptionClass = "composite";
      check = isFunction;
      merge = loc: defs:
        fnArgs: (mergeDefinitions (loc ++ [ "[function body]" ]) elemType (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs)).mergedValue;
      getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "[function body]" ]);
        fnArgs: (mergeDefinitions (loc ++ [ "<function body>" ]) elemType (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs)).mergedValue;
      getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "<function body>" ]);
      getSubModules = elemType.getSubModules;
      substSubModules = m: functionTo (elemType.substSubModules m);
      functor = (defaultFunctor "functionTo") // { wrapped = elemType; };
+2 −2
Original line number Diff line number Diff line
@@ -40,8 +40,8 @@
            concat($optionIdPrefix,
              translate(
                attr[@name = 'name']/string/@value,
                '*&lt; >[]:',
                '_______'
                '*&lt; >[]:&quot;',
                '________'
            ))" />
          <varlistentry>
            <term xlink:href="#{$id}">