Docs: fix src links in extern repos

This commit is contained in:
Benjamin Canou 2018-07-09 12:20:56 +02:00
parent ea4e33b0e2
commit 9f4ff764a8

View File

@ -26,10 +26,9 @@ def package_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
else: else:
lib = text lib = text
src = find_dot_opam(lib) src = find_dot_opam(lib)
branch = os.environ.get('CI_COMMIT_REF_NAME') branch = os.environ.get('CI_COMMIT_REF_NAME', 'master')
if not branch: project_url = os.environ.get('CI_PROJECT_URL', 'https://gitlab.com/tezos/tezos')
branch = 'master' src_url = project_url + "/tree/" + branch + "/" + src
src_url = "https://gitlab.com/tezos/tezos/tree/" + branch + "/" + src
if os.path.isdir('_build/api/odoc/'+lib): if os.path.isdir('_build/api/odoc/'+lib):
if os.path.isdir(os.path.join('_build','api','odoc',lib,lib.replace('-','_').capitalize())): if os.path.isdir(os.path.join('_build','api','odoc',lib,lib.replace('-','_').capitalize())):
lib = lib + '/' + lib.replace('-','_').capitalize() lib = lib + '/' + lib.replace('-','_').capitalize()
@ -71,9 +70,8 @@ def src_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
else: else:
src = text src = text
text = text text = text
branch = os.environ.get('CI_COMMIT_REF_NAME') branch = os.environ.get('CI_COMMIT_REF_NAME', 'master')
if not branch: project_url = os.environ.get('CI_PROJECT_URL', 'https://gitlab.com/tezos/tezos')
branch = 'master' url = project_url + "/tree/" + branch + "/" + src
url = "https://gitlab.com/tezos/tezos/tree/" + branch + "/" + src
node = nodes.reference(rawtext, text, refuri=url, **options) node = nodes.reference(rawtext, text, refuri=url, **options)
return [node], [] return [node], []