Skip to content

Commit 3adeb0f

Browse files
committed
docs/src/options/options: add noNullDefault
1 parent d85298f commit 3adeb0f

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

docs/src/options/introduction.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Functions related to options are divided into four main types:
3131

3232
### Directly Modifying the Attribute Set of an Option
3333
- `noDefault <option>` - removes the `default` attribute from the option. It is rarely used since options without a default value are uncommon.
34+
- `noNullDefault <option>` - removes the `default` attribute from the option if its value is `null`. Used for default value logic where its absence is allowed.
3435
- `readOnly <option>` - adds the `readOnly` attribute with the value `true`.
3536
- `apply <option> <apply>` - adds the `apply` attribute with the value passed to this function.
3637
- `description <option> <description>` - adds the `description` attribute with the given value.
@@ -46,14 +47,15 @@ The list of current options can be found in the source code: [github:yunfachi/de
4647

4748
## Examples {#examples}
4849

49-
| Denix | lib.mkOption |
50-
|--------------------------------------------|--------------------------------------------------------------|
51-
| `portOption 22` | `mkOption {type = types.port; default = 22;}` |
52-
| `noDefault (portOption null)` | `mkOption {type = types.port;}` |
53-
| `allowNull (portOption null)` | `mkOption {type = types.nullOr types.port; default = null;}` |
54-
| `allowStr (portOption "22")` | `mkOption {type = types.strOr types.port; default = "22";}` |
55-
| `listOfOption port []` | `mkOption {type = types.listOf types.port; default = [];}` |
56-
| `readOnly (noDefault (portOption null))` | `mkOption {type = types.port; readOnly = true;}` |
57-
| `singleEnableOption true {name = "git";}` | `git.enable = mkEnableOption "git" // {default = true;}` |
50+
| Denix | lib.mkOption |
51+
|-----------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
52+
| `portOption 22` | `mkOption {type = types.port; default = 22;}` |
53+
| `noDefault (portOption null)` | `mkOption {type = types.port;}` |
54+
| `noNullDefault (if myconfig.server.enable then "127.0.0.1:4533" else null)` | `mkOption {type = types.str;} // (if myconfig.server.enable then {default = "127.0.0.1:4533";} else {})` |
55+
| `allowNull (portOption null)` | `mkOption {type = types.nullOr types.port; default = null;}` |
56+
| `allowStr (portOption "22")` | `mkOption {type = types.strOr types.port; default = "22";}` |
57+
| `listOfOption port []` | `mkOption {type = types.listOf types.port; default = [];}` |
58+
| `readOnly (noDefault (portOption null))` | `mkOption {type = types.port; readOnly = true;}` |
59+
| `singleEnableOption true {name = "git";}` | `git.enable = mkEnableOption "git" // {default = true;}` |
5860

5961
> *(Usually `{name = "git";}` is not required, as this function is mainly used in `delib.module :: options`)*

docs/src/ru/options/introduction.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ delib.listOfOption delib.str []
3131

3232
### Прямое изменение attribute set опции
3333
- `noDefault <option>` - удаляет атрибут `default` из опции. Используется редко, так как редко бывают опции без значения по умолчанию.
34+
- `noNullDefault <option>` - удаляет атрибут `default` из опции, если его значение равно `null`. Используется для логики значений по умолчанию, где допускается их отсутствие.
3435
- `readOnly <option>` - добавляет атрибут `readOnly` со значением `true`.
3536
- `apply <option> <apply>` - добавляет атрибут `apply` с переданным значением.
3637
- `description <option> <description>` - добавляет атрибут `description` с переданным значением.
@@ -46,14 +47,15 @@ delib.listOfOption delib.str []
4647

4748
## Примеры {#examples}
4849

49-
| Denix | lib.mkOption |
50-
|--------------------------------------------|--------------------------------------------------------------|
51-
| `portOption 22` | `mkOption {type = types.port; default = 22;}` |
52-
| `noDefault (portOption null)` | `mkOption {type = types.port;}` |
53-
| `allowNull (portOption null)` | `mkOption {type = types.nullOr types.port; default = null;}` |
54-
| `allowStr (portOption "22")` | `mkOption {type = types.strOr types.port; default = "22";}` |
55-
| `listOfOption port []` | `mkOption {type = types.listOf types.port; default = [];}` |
56-
| `readOnly (noDefault (portOption null))` | `mkOption {type = types.port; readOnly = true;}` |
57-
| `singleEnableOption true {name = "git";}` | `git.enable = mkEnableOption "git" // {default = true;}` |
50+
| Denix | lib.mkOption |
51+
|-----------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
52+
| `portOption 22` | `mkOption {type = types.port; default = 22;}` |
53+
| `noDefault (portOption null)` | `mkOption {type = types.port;}` |
54+
| `noNullDefault (if myconfig.server.enable then "127.0.0.1:4533" else null)` | `mkOption {type = types.str;} // (if myconfig.server.enable then {default = "127.0.0.1:4533";} else {})` |
55+
| `allowNull (portOption null)` | `mkOption {type = types.nullOr types.port; default = null;}` |
56+
| `allowStr (portOption "22")` | `mkOption {type = types.strOr types.port; default = "22";}` |
57+
| `listOfOption port []` | `mkOption {type = types.listOf types.port; default = [];}` |
58+
| `readOnly (noDefault (portOption null))` | `mkOption {type = types.port; readOnly = true;}` |
59+
| `singleEnableOption true {name = "git";}` | `git.enable = mkEnableOption "git" // {default = true;}` |
5860

5961
> *(Обычно `{name = "git";}` указывать не требуется, так как эта функция в основном используется в `delib.module :: options`)*

0 commit comments

Comments
 (0)