Skip to content

Commit f955bbc

Browse files
committed
[CI-docs] 📚 Automates the build of docs on GH pages
Adds new extra dependencies to build the documentation and to install all the dependencies at once.
1 parent 91ae5aa commit f955bbc

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Building documentation as gh-pages
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
build_docs:
9+
name: documentation
10+
runs-on: ubuntu-latest # ${{ matrix.platform }}
11+
12+
steps:
13+
# Checkout the repository and setups the machine to use python
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: 3.13
21+
- name: generates API documentation and build docs
22+
# You may not run this step if done locally and the documentation was updated manually
23+
# (and those files committed to the repository)
24+
run: |
25+
pip install ".[doc]"
26+
sphinx-apidoc -o ./docs/api ./src/sagittal_average
27+
cd docs
28+
make html
29+
- name: Deploy to GitHub Pages
30+
uses: peaceiris/actions-gh-pages@v4
31+
# Needs change the repository setting (Go to Settings > Actions > General > Workflow permissions)
32+
# - Select "Read and write permissions" to be able to write in the gh-pages branch
33+
with:
34+
publish_branch: gh-pages
35+
github_token: ${{ secrets.GITHUB_TOKEN }}
36+
publish_dir: docs/_build/html
37+
force_orphan: true
38+
# First time it builds and creates the gh-pages, needs to activate the deployment as
39+
# Go to Settings > Pages and select from Build and deployment:
40+
# - Source: Deploy from a branch
41+
# - Branch: `gh-pages` and `/(root)`

‎docs/conf.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'sphinx.ext.coverage', # Automatically check if functions are documented
2020
'sphinx.ext.mathjax', # Allow support for algebra
2121
'sphinx.ext.viewcode', # Include the source code in documentation
22+
'sphinx.ext.githubpages', # Publish HTML docs in GitHub Pages¶
2223
]
2324

2425
templates_path = ['_templates']

‎pyproject.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ dev = [
5353
"pytest >= 8",
5454
"pytest-cov",
5555
]
56+
doc = [
57+
"sphinx",
58+
]
59+
all = ["sagittal_average[dev,doc]"]
5660

5761
[project.urls]
5862
Documentation = "https://UCL-COMP0233-24-25.github.io/sagittal_average/"

0 commit comments

Comments
 (0)