提交 d4027d10 authored 作者: Francesco Visin's avatar Francesco Visin

Link 'source' to commit of the selected version

Make sure that the 'source' link in the API documentation is linked to the specific version of the code selected with the version switcher.
上级 a9e18196
......@@ -186,6 +186,7 @@ htmlhelp_basename = 'theanodoc'
# Options for the linkcode extension
# ----------------------------------
# Resolve function
# This function is used to populate the (source) links in the API
def linkcode_resolve(domain, info):
def find_source():
# try to find the file and line number, based on code from numpy:
......@@ -206,7 +207,10 @@ def linkcode_resolve(domain, info):
filename = 'theano/%s#L%d-L%d' % find_source()
except Exception:
filename = info['module'].replace('.', '/') + '.py'
tag = 'master' if 'dev' in release else ('v' + release)
import subprocess
tag = subprocess.Popen(['git', 'rev-parse', 'HEAD'],
stdout=subprocess.PIPE,
universal_newlines=True).communicate()[0][:-1]
return "https://github.com/Theano/theano/blob/%s/%s" % (tag, filename)
# Options for LaTeX output
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论