Skip to content

Commit e13b454

Browse files
Merge pull request #48 from richardkoehler/docs/update-docs
Docs/update docs
2 parents d890d1b + 162c833 commit e13b454

19 files changed

Lines changed: 419 additions & 45 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,26 @@ jobs:
128128
run: |
129129
uv run pytest --cov-fail-under=48
130130
131+
prose-lint:
132+
name: Prose lint (codespell + doc8 + interrogate)
133+
runs-on: ubuntu-latest
134+
135+
steps:
136+
- name: Checkout repository
137+
uses: actions/checkout@v6
138+
139+
- name: Set up uv
140+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57
141+
with:
142+
python-version: "3.12"
143+
enable-cache: true
144+
145+
- name: Run pre-commit (prose hooks)
146+
run: |
147+
uv run pre-commit run --all-files codespell
148+
uv run pre-commit run --all-files doc8
149+
uv run pre-commit run --all-files interrogate
150+
131151
docs:
132152
name: Docs (build + linkcheck)
133153
runs-on: ubuntu-latest
@@ -142,16 +162,34 @@ jobs:
142162
python-version: "3.12"
143163
enable-cache: true
144164

165+
# autosummary imports dbs_annotator modules that transitively touch
166+
# PySide6; ubuntu-latest images omit the EGL/XCB libs that PySide6 needs
167+
# even under QT_QPA_PLATFORM=offscreen.
168+
- name: Install Qt EGL/XCB dependencies
169+
run: |
170+
sudo apt-get update
171+
sudo apt-get install -y --no-install-recommends \
172+
libegl1 \
173+
libgl1 \
174+
libxkbcommon0 \
175+
libdbus-1-3
176+
145177
- name: Sync docs dependency group
146178
run: |
147179
uv sync --locked --group docs --no-dev
148180
149181
- name: Build HTML docs (warnings are errors)
182+
env:
183+
QT_QPA_PLATFORM: offscreen
184+
MPLBACKEND: Agg
150185
run: |
151186
uv run sphinx-build -b html -W --keep-going docs docs/_build/html
152187
153188
- name: Link check (non-blocking)
154189
continue-on-error: true
190+
env:
191+
QT_QPA_PLATFORM: offscreen
192+
MPLBACKEND: Agg
155193
run: |
156194
uv run sphinx-build -b linkcheck docs docs/_build/linkcheck
157195

.github/workflows/release.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,84 @@ permissions:
2121
contents: write
2222

2323
jobs:
24+
# ---------------------------------------------------------------------------
25+
# Pre-flight gates. These run on every invocation and block all build jobs
26+
# from starting if the release artifact would be inconsistent with the
27+
# sources. Both gates are skipped for `workflow_dispatch` runs where
28+
# `publish_release=false`, so maintainers can still dry-run the build matrix
29+
# without a tag.
30+
# ---------------------------------------------------------------------------
31+
changelog-gate:
32+
name: CHANGELOG.md has section for tag
33+
runs-on: ubuntu-latest
34+
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish_release) }}
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v6
39+
40+
- name: Verify CHANGELOG.md contains the tagged version
41+
shell: bash
42+
run: |
43+
set -euo pipefail
44+
ref="${GITHUB_REF_NAME}"
45+
# Strip leading `v` (tags are `vX.Y.Z`; CHANGELOG uses `[X.Y.Z]`).
46+
version="${ref#v}"
47+
if ! grep -qE "^## \[${version}\]( - [0-9]{4}-[0-9]{2}-[0-9]{2})?$" CHANGELOG.md; then
48+
echo "::error file=CHANGELOG.md::Missing '## [${version}]' section in CHANGELOG.md" >&2
49+
echo "Expected a heading like '## [${version}] - YYYY-MM-DD' (Keep a Changelog)." >&2
50+
exit 1
51+
fi
52+
echo "CHANGELOG.md contains a section for ${version}."
53+
54+
version-consistency:
55+
name: Version is consistent across sources
56+
runs-on: ubuntu-latest
57+
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish_release) }}
58+
59+
steps:
60+
- name: Checkout repository
61+
uses: actions/checkout@v6
62+
63+
- name: Set up uv with Python
64+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57
65+
with:
66+
python-version: "3.12"
67+
enable-cache: true
68+
69+
- name: Verify __version__, [tool.briefcase].version, and git tag agree
70+
shell: bash
71+
run: |
72+
set -euo pipefail
73+
ref="${GITHUB_REF_NAME}"
74+
tag_version="${ref#v}"
75+
pkg_version=$(uv run --no-sync --no-project python -c "import re, pathlib; \
76+
src = pathlib.Path('src/dbs_annotator/__init__.py').read_text(); \
77+
m = re.search(r'^__version__\\s*=\\s*[\"\\'](?P<v>[^\"\\']+)[\"\\']', src, re.MULTILINE); \
78+
print(m.group('v') if m else '')")
79+
briefcase_version=$(uv run --no-sync --no-project python -c "import tomllib, pathlib; \
80+
data = tomllib.loads(pathlib.Path('pyproject.toml').read_text()); \
81+
print(data['tool']['briefcase'].get('version', ''))")
82+
echo "git tag : ${tag_version}"
83+
echo "__version__ : ${pkg_version}"
84+
echo "[tool.briefcase].ver : ${briefcase_version}"
85+
fail=0
86+
if [ "${pkg_version}" != "${tag_version}" ]; then
87+
echo "::error file=src/dbs_annotator/__init__.py::__version__ (${pkg_version}) != tag (${tag_version})" >&2
88+
fail=1
89+
fi
90+
if [ "${briefcase_version}" != "${tag_version}" ]; then
91+
echo "::error file=pyproject.toml::[tool.briefcase].version (${briefcase_version}) != tag (${tag_version})" >&2
92+
fail=1
93+
fi
94+
exit "${fail}"
95+
2496
build-python-dist:
2597
name: Build Python distribution
2698
runs-on: ubuntu-latest
99+
needs:
100+
- changelog-gate
101+
- version-consistency
27102

28103
steps:
29104
- name: Checkout repository
@@ -49,6 +124,9 @@ jobs:
49124
build-briefcase-msi:
50125
name: Build Briefcase MSI (Windows)
51126
runs-on: windows-latest
127+
needs:
128+
- changelog-gate
129+
- version-consistency
52130

53131
steps:
54132
- name: Checkout repository
@@ -139,6 +217,9 @@ jobs:
139217
build-briefcase-macos-arm:
140218
name: Build Briefcase macOS DMG (arm64)
141219
runs-on: macos-14
220+
needs:
221+
- changelog-gate
222+
- version-consistency
142223

143224
steps:
144225
- name: Checkout repository
@@ -227,6 +308,9 @@ jobs:
227308
build-briefcase-linux-x86:
228309
name: Build Briefcase Linux package (x86_64)
229310
runs-on: ubuntu-latest
311+
needs:
312+
- changelog-gate
313+
- version-consistency
230314

231315
steps:
232316
- name: Checkout repository

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ instance/
6868

6969
# Sphinx documentation
7070
docs/_build/
71+
docs/_autosummary/
7172

7273
# PyBuilder
7374
.pybuilder/

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@ repos:
1616
- id: ruff-check
1717
args: ["--fix"]
1818

19+
- repo: https://github.com/codespell-project/codespell
20+
rev: v2.3.0
21+
hooks:
22+
- id: codespell
23+
additional_dependencies: ["tomli"]
24+
25+
- repo: https://github.com/PyCQA/doc8
26+
rev: v1.1.2
27+
hooks:
28+
- id: doc8
29+
files: ^docs/.*\.rst$
30+
31+
- repo: https://github.com/econchick/interrogate
32+
rev: 1.7.0
33+
hooks:
34+
- id: interrogate
35+
pass_filenames: false
36+
args: ["src/dbs_annotator"]
37+
1938
- repo: local
2039
hooks:
2140
- id: ty-check

.readthedocs.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ build:
44
os: ubuntu-22.04
55
tools:
66
python: "3.12"
7+
# autosummary imports PySide6 transitively when documenting modules that
8+
# depend on the Qt stack (e.g. utils.theme_manager). PySide6 wheels link
9+
# libEGL / libGL / libxkbcommon / libdbus even under the offscreen platform
10+
# plugin, and the RTD build image does not ship these by default.
11+
apt_packages:
12+
- libegl1
13+
- libgl1
14+
- libxkbcommon0
15+
- libdbus-1-3
716
jobs:
817
pre_install:
918
- python -m pip install --upgrade pip

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ pip install -e .
7474
### Running from Source
7575

7676
```bash
77-
python run.py
78-
# or
7977
python -m dbs_annotator
78+
# or, once the project is installed, the console script
79+
dbs-annotator
8080
```
8181

8282
### Project Structure
@@ -94,7 +94,6 @@ App_ClinicalDBSAnnot/
9494
├── styles/ # QSS theme files (Briefcase + dev; see resource_path)
9595
├── icons/ # Application icons
9696
├── scripts/ # Utility scripts
97-
├── run.py # Development entry point
9897
└── pyproject.toml # Project configuration and dependencies
9998
```
10099

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{ fullname | escape | underline }}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. autoclass:: {{ objname }}
6+
:members:
7+
:show-inheritance:
8+
9+
{% block methods %}
10+
{% if methods %}
11+
.. rubric:: {{ _('Methods') }}
12+
13+
.. autosummary::
14+
{% for item in methods %}
15+
{%- if item not in ['__init__'] %}
16+
~{{ name }}.{{ item }}
17+
{%- endif %}
18+
{%- endfor %}
19+
{% endif %}
20+
{% endblock %}
21+
22+
{% block attributes %}
23+
{% if attributes %}
24+
.. rubric:: {{ _('Attributes') }}
25+
26+
.. autosummary::
27+
{% for item in attributes %}
28+
~{{ name }}.{{ item }}
29+
{%- endfor %}
30+
{% endif %}
31+
{% endblock %}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{{ fullname | escape | underline }}
2+
3+
.. automodule:: {{ fullname }}
4+
5+
{% block attributes %}
6+
{% if attributes %}
7+
.. rubric:: {{ _('Module attributes') }}
8+
9+
.. autosummary::
10+
{% for item in attributes %}
11+
{{ item }}
12+
{%- endfor %}
13+
{% endif %}
14+
{% endblock %}
15+
16+
{% block functions %}
17+
{% if functions %}
18+
.. rubric:: {{ _('Functions') }}
19+
20+
.. autosummary::
21+
:toctree:
22+
{% for item in functions %}
23+
{{ item }}
24+
{%- endfor %}
25+
{% endif %}
26+
{% endblock %}
27+
28+
{% block classes %}
29+
{% if classes %}
30+
.. rubric:: {{ _('Classes') }}
31+
32+
.. autosummary::
33+
:toctree:
34+
:template: autosummary/class.rst
35+
{% for item in classes %}
36+
{{ item }}
37+
{%- endfor %}
38+
{% endif %}
39+
{% endblock %}
40+
41+
{% block exceptions %}
42+
{% if exceptions %}
43+
.. rubric:: {{ _('Exceptions') }}
44+
45+
.. autosummary::
46+
:toctree:
47+
{% for item in exceptions %}
48+
{{ item }}
49+
{%- endfor %}
50+
{% endif %}
51+
{% endblock %}
52+
53+
{% block modules %}
54+
{% if modules %}
55+
.. rubric:: {{ _('Modules') }}
56+
57+
.. autosummary::
58+
:toctree:
59+
:template: autosummary/module.rst
60+
:recursive:
61+
{% for item in modules %}
62+
{{ item }}
63+
{%- endfor %}
64+
{% endif %}
65+
{% endblock %}

docs/api.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
API Reference
2+
=============
3+
4+
This page is generated automatically from the docstrings of the
5+
``dbs_annotator`` package. It is aimed at developers extending or embedding
6+
the application; clinicians and researchers should prefer the
7+
:doc:`quickstart` and :doc:`workflow_session` guides.
8+
9+
The reference deliberately covers the **data, configuration, and control
10+
layers** of the application. The Qt UI layers (``dbs_annotator.ui`` and
11+
``dbs_annotator.views``) are `PySide6 <https://doc.qt.io/qtforpython-6/>`_
12+
subclasses whose public surface is Qt signals and slots; refer to the PySide6
13+
documentation and the source itself for those.
14+
15+
.. autosummary::
16+
:toctree: _autosummary
17+
:template: autosummary/module.rst
18+
:recursive:
19+
20+
dbs_annotator.config
21+
dbs_annotator.config_electrode_models
22+
dbs_annotator.controllers
23+
dbs_annotator.logging_config
24+
dbs_annotator.models
25+
dbs_annotator.utils
26+
dbs_annotator.version

docs/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
```{include} ../CHANGELOG.md
4+
:start-after: "# Changelog"
5+
```

0 commit comments

Comments
 (0)