lib/*: fix docs to use "returns" instead of "return" (#442388)

This commit is contained in:
Johannes Kirschbauer
2025-10-06 08:09:54 +00:00
committed by GitHub
10 changed files with 35 additions and 35 deletions

View File

@@ -44,7 +44,7 @@ rec {
; ;
/** /**
Return an attribute from nested attribute sets. Returns an attribute from nested attribute sets.
Nix has an [attribute selection operator `.`](https://nixos.org/manual/nix/stable/language/operators#attribute-selection) which is sufficient for such queries, as long as the number of attributes is static. For example: Nix has an [attribute selection operator `.`](https://nixos.org/manual/nix/stable/language/operators#attribute-selection) which is sufficient for such queries, as long as the number of attributes is static. For example:
@@ -111,7 +111,7 @@ rec {
attrByPath' 0 set; attrByPath' 0 set;
/** /**
Return if an attribute from nested attribute set exists. Returns if an attribute from nested attribute set exists.
Nix has a [has attribute operator `?`](https://nixos.org/manual/nix/stable/language/operators#has-attribute), which is sufficient for such queries, as long as the number of attributes is static. For example: Nix has a [has attribute operator `?`](https://nixos.org/manual/nix/stable/language/operators#has-attribute), which is sufficient for such queries, as long as the number of attributes is static. For example:
@@ -177,7 +177,7 @@ rec {
hasAttrByPath' 0 e; hasAttrByPath' 0 e;
/** /**
Return the longest prefix of an attribute path that refers to an existing attribute in a nesting of attribute sets. Returns the longest prefix of an attribute path that refers to an existing attribute in a nesting of attribute sets.
Can be used after [`mapAttrsRecursiveCond`](#function-library-lib.attrsets.mapAttrsRecursiveCond) to apply a condition, Can be used after [`mapAttrsRecursiveCond`](#function-library-lib.attrsets.mapAttrsRecursiveCond) to apply a condition,
although this will evaluate the predicate function on sibling attributes as well. although this will evaluate the predicate function on sibling attributes as well.
@@ -504,7 +504,7 @@ rec {
updates: value: go 0 true value updates; updates: value: go 0 true value updates;
/** /**
Return the specified attributes from a set. Returns the specified attributes from a set.
# Inputs # Inputs
@@ -536,7 +536,7 @@ rec {
attrVals = nameList: set: map (x: set.${x}) nameList; attrVals = nameList: set: map (x: set.${x}) nameList;
/** /**
Return the values of all attributes in the given set, sorted by Returns the values of all attributes in the given set, sorted by
attribute name. attribute name.
# Type # Type

View File

@@ -73,7 +73,7 @@ let
name: default: attrs: name: default: attrs:
attrs.${name} or default; attrs.${name} or default;
# Return the second argument if the first one is true or the empty version # Returns the second argument if the first one is true or the empty version
# of the second argument. # of the second argument.
ifEnable = ifEnable =
cond: val: cond: val:
@@ -89,7 +89,7 @@ let
else else
null; null;
# Return true only if there is an attribute and it is true. # Returns true only if there is an attribute and it is true.
checkFlag = checkFlag =
attrSet: name: attrSet: name:
if name == "true" then if name == "true" then

View File

@@ -119,7 +119,7 @@ rec {
x; x;
/** /**
Return the fixpoint that `f` converges to when called iteratively, starting Returns the fixpoint that `f` converges to when called iteratively, starting
with the input `x`. with the input `x`.
``` ```

View File

@@ -642,7 +642,7 @@ rec {
if index == null then default else elemAt list index; if index == null then default else elemAt list index;
/** /**
Return true if function `pred` returns true for at least one Returns true if function `pred` returns true for at least one
element of `list`. element of `list`.
# Inputs # Inputs
@@ -677,7 +677,7 @@ rec {
any = builtins.any; any = builtins.any;
/** /**
Return true if function `pred` returns true for all elements of Returns true if function `pred` returns true for all elements of
`list`. `list`.
# Inputs # Inputs
@@ -777,7 +777,7 @@ rec {
optional = cond: elem: if cond then [ elem ] else [ ]; optional = cond: elem: if cond then [ elem ] else [ ];
/** /**
Return a list or an empty list, depending on a boolean value. Returns a list or an empty list, depending on a boolean value.
# Inputs # Inputs
@@ -837,7 +837,7 @@ rec {
toList = x: if isList x then x else [ x ]; toList = x: if isList x then x else [ x ];
/** /**
Return a list of integers from `first` up to and including `last`. Returns a list of integers from `first` up to and including `last`.
# Inputs # Inputs
@@ -871,7 +871,7 @@ rec {
range = first: last: if first > last then [ ] else genList (n: first + n) (last - first + 1); range = first: last: if first > last then [ ] else genList (n: first + n) (last - first + 1);
/** /**
Return a list with `n` copies of an element. Returns a list with `n` copies of an element.
# Inputs # Inputs
@@ -1429,7 +1429,7 @@ rec {
map (x: elemAt x 1) (sort less prepared); map (x: elemAt x 1) (sort less prepared);
/** /**
Return the first (at most) N elements of a list. Returns the first (at most) N elements of a list.
# Inputs # Inputs
@@ -1463,7 +1463,7 @@ rec {
take = count: sublist 0 count; take = count: sublist 0 count;
/** /**
Return the last (at most) N elements of a list. Returns the last (at most) N elements of a list.
# Inputs # Inputs
@@ -1639,7 +1639,7 @@ rec {
throw "lib.lists.removePrefix: First argument is not a list prefix of the second argument"; throw "lib.lists.removePrefix: First argument is not a list prefix of the second argument";
/** /**
Return a list consisting of at most `count` elements of `list`, Returns a list consisting of at most `count` elements of `list`,
starting at index `start`. starting at index `start`.
# Inputs # Inputs
@@ -1737,7 +1737,7 @@ rec {
take commonPrefixLength list1; take commonPrefixLength list1;
/** /**
Return the last element of a list. Returns the last element of a list.
This function throws an error if the list is empty. This function throws an error if the list is empty.
@@ -1770,7 +1770,7 @@ rec {
elemAt list (length list - 1); elemAt list (length list - 1);
/** /**
Return all elements but the last. Returns all elements but the last.
This function throws an error if the list is empty. This function throws an error if the list is empty.
@@ -1803,7 +1803,7 @@ rec {
take (length list - 1) list; take (length list - 1) list;
/** /**
Return the image of the cross product of some lists by a function. Returns the image of the cross product of some lists by a function.
# Examples # Examples
:::{.example} :::{.example}

View File

@@ -1452,7 +1452,7 @@ let
}; };
/** /**
Return a definition with file location information. Returns a definition with file location information.
*/ */
mkDefinition = args@{ file, value, ... }: args // { _type = "definition"; }; mkDefinition = args@{ file, value, ... }: args // { _type = "definition"; };
@@ -1541,7 +1541,7 @@ let
}; };
/** /**
Return a module that causes a warning to be shown if the Returns a module that causes a warning to be shown if the
specified option is defined. For example, specified option is defined. For example,
mkRemovedOptionModule [ "boot" "loader" "grub" "bootDevice" ] "<replacement instructions>" mkRemovedOptionModule [ "boot" "loader" "grub" "bootDevice" ] "<replacement instructions>"
@@ -1589,7 +1589,7 @@ let
}; };
/** /**
Return a module that causes a warning to be shown if the Returns a module that causes a warning to be shown if the
specified "from" option is defined; the defined value is however specified "from" option is defined; the defined value is however
forwarded to the "to" option. This can be used to rename options forwarded to the "to" option. This can be used to rename options
while providing backward compatibility. For example, while providing backward compatibility. For example,
@@ -1645,7 +1645,7 @@ let
}; };
/** /**
Return a module that causes a warning to be shown if any of the "from" Returns a module that causes a warning to be shown if any of the "from"
option is defined; the defined values can be used in the "mergeFn" to set option is defined; the defined values can be used in the "mergeFn" to set
the "to" value. the "to" value.
This function can be used to merge multiple options into one that has a This function can be used to merge multiple options into one that has a
@@ -1724,7 +1724,7 @@ let
/** /**
Single "from" version of mkMergedOptionModule. Single "from" version of mkMergedOptionModule.
Return a module that causes a warning to be shown if the "from" option is Returns a module that causes a warning to be shown if the "from" option is
defined; the defined value can be used in the "mergeFn" to set the "to" defined; the defined value can be used in the "mergeFn" to set the "to"
value. value.
This function can be used to change an option into another that has a This function can be used to change an option into another that has a
@@ -1822,7 +1822,7 @@ let
mkDerivedConfig = opt: f: mkOverride (opt.highestPrio or defaultOverridePriority) (f opt.value); mkDerivedConfig = opt: f: mkOverride (opt.highestPrio or defaultOverridePriority) (f opt.value);
/** /**
Return a module that help declares an option that has been renamed. Returns a module that help declares an option that has been renamed.
When a value is defined for the old option, it is forwarded to the `to` option. When a value is defined for the old option, it is forwarded to the `to` option.
*/ */
doRename = doRename =

View File

@@ -503,7 +503,7 @@ rec {
loc: defs: loc: defs:
if defs == [ ] then if defs == [ ] then
abort "This case should never happen." abort "This case should never happen."
# Return early if we only have one element # Returns early if we only have one element
# This also makes it work for functions, because the foldl' below would try # This also makes it work for functions, because the foldl' below would try
# to compare the first element with itself, which is false for functions # to compare the first element with itself, which is false for functions
else if length defs == 1 then else if length defs == 1 then

View File

@@ -40,7 +40,7 @@ let
isValid isValid
; ;
# Return the reason why a subpath is invalid, or `null` if it's valid # Returns the reason why a subpath is invalid, or `null` if it's valid
subpathInvalidReason = subpathInvalidReason =
value: value:
if !isString value then if !isString value then

View File

@@ -1806,7 +1806,7 @@ rec {
if len == 0 then [ (addContextFrom str "") ] else map (addContextFrom str) (go 0 "" [ ]); if len == 0 then [ (addContextFrom str "") ] else map (addContextFrom str) (go 0 "" [ ]);
/** /**
Return a string without the specified prefix, if the prefix matches. Returns a string without the specified prefix, if the prefix matches.
# Inputs # Inputs
@@ -1857,7 +1857,7 @@ rec {
); );
/** /**
Return a string without the specified suffix, if the suffix matches. Returns a string without the specified suffix, if the suffix matches.
# Inputs # Inputs
@@ -1908,7 +1908,7 @@ rec {
); );
/** /**
Return true if string `v1` denotes a version older than `v2`. Returns true if string `v1` denotes a version older than `v2`.
# Inputs # Inputs
@@ -1940,7 +1940,7 @@ rec {
versionOlder = v1: v2: compareVersions v2 v1 == 1; versionOlder = v1: v2: compareVersions v2 v1 == 1;
/** /**
Return true if string v1 denotes a version equal to or newer than v2. Returns true if string v1 denotes a version equal to or newer than v2.
# Inputs # Inputs

View File

@@ -327,7 +327,7 @@ in
f b a; f b a;
/** /**
Return `maybeValue` if not null, otherwise return `default`. Returns `maybeValue` if not null, otherwise return `default`.
# Inputs # Inputs
@@ -529,7 +529,7 @@ in
## Integer operations ## Integer operations
/** /**
Return minimum of two numbers. Returns minimum of two numbers.
# Inputs # Inputs
@@ -544,7 +544,7 @@ in
min = x: y: if x < y then x else y; min = x: y: if x < y then x else y;
/** /**
Return maximum of two numbers. Returns maximum of two numbers.
# Inputs # Inputs

View File

@@ -289,7 +289,7 @@ let
# `optionType`: The option type to parenthesize or not. # `optionType`: The option type to parenthesize or not.
# The option whose description we're returning. # The option whose description we're returning.
# #
# Return value # Returns value
# #
# The description of the `optionType`, with parentheses if there may be an # The description of the `optionType`, with parentheses if there may be an
# ambiguity. # ambiguity.