From 61040a7bcd46c057e34fe4671ef20b9111649e74 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 14 Oct 2016 12:18:56 +1300 Subject: docs: improve external source links, tweak code docs --- docs/conf.py | 29 ++++++++++++++--------------- docs/scripting/api.rst | 20 +++++++++++++++++--- 2 files changed, 31 insertions(+), 18 deletions(-) (limited to 'docs') diff --git a/docs/conf.py b/docs/conf.py index 76dc83d4..ef5f0556 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -195,20 +195,19 @@ html_show_sourcelink = False htmlhelp_basename = 'mitmproxydoc' +SRCBASE = "https://github.com/mitmproxy/mitmproxy/blob/master" + + # FIXME: change master to dynamic version before release extlinks = dict( - src = ('https://github.com/mitmproxy/mitmproxy/blob/master/%s', '') + src = (SRCBASE + r"/%s", '') ) -MODULE = "/mitmproxy/" - def linkcode_resolve(domain, info): if domain != 'py': return None module, fullname = info['module'], info['fullname'] - # TODO: attributes/properties don't have modules, maybe try to look - # them up based on their cached host object? if not module: return None obj = importlib.import_module(module) @@ -217,19 +216,19 @@ def linkcode_resolve(domain, info): if obj is None: return None try: - obj = getattr(obj, '_orig') - except AttributeError: - pass - try: - obj_source_path = inspect.getsourcefile(obj) + spath = inspect.getsourcefile(obj) _, line = inspect.getsourcelines(obj) except (TypeError, IOError): - # obj doesn't have a module, or something return None - off = obj_source_path.rfind(MODULE) - mpath = obj_source_path[off + len(MODULE):] - print(obj_source_path, mpath) - return "https://github.com/mitmproxy/mitmproxy/blob/master/%s" % mpath + if spath.rfind("netlib") > -1: + off = spath.rfind("netlib") + mpath = spath[off:] + elif spath.rfind("mitmproxy") > -1: + off = spath.rfind("mitmproxy") + mpath = spath[off:] + else: + return None + return SRCBASE + "/%s#L%s" % (mpath, line) def setup(app): diff --git a/docs/scripting/api.rst b/docs/scripting/api.rst index 03d35920..a1769329 100644 --- a/docs/scripting/api.rst +++ b/docs/scripting/api.rst @@ -1,8 +1,22 @@ .. _api: + API -==== +=== + +- HTTP + - `mitmproxy.models.http.HTTPRequest <#mitmproxy.models.http.HTTPRequest>`_ + - `mitmproxy.models.http.HTTPResponse <#mitmproxy.models.http.HTTPResponse>`_ + - `mitmproxy.models.http.HTTPFlow <#mitmproxy.models.http.HTTPFlow>`_ + +HTTP +---- + +.. autoclass:: mitmproxy.models.http.HTTPRequest + :inherited-members: + +.. autoclass:: mitmproxy.models.http.HTTPResponse + :inherited-members: -.. automodule:: mitmproxy.models.http +.. autoclass:: mitmproxy.models.http.HTTPFlow :inherited-members: - :members: HTTPFlow, HTTPRequest, HTTPResponse -- cgit v1.2.3