Skip to content

Commit

Permalink
Add sphinx docs github actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed May 10, 2022
1 parent 79fa709 commit 911e421
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 3 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/sphinx_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: sphinx docs

on:
push: # run on push to main and PR
branches:
- main
pull_request:

env:
DJANGO_ENV: docs
DJANGO_VERSION: 3.2

jobs:
docs:
name: sphinx documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

# Python version to use is stored in the .python-version file, which is the
# convention for pyenv: https://github.com/pyenv/pyenv
- name: Get Python version
run: echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}

# We base the python cache on the hash of all requirements files, so that
# if any change, the cache is invalidated.
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('requirements/*.txt') }}
restore-keys: |
pip-${{ hashFiles('requirements/*.txt') }}
pip-
- name: Install package dependencies
- name: Install package with dependencies
run: |
pip install -q Django==${{ env.DJANGO_VERSION }}
pip install -e .
pip install -e '.[docs]'
- name: Setup test settings
run: |
cp ci/testsettings.py testsettings.py
python -c "import uuid; print('SECRET_KEY = \'%s\'' % uuid.uuid4())" >> testsettings.py
- name: Build Sphinx docs
run: cd sphinx-docs && make -b coverage html

# for pull requests, exit with error if documentation coverage is incomplete
- name: Report on documentation coverage
if: ${{ github.event_name == 'pull_request' }}
run: if [[ $((`wc -l < sphinx-docs/_build/coverage/python.txt`)) -eq 2 ]] ; then echo "Documentation coverage complete"; else cat sphinx-docs/_build/coverage/python.txt && exit 1; fi

# when building on push to main, publish the built docs
- name: Deploy built docs to github pages
if: ${{ github.event_name == 'push' }}
uses: peaceiris/actions-gh-pages@v2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./sphinx-docs/_build/html
with:
emptyCommits: false
2 changes: 1 addition & 1 deletion sphinx-docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile
l

# build production documentation for publishing on github pages
# run the html build, then move to /docs/ folder and add to git
docs:
Expand Down
8 changes: 6 additions & 2 deletions sphinx-docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@
]




# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}


coverage_ignore_pyobjects = [
# django auto-generated model methods
"get_(next|previous)_by_(created|last_modified)",
]

0 comments on commit 911e421

Please sign in to comment.