Skip to content

Commit

Permalink
chore: build documentation with make (#433)
Browse files Browse the repository at this point in the history
* ci: add jcache tox job
* ci: define dependabot for GitHub Actions
* ci: pass GITHUB_REPO environment variable
* ci: pass GITHUB_TOKEN environment variable
* ci: run MyST-NB with cache
  https://myst-nb.readthedocs.io/en/v0.15.0/computation/execute.html#notebook-execution-modes
* fix: update link to scipy inventory
* style: use 2 spaces indent size in ini files
  • Loading branch information
redeboer authored May 21, 2022
1 parent d9bef49 commit 5b51859
Show file tree
Hide file tree
Showing 19 changed files with 186 additions and 174 deletions.
1 change: 0 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"docs/adr/*/*",
"docs/conf.py",
"labels.toml",
"Makefile",
"pyproject.toml",
"pyrightconfig.json",
"pytest.ini",
Expand Down
16 changes: 7 additions & 9 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ root = true

[*]
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[Makefile]
indent_style = tab
[*.ipynb]
indent_size = 1

[*.{py,toml}]
[*.{py,pyi,toml}]
indent_size = 4

[*.{json,yaml,yml}]
indent_size = 2

[*.{rst,inc}]
indent_size = 2

# when adding words through vscode, this is the resulting output format
[.cspell.json]
indent_size = 4

[setup.cfg]
indent_size = 4
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
assignees:
- redeboer
labels:
- 🖱️ DX
schedule:
interval: monthly
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Performance regression
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: 3.9
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
needs: push
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ jobs:
name: Build documentation and run notebooks
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -c .constraints/py3.8.txt .[doc]
pip install -c .constraints/py3.8.txt .[doc] tox
sudo apt-get -y install graphviz pandoc
- name: Build documentation and run notebooks
working-directory: docs
env:
EXECUTE_NB: YES
GITHUB_REPO: ${{ github.event.pull_request.head.repo.full_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make html
run: tox -e docnb
# cspell:ignore docnb
- name: Print error logs with color
if: ${{ failure() }}
# cspell:ignore printf
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Style checks
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- os: macos-11
python-version: "3.7"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
name: Unit tests (JAX only)
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
if: join(github.event.inputs.*)
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/linkcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ jobs:
name: Check external links
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -c .constraints/py3.8.txt -e .[doc]
pip install -c .constraints/py3.8.txt -e .[doc] tox
sudo apt-get -y install graphviz pandoc
- name: Check external links
working-directory: docs
env:
REPO: ${{ github.event.pull_request.head.repo.full_name }}
GITHUB_REPO: ${{ github.event.pull_request.head.repo.full_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH=main
if [[ "$GITHUB_HEAD_REF" != "" ]]; then
BRANCH=$GITHUB_HEAD_REF
fi
READTHEDOCS_VERSION=$BRANCH make ignore-warnings=1 linkcheck
READTHEDOCS_VERSION=$BRANCH tox -e linkcheck
6 changes: 3 additions & 3 deletions .github/workflows/requirements-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- "3.8"
- "3.9"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ComPWA/update-pip-constraints@main
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -48,7 +48,7 @@ jobs:
if: needs.is-even-week.outputs.is-even-week != 0
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ComPWA/update-pre-commit@main

push:
Expand All @@ -58,7 +58,7 @@ jobs:
- pip-constraints
- pre-commit
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
# GITHUB_TOKEN will not rerun checks after pushing to a PR branch
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/requirements-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Determine dependency changes
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
- "3.8"
- "3.9"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ComPWA/update-pip-constraints@main
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -53,7 +53,7 @@ jobs:
needs.diff.outputs.diff != ''
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ComPWA/update-pre-commit@main

push:
Expand All @@ -67,7 +67,7 @@ jobs:
- pip-constraints
- pre-commit
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
# GITHUB_TOKEN will not rerun checks after pushing to a PR branch
Expand Down
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/ComPWA/repo-maintenance
rev: 0.0.124
rev: 0.0.127
hooks:
- id: check-dev-files
args:
Expand Down Expand Up @@ -78,7 +78,9 @@ repos:
- id: editorconfig-checker
exclude: >
(?x)^(
.*\.py
.*\.md|
.*\.py|
LICENSE
)$
- repo: https://github.com/pycqa/isort
Expand Down
25 changes: 0 additions & 25 deletions docs/Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions docs/_templates/module.rst_t
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

.. code-block:: python

import {{ basename }}
import {{ basename }}

{% endif -%}
.. automodule:: {{ qualname }}
{%- for option in automodule_options %}
:{{ option }}:
:{{ option }}:
{%- endfor %}
6 changes: 3 additions & 3 deletions docs/_templates/package.rst_t
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{%- macro automodule(modname, options) -%}
.. automodule:: {{ modname }}
{%- for option in options %}
:{{ option }}:
:{{ option }}:
{%- endfor %}
{%- endmacro %}

{%- macro toctree(docnames) -%}
.. toctree::
{% for docname in docnames %}
{{ docname }}
{{ docname }}
{%- endfor %}
{%- endmacro %}

{{ pkgname.split(".")[-1] | e | heading }}

.. code-block:: python

import {{ pkgname }}
import {{ pkgname }}

{%- if modulefirst and not is_namespace %}
{{ automodule(pkgname, automodule_options) }}
Expand Down
4 changes: 2 additions & 2 deletions docs/_templates/toc.rst_t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ header | heading }}

.. toctree::
:maxdepth: {{ maxdepth }}
:maxdepth: {{ maxdepth }}
{% for docname in docnames %}
{{ docname }}
{{ docname }}
{%- endfor %}
6 changes: 2 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ def get_minor_version(package_name: str) -> str:
return matches[1]


__SCIPY_URL = (
f"https://docs.scipy.org/doc/scipy-{get_version('scipy')}/reference/"
)
__SCIPY_URL = f"https://docs.scipy.org/doc/scipy-{get_version('scipy')}/"
r = requests.get(__SCIPY_URL)
if r.status_code != 200:
__SCIPY_URL = "https://docs.scipy.org/doc/scipy"
Expand Down Expand Up @@ -291,7 +289,7 @@ def get_minor_version(package_name: str) -> str:
nb_execution_mode = "off"
if "EXECUTE_NB" in os.environ:
print("\033[93;1mWill run Jupyter notebooks!\033[0m")
nb_execution_mode = "force"
nb_execution_mode = "cache"

# Settings for myst-parser
myst_enable_extensions = [
Expand Down
Loading

0 comments on commit 5b51859

Please sign in to comment.