summary refs log tree commit diff
path: root/nixos/lib/make-options-doc/generateAsciiDoc.py
blob: 48eadd248c5a01e9962498b2d14bfde5feb24a1d (plain) (blame)
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
import json
import sys

options = json.load(sys.stdin)
# TODO: declarations: link to github
for (name, value) in options.items():
    print(f'== {name}')
    print()
    print(value['description'])
    print()
    print('[discrete]')
    print('=== details')
    print()
    print(f'Type:: {value["type"]}')
    if 'default' in value:
        print('Default::')
        print('+')
        print('----')
        print(json.dumps(value['default'], ensure_ascii=False, separators=(',', ':')))
        print('----')
        print()
    else:
        print('No Default:: {blank}')
    if value['readOnly']:
        print('Read Only:: {blank}')
    else:
        print()
    if 'example' in value:
        print('Example::')
        print('+')
        print('----')
        print(json.dumps(value['example'], ensure_ascii=False, separators=(',', ':')))
        print('----')
        print()
    else:
        print('No Example:: {blank}')
    print()