scripts/generate-options: fix typing issue

This commit is contained in:
Martin Weinelt 2025-05-08 01:38:42 +02:00
parent 1615c93511
commit f9fcbe9430
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759

View File

@ -33,7 +33,9 @@ groups = ["mailserver.loginAccounts",
"mailserver.borgbackup"] "mailserver.borgbackup"]
def render_option_value(opt, attr): def render_option_value(opt, attr):
if attr in opt: if attr not in opt:
return ""
if isinstance(opt[attr], dict) and '_type' in opt[attr]: if isinstance(opt[attr], dict) and '_type' in opt[attr]:
if opt[attr]['_type'] == 'literalExpression': if opt[attr]['_type'] == 'literalExpression':
if '\n' in opt[attr]['text']: if '\n' in opt[attr]['text']:
@ -42,6 +44,8 @@ def render_option_value(opt, attr):
res = '```{}```'.format(opt[attr]['text']) res = '```{}```'.format(opt[attr]['text'])
elif opt[attr]['_type'] == 'literalMD': elif opt[attr]['_type'] == 'literalMD':
res = opt[attr]['text'] res = opt[attr]['text']
else:
assert RuntimeError(f"Unhandled option type {opt[attr]["_type"]}")
else: else:
s = str(opt[attr]) s = str(opt[attr])
if s == "": if s == "":
@ -50,10 +54,8 @@ def render_option_value(opt, attr):
res = '\n```\n' + s.rstrip('\n') + '\n```' res = '\n```\n' + s.rstrip('\n') + '\n```'
else: else:
res = '```{}```'.format(s) res = '```{}```'.format(s)
res = '- ' + attr + ': ' + res
else: return '- ' + attr + ': ' + res # type: ignore
res = ""
return res
def print_option(opt): def print_option(opt):
if isinstance(opt['description'], dict) and '_type' in opt['description']: # mdDoc if isinstance(opt['description'], dict) and '_type' in opt['description']: # mdDoc