mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-21 22:58:24 +00:00
docs: fix options generation, add anchors
This commit is contained in:
parent
5fc20e3e8c
commit
1af095bcf8
@ -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}"># </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>")
|
||||
|
@ -82,7 +82,7 @@ code {
|
||||
}
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
h1, h2, h3, h4, h5, h6, th {
|
||||
.anchor {
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
|
Loading…
Reference in New Issue
Block a user