From e06f494a81d65177404cf9b1d28a5fbffda0f146 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 30 Jun 2015 12:19:49 +0200 Subject: [PATCH] doc: document lib.makeOverridable --- doc/functions.xml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/doc/functions.xml b/doc/functions.xml index 89f2fda0ad4b..2aae3cfb2aec 100644 --- a/doc/functions.xml +++ b/doc/functions.xml @@ -85,4 +85,36 @@ in ... +
+ lib.makeOverridable + + + The function lib.makeOverridable is used make the result + of a function easily customizable. This utility only makes sense for functions + that accept an argument set and return an attribute set. + + + + Example usage: + + f = { a, b }: { result = a+b; } +c = lib.makeOverridable f { a = 1; b = 2; } + + + + + The variable c is the value of the f function + applied with some default arguments. Hence the value of c.result + is 3, in this example. + + + + The variable c however also has some additional functions, like + c.override which can be used to + override the default arguments. In this example the value of + (c.override { a = 4; }).result is 6. + + +
+