blob: ea217468cb75d44b06cb64479969636028bba488 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
{ outputAttrPath, optionsAttrPath, optionsInternal ? true, }:
{ lib, options, pkgs, ... }:
with lib;
let
visibleOptionDocs = filter (opt: opt.visible && !opt.internal) (optionAttrSetToDocList options);
toValue = value:
if value ? _type && value._type == "literalExpression" then value.text
else generators.toPretty { } value;
toMarkdown = option:
''
## `${option.name}`
${option.description}
${optionalString (option ? default) ''
**Default value**:
```nix
${toValue option.default}
```
''}
**Type**: ${option.type}${optionalString option.readOnly " (read only)"}
${optionalString (option ? example) ''
**Example**:
```nix
${toValue option.example}
```
''}
Declared in:
${concatStringsSep "\n" (map (decl: "- ${decl}") option.declarations)}
'';
# TODO: rewrite "Declared in" so that it points to GitHub repository
options-md = concatStringsSep "\n" (map toMarkdown visibleOptionDocs);
in
{
config = setAttrByPath outputAttrPath {
doc-options-md = pkgs.writeText "options.md" options-md;
};
}
|