diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml new file mode 100644 index 000000000..017480b5d --- /dev/null +++ b/.github/workflows/doc.yml @@ -0,0 +1,39 @@ +name: Documentation Build + +on: + push: + paths: + - "doc/**" + - "**/doc.yml" + - "requirements-docs.txt" + pull_request: + paths: + - "doc/**" + - "**/doc.yml" + - "requirements-docs.txt" + +jobs: + build: + # We want to run on external PRs, but not on our own internal PRs as they'll be run + # by the push to the branch. Without this if check, checks are duplicated since + # internal PRs match both the push and pull_request events. + if: + github.event_name == 'push' || github.event.pull_request.head.repo.full_name != + github.repository + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install -r "requirements-docs.txt" + python -m pip install -e "." + - name: Build documentation + run: make --directory=doc html \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index 46886f59e..7097c49a9 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -10,16 +10,15 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # +import contextlib import os import sys +from pkg_resources import DistributionNotFound, get_distribution sys.path.insert(0, os.path.abspath("../..")) sys.path.insert(0, os.path.abspath("../sphinxext")) import datetime -import icepyx -import recommonmark - # -- Project information ----------------------------------------------------- @@ -27,6 +26,29 @@ year = datetime.date.today().year copyright = "2019-{}, The icepyx Developers".format(year) +@contextlib.contextmanager +def chdir(directory): + curdir = os.curdir + try: + os.chdir(directory) + yield + finally: + os.chdir(curdir) + + +try: + dist = get_distribution(project) +except DistributionNotFound: + # The project is not installed in readthedocs environment (requires LDAP + # bindings). Read the version with setuptools_scm. + import setuptools_scm + + with chdir("../.."): + release = setuptools_scm.get_version() +else: + release = dist.version +version = ".".join(release.split(".")[:2]) + # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be diff --git a/readthedocs.yml b/readthedocs.yml index b969696f8..827bf74de 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -22,3 +22,6 @@ python: install: - requirements: requirements-docs.txt - requirements: requirements.txt + - method: pip + path: . + system_packages: true diff --git a/requirements-docs.txt b/requirements-docs.txt index d2f785927..ab4d7e637 100644 --- a/requirements-docs.txt +++ b/requirements-docs.txt @@ -1,6 +1,10 @@ gitpython nbsphinx numpydoc +pandoc pybtex pygithub sphinxcontrib-bibtex +setuptools_scm +recommonmark +sphinx_rtd_theme