Skip to content

Commit 49bd579

Browse files
authored
Added astro docs (#16)
* Added astro docs * Ruff-only CI, Python 3.10-3.13 matrix, Quarto README and docs build fix
1 parent a8dcb9e commit 49bd579

48 files changed

Lines changed: 8588 additions & 622 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
# Copy the repository, run setup_project.sh with a new name and build the docs site of the copy,
3+
# to check that the rename reaches the Astro config and the API pages.
4+
set -euo pipefail
5+
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
6+
PYTHON="${PYTHON:-$REPO/.venv-docs/bin/python}"
7+
WORK="$(mktemp -d)"
8+
trap 'rm -rf "$WORK"' EXIT
9+
rsync -a --exclude .git --exclude node_modules --exclude dist --exclude .astro --exclude .venv-docs "$REPO/" "$WORK/"
10+
cd "$WORK"
11+
bash setup_project.sh my-test-app
12+
grep -q "const pythonPackage = 'my_test_app'" docs/astro.config.mjs
13+
grep -q "/api/my_test_app/" docs/src/components/Header.astro
14+
grep -q "from my_test_app.main import main" docs/src/content/docs/getting-started/quickstart.md
15+
cp -cR "$REPO/docs/node_modules" docs/node_modules 2>/dev/null || cp -R "$REPO/docs/node_modules" docs/node_modules
16+
cd docs && DOCS_PYTHON="$PYTHON" npm run build 2>&1 | tail -25
17+
test -f dist/api/my_test_app/main/index.html
18+
echo "setup script + docs build: OK"

‎.github/actions/build-docs/action.yml‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎.github/workflows/docs.yml‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Docs
2+
3+
# The Astro + Starlight site in docs/: hand-written pages, the executed tutorials and the API
4+
# reference. Built on every push and pull request; deployed to GitHub Pages from main.
5+
6+
on:
7+
push:
8+
branches: ["main", "devel"]
9+
pull_request:
10+
branches: ["main", "devel"]
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
concurrency:
19+
group: docs-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
defaults:
26+
run:
27+
shell: bash
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: actions/setup-python@v5
32+
with:
33+
python-version: "3.12"
34+
cache: pip
35+
36+
- uses: actions/setup-node@v4
37+
with:
38+
node-version: 22
39+
cache: npm
40+
cache-dependency-path: docs/package-lock.json
41+
42+
- name: Install the package with the docs extra
43+
run: |
44+
python -m pip install --upgrade pip
45+
pip install -e ".[docs]"
46+
python -m ipykernel install --user --name python3
47+
48+
- name: Execute and convert the tutorials
49+
run: |
50+
python docs/tools/notebooks.py execute
51+
python docs/tools/notebooks.py convert --strict
52+
53+
- name: Build the site
54+
working-directory: docs
55+
run: |
56+
npm ci
57+
npm run check:mdx
58+
DOCS_PYTHON="$(command -v python)" npm run build
59+
60+
- uses: actions/upload-pages-artifact@v3
61+
with:
62+
path: docs/dist
63+
64+
deploy:
65+
needs: build
66+
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
67+
runs-on: ubuntu-latest
68+
environment:
69+
name: github-pages
70+
url: ${{ steps.deployment.outputs.page_url }}
71+
steps:
72+
- id: deployment
73+
uses: actions/deploy-pages@v4

‎.github/workflows/publish_docs.yml‎

Lines changed: 0 additions & 44 deletions
This file was deleted.

‎.github/workflows/publish_pypi.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717

1818
steps:
1919
- name: Checkout repository
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121

2222
- name: Set up Python
23-
uses: actions/setup-python@v4
23+
uses: actions/setup-python@v5
2424
with:
25-
python-version: "3.10"
25+
python-version: "3.12"
2626

2727
- name: Install build tools
2828
run: |

‎.github/workflows/static_analysis.yml‎

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@ on:
1010
- main
1111
- devel
1212

13-
defaults:
14-
run:
15-
shell: bash
16-
1713
jobs:
18-
pre-commit:
14+
ruff:
1915
runs-on: ubuntu-latest
2016
steps:
2117
- name: Checkout the code
@@ -26,35 +22,23 @@ jobs:
2622
with:
2723
python-version: "3.10"
2824

29-
- name: Run pre-commit
30-
uses: pre-commit/action@v3.0.1
25+
- name: Install ruff
26+
run: pip install ruff
3127

32-
cloc:
33-
runs-on: ubuntu-latest
34-
steps:
35-
- name: Checkout the code
36-
uses: actions/checkout@v4
28+
- name: Lint
29+
run: ruff check .
3730

38-
- name: Download and run cloc
39-
run: |
40-
curl -s https://raw.githubusercontent.com/AlDanial/cloc/master/cloc > cloc
41-
chmod +x cloc
42-
./cloc --version
43-
./cloc $(git ls-files)
31+
- name: Check formatting
32+
run: ruff format --check .
4433

45-
mypy:
34+
readme:
4635
runs-on: ubuntu-latest
47-
continue-on-error: true
4836
steps:
4937
- name: Checkout the code
5038
uses: actions/checkout@v4
5139

52-
- name: Set up Python
53-
uses: actions/setup-python@v5
54-
with:
55-
python-version: "3.10"
40+
- name: Set up Quarto
41+
uses: quarto-dev/quarto-actions/setup@v2
5642

57-
- name: Type checking with mypy
58-
run: |
59-
pip install mypy
60-
mypy src/ || true
43+
- name: Check that README.md is rendered from README.qmd
44+
run: make readme-check

‎.github/workflows/test_docs.yml‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎.github/workflows/test_pytest.yml‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,20 @@ on:
1313
jobs:
1414
pytest:
1515
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1620

1721
steps:
1822
- name: Checkout code
1923
uses: actions/checkout@v4
2024

21-
- name: Set up Python
25+
- name: Set up Python ${{ matrix.python-version }}
2226
uses: actions/setup-python@v5
2327
with:
24-
python-version: "3.10"
25-
26-
- name: Cache pip
27-
uses: actions/cache@v4
28-
with:
29-
path: ~/.cache/pip
30-
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
31-
restore-keys: |
32-
${{ runner.os }}-pip-
28+
python-version: ${{ matrix.python-version }}
29+
cache: pip
3330

3431
- name: Install project
3532
run: |

‎.github/workflows/test_setup_script.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Set up Python
2525
uses: actions/setup-python@v5
2626
with:
27-
python-version: "3.10"
27+
python-version: "3.12"
2828

2929
- name: Run setup script
3030
run: |

‎.github/workflows/test_tutorials.yml‎

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,27 @@ on:
1313
jobs:
1414
tutorials:
1515
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ["3.10", "3.13"]
1620

1721
steps:
1822
- name: Checkout code
1923
uses: actions/checkout@v4
2024

21-
- name: Set up Python
25+
- name: Set up Python ${{ matrix.python-version }}
2226
uses: actions/setup-python@v5
2327
with:
24-
python-version: "3.10"
25-
26-
- name: Cache pip
27-
uses: actions/cache@v4
28-
with:
29-
path: ~/.cache/pip
30-
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
31-
restore-keys: |
32-
${{ runner.os }}-pip-
33-
34-
- name: Install dependencies
35-
run: |
36-
sudo apt-get update
37-
sudo apt-get install -y pandoc
28+
python-version: ${{ matrix.python-version }}
29+
cache: pip
3830

3931
- name: Install project
4032
run: |
4133
pip install --upgrade pip
42-
pip install ".[dev]"
34+
pip install ".[docs]"
35+
python -m ipykernel install --user --name python3
4336
4437
- name: Execute tutorials
4538
run: |
46-
jupyter nbconvert --to notebook --execute tutorials/*.ipynb --output-dir=/tmp --ExecutePreprocessor.timeout=300
39+
python docs/tools/notebooks.py execute --force

0 commit comments

Comments
 (0)