diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 326cf3e33dfd56c45a558232903740bd4be930a5..a063a87983fd8e72cfec482b84b084b43455b83e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -241,7 +241,7 @@ build documentation: script: - pip install git+https://github.com/jupyter-widgets/jupyter-sphinx - python -m ipykernel install --user --name kwant-latest - - make -C doc realclean; make -C doc html SPHINXOPTS='-A website_deploy=True -n -W' SOURCE_LINK_TEMPLATE="$CI_PROJECT_URL"/blob/\$\$r/\$\$f + - make -C doc realclean; make -C doc html SPHINXOPTS='-A website_deploy=True -n -W -D jupyter_execute_default_kernel=kwant-latest' SOURCE_LINK_TEMPLATE="$CI_PROJECT_URL"/blob/\$\$r/\$\$f artifacts: paths: - doc/build/html/ @@ -255,7 +255,7 @@ build PDF documentation: script: - pip install git+https://github.com/jupyter-widgets/jupyter-sphinx - python -m ipykernel install --user --name kwant-latest - - make -C doc latex SPHINXOPTS='-n -W' + - make -C doc latex SPHINXOPTS='-n -W -D jupyter_execute_default_kernel=kwant-latest' - cd doc/build/latex - make all-pdf artifacts: diff --git a/doc/source/conf.py b/doc/source/conf.py index d3d7fceb5022796e9fe464cde6def683778bed46..da68f06bf8e783bb9768869317b49dc38bbf7ccd 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -15,8 +15,15 @@ import sys import os import string from distutils.util import get_platform -sys.path.insert(0, "../../build/lib.{0}-{1}.{2}".format( - get_platform(), *sys.version_info[:2])) + +package_path = os.path.abspath( + "../../build/lib.{0}-{1}.{2}" + .format(get_platform(), *sys.version_info[:2])) + +# Insert into sys.path so that we can import kwant here +sys.path.insert(0, package_path) +# Insert into PYTHONPATH so that jupyter-sphinx will pick it up +os.environ['PYTHONPATH'] = ':'.join((package_path, os.environ.get('PYTHONPATH',''))) import kwant import kwant.qsymm @@ -31,7 +38,7 @@ sys.path.insert(0, os.path.abspath('../sphinxext')) extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.todo', 'sphinx.ext.mathjax', 'numpydoc', - 'kwantdoc', 'sphinx.ext.linkcode'] + 'kwantdoc', 'sphinx.ext.linkcode', 'jupyter_sphinx.execute'] # Add any paths that contain templates here, relative to this directory. templates_path = ['../templates'] @@ -239,7 +246,6 @@ autosummary_generate = True autoclass_content = "both" autodoc_default_flags = ['show-inheritance'] - # -- Teach Sphinx to document bound methods like functions --------------------- import types from sphinx.ext import autodoc