From 1af095bcf86d6d05a33d671b1667d4c26be819f1 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 15 Mar 2022 19:02:43 +0100 Subject: [PATCH] docs: fix options generation, add anchors --- docs/scripts/options.py | 50 ++++++++++++++++++++------------------ docs/src/assets/style.scss | 2 +- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/docs/scripts/options.py b/docs/scripts/options.py index ff7d0f7f8..193dabfb7 100755 --- a/docs/scripts/options.py +++ b/docs/scripts/options.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import asyncio from mitmproxy import options, optmanager from mitmproxy.tools import dump, console, web @@ -11,15 +12,20 @@ masters = { unified_options = {} -for tool_name, master in masters.items(): - opts = options.Options() - inst = master(opts) - for key, option in optmanager.dump_dicts(opts).items(): - if key in unified_options: - unified_options[key]['tools'].append(tool_name) - else: - unified_options[key] = option - unified_options[key]['tools'] = [tool_name] + +async def dump(): + for tool_name, master in masters.items(): + opts = options.Options() + inst = master(opts) + for key, option in optmanager.dump_dicts(opts).items(): + if key in unified_options: + unified_options[key]['tools'].append(tool_name) + else: + unified_options[key] = option + unified_options[key]['tools'] = [tool_name] + + +asyncio.run(dump()) print(""" @@ -33,21 +39,17 @@ print(""" """.strip()) for key, option in sorted(unified_options.items(), key=lambda t: t[0]): - print(""" - - - - + + + - """.strip().format( - key, - ' '.join(["{}".format(t) for t in option['tools']]), - option['type'], - option['help'], - option['default'], - "
Choices: {}".format(', '.join(option['choices'])) if option['choices'] else "", - )) + """.strip()) print("
{}
{}
{}{}
- Default: {} - {} + print(f""" +
+ #   + {key}
+ {' '.join(["{}".format(t) for t in option['tools']])}
{option['type']}{option['help']}
+ Default: {option['default']} + {"
Choices: {}".format(', '.join(option['choices'])) if option['choices'] else ""}
") diff --git a/docs/src/assets/style.scss b/docs/src/assets/style.scss index 86b19b86d..ec46d3745 100644 --- a/docs/src/assets/style.scss +++ b/docs/src/assets/style.scss @@ -82,7 +82,7 @@ code { } } -h1, h2, h3, h4, h5, h6 { +h1, h2, h3, h4, h5, h6, th { .anchor { display: inline-block; width: 0;