docs: generate the list of options
To generate the list of options, we need to generate and commit a rst file to make all files available for ReadTheDoc. An Hydra test ensures this generated file is up-to-date. If it is not up-to-date, the error message explains the user how to generate it: the user just needs to run `nix-shell --run generate-rst-options`.
This commit is contained in:
parent
9578dbac69
commit
4d087532b6
5 changed files with 1247 additions and 3 deletions
64
scripts/generate-rst-options.py
Normal file
64
scripts/generate-rst-options.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
import json
|
||||
import sys
|
||||
|
||||
header = """
|
||||
Mailserver Options
|
||||
==================
|
||||
|
||||
mailserver
|
||||
~~~~~~~~~~
|
||||
|
||||
"""
|
||||
|
||||
template = """
|
||||
{key}
|
||||
{line}
|
||||
|
||||
{description}
|
||||
|
||||
{type}
|
||||
{default}
|
||||
"""
|
||||
|
||||
f = open(sys.argv[1])
|
||||
options = json.load(f)
|
||||
|
||||
options = { k: v for k, v in options.items() if k.startswith("mailserver.") }
|
||||
|
||||
groups = [ "mailserver.loginAccount",
|
||||
"mailserver.certificate",
|
||||
"mailserver.dkim",
|
||||
"mailserver.fullTextSearch",
|
||||
"mailserver.redis",
|
||||
"mailserver.monitoring",
|
||||
"mailserver.backup",
|
||||
"mailserver.borg" ]
|
||||
|
||||
def print_option(name, value):
|
||||
if 'default' in v:
|
||||
if v['default'] == "":
|
||||
default = '- Default: ``""``'
|
||||
else:
|
||||
default = '- Default: ``{}``'.format(v['default'])
|
||||
else:
|
||||
default = ""
|
||||
print(template.format(
|
||||
key=k,
|
||||
line="-"*len(k),
|
||||
description=v['description'],
|
||||
type="- Type: ``{}``".format(v['type']),
|
||||
default=default))
|
||||
|
||||
print(header)
|
||||
for k, v in options.items():
|
||||
if any([k.startswith(c) for c in groups]):
|
||||
continue
|
||||
print_option(k, v)
|
||||
|
||||
for c in groups:
|
||||
print(c)
|
||||
print("~"*len(c))
|
||||
print()
|
||||
for k, v in options.items():
|
||||
if k.startswith(c):
|
||||
print_option(k, v)
|
Loading…
Add table
Add a link
Reference in a new issue