Skip to content

Commit 29bcc7e

Browse files
author
Phil Rzewski
committed
Switch to sphinx.ext.linkcode so docs link to GitHub
1 parent 1208720 commit 29bcc7e

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

doc/conf.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# Add any Sphinx extension module names here, as strings. They can be
3131
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3232
# ones.
33-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
33+
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.linkcode' ]
3434

3535
# Add any paths that contain templates here, relative to this directory.
3636
templates_path = ['_templates']
@@ -153,4 +153,21 @@
153153
]
154154

155155

156-
156+
def linkcode_resolve(domain, info):
157+
def find_line():
158+
obj = sys.modules[info['module']]
159+
for part in info['fullname'].split('.'):
160+
obj = getattr(obj, part)
161+
import inspect
162+
fn = inspect.getsourcefile(obj)
163+
source, lineno = inspect.findsource(obj)
164+
return lineno + 1
165+
166+
if domain != 'py' or not info['module']:
167+
return None
168+
#tag = 'master' if 'dev' in release else ('v' + release)
169+
url = "https://github.com/draios/python-sdc-client/blob/teams-api/sdcclient/_client.py"
170+
try:
171+
return url + '#L%d' % find_line()
172+
except Exception:
173+
return url

0 commit comments

Comments
 (0)