docs: fix options generation, add anchors

This commit is contained in:
Maximilian Hils 2022-03-15 19:02:43 +01:00
parent 5fc20e3e8c
commit 1af095bcf8
2 changed files with 27 additions and 25 deletions

View File

@ -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("""
<table class=\"table optiontable\">
@ -33,21 +39,17 @@ print("""
<tbody>
""".strip())
for key, option in sorted(unified_options.items(), key=lambda t: t[0]):
print("""
<tr>
<th>{}<br/>{}</th>
<td>{}</td>
<td>{}<br/>
Default: {}
{}
print(f"""
<tr id="{key}">
<th>
<a class="anchor" href="#{key}">#&nbsp;&nbsp;</a>
{key}<br/>
{' '.join(["<span class='badge'>{}</span>".format(t) for t in option['tools']])}</th>
<td>{option['type']}</td>
<td>{option['help']}<br/>
Default: {option['default']}
{"<br/>Choices: {}".format(', '.join(option['choices'])) if option['choices'] else ""}
</td>
</tr>
""".strip().format(
key,
' '.join(["<span class='badge'>{}</span>".format(t) for t in option['tools']]),
option['type'],
option['help'],
option['default'],
"<br/>Choices: {}".format(', '.join(option['choices'])) if option['choices'] else "",
))
""".strip())
print("</tbody></table>")

View File

@ -82,7 +82,7 @@ code {
}
}
h1, h2, h3, h4, h5, h6 {
h1, h2, h3, h4, h5, h6, th {
.anchor {
display: inline-block;
width: 0;