diff options
author | Aldo Cortesi <aldo@corte.si> | 2018-03-30 09:38:17 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-30 09:38:17 +1300 |
commit | 3c52ed6ee1948a1c4b0fa064fe7313bdfadb8950 (patch) | |
tree | 93ec314a2228612f76cde96132d0f4d496f3de78 /docs/scripts/options.py | |
parent | c6cf502657024c8077fe2e52a3f20c41ade0fbaf (diff) | |
parent | f6699792da82c00de4cdcc1e413bd65caad9d3c3 (diff) | |
download | mitmproxy-3c52ed6ee1948a1c4b0fa064fe7313bdfadb8950.tar.gz mitmproxy-3c52ed6ee1948a1c4b0fa064fe7313bdfadb8950.tar.bz2 mitmproxy-3c52ed6ee1948a1c4b0fa064fe7313bdfadb8950.zip |
Merge pull request #3012 from Kriechi/docs-options
docs: add auto-generated options reference
Diffstat (limited to 'docs/scripts/options.py')
-rwxr-xr-x | docs/scripts/options.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/docs/scripts/options.py b/docs/scripts/options.py new file mode 100755 index 00000000..ff7d0f7f --- /dev/null +++ b/docs/scripts/options.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 + +from mitmproxy import options, optmanager +from mitmproxy.tools import dump, console, web + +masters = { + "mitmproxy": console.master.ConsoleMaster, + "mitmdump": dump.DumpMaster, + "mitmweb": web.master.WebMaster +} + +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] + +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>") |