forked from mirrors/nixpkgs
lib/options: add literalExpression and literalDocBook, deprecate literalExample
This commit is contained in:
parent
c3bf08d1b0
commit
52a2e4136e
|
@ -123,8 +123,8 @@ let
|
||||||
inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
|
inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions
|
||||||
mergeDefaultOption mergeOneOption mergeEqualOption getValues
|
mergeDefaultOption mergeOneOption mergeEqualOption getValues
|
||||||
getFiles optionAttrSetToDocList optionAttrSetToDocList'
|
getFiles optionAttrSetToDocList optionAttrSetToDocList'
|
||||||
scrubOptionValue literalExample showOption showFiles
|
scrubOptionValue literalExpression literalExample literalDocBook
|
||||||
unknownModule mkOption;
|
showOption showFiles unknownModule mkOption;
|
||||||
inherit (self.types) isType setType defaultTypeMerge defaultFunctor
|
inherit (self.types) isType setType defaultTypeMerge defaultFunctor
|
||||||
isOptionType mkOptionType;
|
isOptionType mkOptionType;
|
||||||
inherit (self.asserts)
|
inherit (self.asserts)
|
||||||
|
|
|
@ -54,7 +54,7 @@ rec {
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
mkOption { } // => { _type = "option"; }
|
mkOption { } // => { _type = "option"; }
|
||||||
mkOption { defaultText = "foo"; } // => { _type = "option"; defaultText = "foo"; }
|
mkOption { default = "foo"; } // => { _type = "option"; default = "foo"; }
|
||||||
*/
|
*/
|
||||||
mkOption =
|
mkOption =
|
||||||
{
|
{
|
||||||
|
@ -212,11 +212,25 @@ rec {
|
||||||
else x;
|
else x;
|
||||||
|
|
||||||
|
|
||||||
/* For use in the `example` option attribute. It causes the given
|
/* For use in the `defaultText` and `example` option attributes. Causes the
|
||||||
text to be included verbatim in documentation. This is necessary
|
given string to be rendered verbatim in the documentation as Nix code. This
|
||||||
for example values that are not simple values, e.g., functions.
|
is necessary for complex values, e.g. functions, or values that depend on
|
||||||
|
other values or packages.
|
||||||
*/
|
*/
|
||||||
literalExample = text: { _type = "literalExample"; inherit text; };
|
literalExpression = text:
|
||||||
|
if ! isString text then throw "literalExpression expects a string."
|
||||||
|
else { _type = "literalExpression"; inherit text; };
|
||||||
|
|
||||||
|
literalExample = lib.warn "literalExample is deprecated, use literalExpression instead, or use literalDocBook for a non-Nix description." literalExpression;
|
||||||
|
|
||||||
|
|
||||||
|
/* For use in the `defaultText` and `example` option attributes. Causes the
|
||||||
|
given DocBook text to be inserted verbatim in the documentation, for when
|
||||||
|
a `literalExpression` would be too hard to read.
|
||||||
|
*/
|
||||||
|
literalDocBook = text:
|
||||||
|
if ! isString text then throw "literalDocBook expects a string."
|
||||||
|
else { _type = "literalDocBook"; inherit text; };
|
||||||
|
|
||||||
# Helper functions.
|
# Helper functions.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue