Skip to content

Commit 0d7472d

Browse files
authored
Merge pull request #30 from ilaflott/copilot/fix-sphinx-doc-builds-again
Add Sphinx doc build and RST linting CI workflow
2 parents 23a3c1c + 8eb010b commit 0d7472d

6 files changed

Lines changed: 66 additions & 1 deletion

File tree

.github/workflows/docs.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: docs
2+
3+
on:
4+
pull_request:
5+
branches:
6+
7+
# cancel running jobs if theres a newer push
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
docs:
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
shell: bash -l {0}
21+
steps:
22+
- name: Checkout Files
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.11'
29+
30+
- name: Install doc dependencies
31+
run: |
32+
pip install sphinx renku-sphinx-theme sphinx-rtd-theme click pyyaml rstcheck
33+
34+
- name: Install fremorizer
35+
run: |
36+
pip install --no-deps .
37+
38+
- name: Lint RST files
39+
run: |
40+
rstcheck --recursive docs/
41+
42+
- name: Build Sphinx docs
43+
run: |
44+
sphinx-build -W --keep-going -b html docs docs/build/html

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,4 @@ tmp/
158158
# autogen'd by doc build
159159
docs/fremorizer.*
160160
docs/modules.rst
161+
docs/build/

docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
API Reference
2+
=============
3+
14
.. automodule:: fremorizer
25
:members:

docs/conf.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@
99

1010
sys.path.insert(0, str(Path('..').resolve()))
1111

12-
from fremorizer import __version__ as pkg_version
12+
import importlib.util
13+
14+
# Load _version.py directly to avoid triggering the full package init
15+
# (which imports heavy optional dependencies like cmor, netCDF4, etc.)
16+
_ver_spec = importlib.util.spec_from_file_location(
17+
"fremorizer._version",
18+
Path('..').resolve() / 'fremorizer' / '_version.py'
19+
)
20+
_ver_mod = importlib.util.module_from_spec(_ver_spec) # type: ignore[arg-type]
21+
_ver_spec.loader.exec_module(_ver_mod) # type: ignore[union-attr]
22+
pkg_version = _ver_mod.__version__
1323

1424
# -- Project information -----------------------------------------------------
1525
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
sphinx
22
renku-sphinx-theme
33
sphinx-rtd-theme
4+
rstcheck

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,15 @@ docs = [
5353
"sphinx",
5454
"renku-sphinx-theme",
5555
"sphinx-rtd-theme",
56+
"rstcheck",
5657
]
5758

5859
test = [
5960
"pylint",
6061
"pytest",
6162
]
63+
64+
65+
[tool.rstcheck]
66+
report_level = "WARNING"
67+
ignore_directives = ["automodule", "autoclass", "autofunction", "automethod", "autoattribute"]

0 commit comments

Comments
 (0)