Skip to content
Snippets Groups Projects
Commit c123e027 authored by Christoph Groth's avatar Christoph Groth
Browse files

links to source: get refname from version string

So it's no longer necessary to provide the REFNAME environment variable.
Also the link template string format is now more general to support at
least gitlab github and cgit.
parent 3db8bc41
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,7 @@ check for dependencies installed: ...@@ -38,7 +38,7 @@ check for dependencies installed:
build documentation: build documentation:
stage: test stage: test
script: script:
- make -C doc realclean; make -C doc html SPHINXOPTS='-A website_deploy=True -n -W' REFNAME="${CI_COMMIT_TAG:-$CI_COMMIT_SHA}" SOURCE_URL="$CI_PROJECT_URL"/blob - make -C doc realclean; make -C doc html SPHINXOPTS='-A website_deploy=True -n -W' SOURCE_LINK_TEMPLATE="$CI_PROJECT_URL"/blob/$$r/$$f
artifacts: artifacts:
paths: paths:
- doc/build/html/ - doc/build/html/
......
...@@ -112,7 +112,7 @@ Building the documentation requires 'sphinx' and a Latex installation. ...@@ -112,7 +112,7 @@ Building the documentation requires 'sphinx' and a Latex installation.
First build the HTML and PDF documentation:: First build the HTML and PDF documentation::
./setup.py build ./setup.py build
make -C doc realclean html latex SPHINXOPTS='-A website_deploy=True -n -W' REFNAME="<version>" make -C doc realclean html latex SPHINXOPTS='-A website_deploy=True -n -W'
cd doc/build/latex cd doc/build/latex
make all-pdf make all-pdf
......
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import sys, os import sys
import os
import string
from distutils.util import get_platform from distutils.util import get_platform
sys.path.insert(0, "../../build/lib.{0}-{1}.{2}".format( sys.path.insert(0, "../../build/lib.{0}-{1}.{2}".format(
get_platform(), *sys.version_info[:2])) get_platform(), *sys.version_info[:2]))
...@@ -298,8 +299,18 @@ def linkcode_resolve(domain, info): ...@@ -298,8 +299,18 @@ def linkcode_resolve(domain, info):
filename = 'kwant/%s#L%d-%d' % find_source() filename = 'kwant/%s#L%d-%d' % find_source()
except Exception: except Exception:
filename = info['module'].replace('.', '/') + '.py' filename = info['module'].replace('.', '/') + '.py'
source_branch = os.environ.get('REFNAME', 'master')
url = os.environ.get('SOURCE_URL',
"https://gitlab.kwant-project.org/kwant/kwant/blob")
return "{}/{}/{}".format(url, source_branch, filename) # The following relies on the documented format of kwant.__version__.
rel = release.rstrip('.dirty')
if '.dev' in rel:
try:
refname = rel[rel.index('+g') + 2:]
except ValueError:
return
else:
refname = 'v' + rel
templ = os.environ.get(
"SOURCE_LINK_TEMPLATE",
"https://gitlab.kwant-project.org/kwant/kwant/blob/$r/$f")
return string.Template(templ).safe_substitute(r=refname, f=filename)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment