diff options
author | Antoine Eiche <lewo@abesis.fr> | 2021-07-14 10:06:58 +0200 |
---|---|---|
committer | lewo <lewo@abesis.fr> | 2021-07-27 19:58:33 +0000 |
commit | 4d087532b69c35858b4f72bdcefebe6c49a69c01 (patch) | |
tree | 7127127736be1c3e9c03aeb0457ab9e9e7c7fcaf /scripts | |
parent | 9578dbac69ec3ddf9b2fd38a40d74332b7454dfa (diff) |
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`.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/generate-rst-options.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/scripts/generate-rst-options.py b/scripts/generate-rst-options.py new file mode 100644 index 0000000..da4e3dd --- /dev/null +++ b/scripts/generate-rst-options.py @@ -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) |