Skip to content

Commit 18bcc2f

Browse files
hugtalbotalxbilger
andauthored
[doc] Towards automatic documentation generation for SofaPython3 (#482)
* [doc] Towards automatic documentation generation for SofaPython3 * Apply suggestions from code review Co-authored-by: Alex Bilger <[email protected]> --------- Co-authored-by: Alex Bilger <[email protected]>
1 parent d5135f4 commit 18bcc2f

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build, zip and upload documentation for release
2+
3+
on:
4+
workflow_dispatch: # This allows manual triggering
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.12'
18+
19+
- name: Install dependencies
20+
run: |
21+
cd docs/sphinx/
22+
pip install -r source/requirements.txt
23+
24+
- name: Get latest release tag of the remote repository
25+
id: get_release
26+
run: |
27+
LATEST_RELEASE=$(curl -s https://api.github.com/repos/sofa-framework/sofa/releases/latest | jq -r .tag_name)
28+
PYTHON_VERSION=$(python --version | awk '{print $2}' | cut -d. -f1,2)
29+
echo "LATEST_RELEASE=${LATEST_RELEASE}" >> $GITHUB_ENV
30+
echo "PYTHON_VERSION=${PYTHON_VERSION}" >> $GITHUB_ENV
31+
echo "${LATEST_RELEASE}"
32+
echo "${PYTHON_VERSION}"
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Download latest release ZIP
37+
run: |
38+
echo "Downloading ZIP --> https://github.com/sofa-framework/sofa/releases/download/${LATEST_RELEASE}/SOFA_${LATEST_RELEASE}_Linux-Python_${PYTHON_VERSION}.zip"
39+
curl -L -o release.zip "https://github.com/sofa-framework/sofa/releases/download/${LATEST_RELEASE}/SOFA_${LATEST_RELEASE}_Linux-Python_${PYTHON_VERSION}.zip"
40+
ls -lah .
41+
42+
- name: Unzip release
43+
run: |
44+
unzip release.zip -d extracted
45+
mv extracted/* extracted/sofa_binaries
46+
47+
- name: Check extracted files
48+
run: |
49+
echo "Listing extracted files:"
50+
ls -lah extracted/sofa_binaries
51+
52+
- name: Define environment variables
53+
run: |
54+
echo "PYTHONPATH=${{ github.workspace }}/extracted/sofa_binaries/plugins/SofaPython3/lib/python3/site-packages"
55+
echo "PYTHONPATH=${{ github.workspace }}/extracted/sofa_binaries/plugins/SofaPython3/lib/python3/site-packages" >> $GITHUB_ENV
56+
ls ${{ github.workspace }}/extracted/sofa_binaries/plugins/SofaPython3/lib/python3/site-packages
57+
58+
- name: Build Sphinx documentation
59+
run: |
60+
cd docs/sphinx/
61+
mkdir build/
62+
sphinx-build -b html -a -E source/ build/
63+
64+
- name: Zip Documentation
65+
run: |
66+
# Create a zip file of the documentation
67+
ls -lah docs/sphinx/build/
68+
cd docs/sphinx/build/
69+
# Create a zip file of the documentation
70+
zip -r SofaPython3_${LATEST_RELEASE}_docs.zip .
71+
ls .
72+
73+
- name: Create tag (before release)
74+
run: |
75+
echo "RELEASE_TAG=${LATEST_RELEASE}-doc-generation" >> $GITHUB_ENV
76+
echo "RELEASE_TAG=${LATEST_RELEASE}-doc-generation"
77+
78+
- name: Upload to GitHub Release
79+
uses: softprops/action-gh-release@v2
80+
with:
81+
tag_name: ${{ env.RELEASE_TAG }}
82+
files: |
83+
docs/sphinx/build/SofaPython3_${{ env.LATEST_RELEASE }}_docs.zip
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+

docs/sphinx/source/requirements.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
mock
22
sphinxcontrib-contentui
3-
sphinx-search
3+
readthedocs-sphinx-search
44
sphinx-autodoc-typehints
55
sphinx-rtd-theme
6+
sphinx-tabs
7+
sphinx-autosummary-autocollect

0 commit comments

Comments
 (0)