diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2018-03-25 12:12:00 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2018-03-25 13:42:55 +0200 |
commit | f6699792da82c00de4cdcc1e413bd65caad9d3c3 (patch) | |
tree | 154b5e3de371995b2dea3281678edf71f7f9e07f /docs/scripts/options.py | |
parent | 0e62e386c0ede3f9d0ca7a82681e69977c0b59e6 (diff) | |
download | mitmproxy-f6699792da82c00de4cdcc1e413bd65caad9d3c3.tar.gz mitmproxy-f6699792da82c00de4cdcc1e413bd65caad9d3c3.tar.bz2 mitmproxy-f6699792da82c00de4cdcc1e413bd65caad9d3c3.zip |
docs: add auto-generated options reference
Diffstat (limited to 'docs/scripts/options.py')
-rwxr-xr-x[-rw-r--r--] | docs/scripts/options.py | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/docs/scripts/options.py b/docs/scripts/options.py index 5ad23d67..ff7d0f7f 100644..100755 --- a/docs/scripts/options.py +++ b/docs/scripts/options.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 + from mitmproxy import options, optmanager from mitmproxy.tools import dump, console, web @@ -8,7 +9,45 @@ masters = { "mitmweb": web.master.WebMaster } -for name, master in masters.items(): +unified_options = {} + +for tool_name, master in masters.items(): opts = options.Options() inst = master(opts) - print(optmanager.dump_dicts(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] + +print(""" + <table class=\"table optiontable\"> + <thead> + <tr> + <th>Name</th> + <th>Type</th> + <th>Description</th> + </tr> + </thead> + <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: {} + {} + </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 "", + )) +print("</tbody></table>") |