docs: remove output paths from generated documentation

Otherwise, the `testRstOptions` test would fail too often!
This commit is contained in:
Antoine Eiche 2021-10-14 09:06:14 +02:00
parent fb85a3fe9e
commit 74bb227990
2 changed files with 31 additions and 24 deletions

View file

@ -489,7 +489,7 @@ For which domains should this account act as a catch all?
Note: Does not allow sending from all addresses of these domains. Note: Does not allow sending from all addresses of these domains.
- Type: ``list of one of s`` - Type: ``list of impossible (empty enum)s``
- Default: ``[]`` - Default: ``[]``
@ -858,23 +858,23 @@ check system $HOST
if loadavg (15min) > 70 for 8 cycles then alert if loadavg (15min) > 70 for 8 cycles then alert
check process sshd with pidfile /var/run/sshd.pid check process sshd with pidfile /var/run/sshd.pid
start program "/nix/store/gyg6zyw1f0d1ahh1yk0pl18sxwx5a3zc-systemd-246.6/bin/systemctl start sshd" start program "<OUTPUT-PATH>/bin/systemctl start sshd"
stop program "/nix/store/gyg6zyw1f0d1ahh1yk0pl18sxwx5a3zc-systemd-246.6/bin/systemctl stop sshd" stop program "<OUTPUT-PATH>/bin/systemctl stop sshd"
if failed port 22 protocol ssh for 2 cycles then restart if failed port 22 protocol ssh for 2 cycles then restart
check process postfix with pidfile /var/lib/postfix/queue/pid/master.pid check process postfix with pidfile /var/lib/postfix/queue/pid/master.pid
start program = "/nix/store/gyg6zyw1f0d1ahh1yk0pl18sxwx5a3zc-systemd-246.6/bin/systemctl start postfix" start program = "<OUTPUT-PATH>/bin/systemctl start postfix"
stop program = "/nix/store/gyg6zyw1f0d1ahh1yk0pl18sxwx5a3zc-systemd-246.6/bin/systemctl stop postfix" stop program = "<OUTPUT-PATH>/bin/systemctl stop postfix"
if failed port 25 protocol smtp for 5 cycles then restart if failed port 25 protocol smtp for 5 cycles then restart
check process dovecot with pidfile /var/run/dovecot2/master.pid check process dovecot with pidfile /var/run/dovecot2/master.pid
start program = "/nix/store/gyg6zyw1f0d1ahh1yk0pl18sxwx5a3zc-systemd-246.6/bin/systemctl start dovecot2" start program = "<OUTPUT-PATH>/bin/systemctl start dovecot2"
stop program = "/nix/store/gyg6zyw1f0d1ahh1yk0pl18sxwx5a3zc-systemd-246.6/bin/systemctl stop dovecot2" stop program = "<OUTPUT-PATH>/bin/systemctl stop dovecot2"
if failed host mx.example.com port 993 type tcpssl sslauto protocol imap for 5 cycles then restart if failed host mx.example.com port 993 type tcpssl sslauto protocol imap for 5 cycles then restart
check process rspamd with pidfile /var/run/rspamd.pid check process rspamd with pidfile /var/run/rspamd.pid
start program = "/nix/store/gyg6zyw1f0d1ahh1yk0pl18sxwx5a3zc-systemd-246.6/bin/systemctl start rspamd" start program = "<OUTPUT-PATH>/bin/systemctl start rspamd"
stop program = "/nix/store/gyg6zyw1f0d1ahh1yk0pl18sxwx5a3zc-systemd-246.6/bin/systemctl stop rspamd" stop program = "<OUTPUT-PATH>/bin/systemctl stop rspamd"
`` ``

View file

@ -1,5 +1,6 @@
import json import json
import sys import sys
import re
header = """ header = """
Mailserver Options Mailserver Options
@ -23,32 +24,38 @@ template = """
f = open(sys.argv[1]) f = open(sys.argv[1])
options = json.load(f) options = json.load(f)
options = { k: v for k, v in options.items() if k.startswith("mailserver.") } options = {k: v for k, v in options.items()
if k.startswith("mailserver.")}
groups = [ "mailserver.loginAccount", groups = ["mailserver.loginAccount",
"mailserver.certificate", "mailserver.certificate",
"mailserver.dkim", "mailserver.dkim",
"mailserver.fullTextSearch", "mailserver.fullTextSearch",
"mailserver.redis", "mailserver.redis",
"mailserver.monitoring", "mailserver.monitoring",
"mailserver.backup", "mailserver.backup",
"mailserver.borg" ] "mailserver.borg"]
def print_option(name, value): def print_option(name, value):
if 'default' in v: if 'default' in value:
if v['default'] == "": if value['default'] == "":
default = '- Default: ``""``' default = '- Default: ``""``'
else: else:
default = '- Default: ``{}``'.format(v['default']) default = '- Default: ``{}``'.format(v['default'])
# Some default values contains OUTPUTPATHS which make the
# output not stable across nixpkgs updates.
default = re.sub('/nix/store/[\w.-]*/', '<OUTPUT-PATH>/', default) # noqa
else: else:
default = "" default = ""
print(template.format( print(template.format(
key=k, key=name,
line="-"*len(k), line="-"*len(name),
description=v['description'], description=value['description'],
type="- Type: ``{}``".format(v['type']), type="- Type: ``{}``".format(value['type']),
default=default)) default=default))
print(header) print(header)
for k, v in options.items(): for k, v in options.items():
if any([k.startswith(c) for c in groups]): if any([k.startswith(c) for c in groups]):