From c263966e3bdf74137c5857acd1100208d8709bea Mon Sep 17 00:00:00 2001 From: hugtalbot Date: Wed, 19 Feb 2025 00:08:24 +0100 Subject: [PATCH 1/2] [doc] Towards automatic documentation generation for SofaPython3 --- .../workflows/build_sphinx_documentation.yml | 86 +++++++++++++++++++ docs/sphinx/source/requirements.txt | 4 +- 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build_sphinx_documentation.yml diff --git a/.github/workflows/build_sphinx_documentation.yml b/.github/workflows/build_sphinx_documentation.yml new file mode 100644 index 00000000..3c09d4d7 --- /dev/null +++ b/.github/workflows/build_sphinx_documentation.yml @@ -0,0 +1,86 @@ +name: Build, zip and upload documentation for release + +on: + workflow_dispatch: # This allows manual triggering + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + cd docs/sphinx/ + pip install -r source/requirements.txt # Replace with your project's requirements file + + - name: Get latest release tag of the remote repository + id: get_release + run: | + LATEST_RELEASE=$(curl -s https://api.github.com/repos/sofa-framework/sofa/releases/latest | jq -r .tag_name) + PYTHON_VERSION=$(python --version | awk '{print $2}' | cut -d. -f1,2) + echo "LATEST_RELEASE=${LATEST_RELEASE}" >> $GITHUB_ENV + echo "PYTHON_VERSION=${PYTHON_VERSION}" >> $GITHUB_ENV + echo "${LATEST_RELEASE}" + echo "${PYTHON_VERSION}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Download latest release ZIP + run: | + echo "Downloading ZIP --> https://github.com/sofa-framework/sofa/releases/download/${LATEST_RELEASE}/SOFA_${LATEST_RELEASE}_Linux-Python_${PYTHON_VERSION}.zip" + curl -L -o release.zip "https://github.com/sofa-framework/sofa/releases/download/${LATEST_RELEASE}/SOFA_${LATEST_RELEASE}_Linux-Python_${PYTHON_VERSION}.zip" + ls -lah . + + - name: Unzip release + run: | + unzip release.zip -d extracted + mv extracted/* extracted/sofa_binaries + + - name: Check extracted files + run: | + echo "Listing extracted files:" + ls -lah extracted/sofa_binaries + + - name: Define environment variables + run: | + echo "PYTHONPATH=${{ github.workspace }}/extracted/sofa_binaries/plugins/SofaPython3/lib/python3/site-packages" + echo "PYTHONPATH=${{ github.workspace }}/extracted/sofa_binaries/plugins/SofaPython3/lib/python3/site-packages" >> $GITHUB_ENV + ls ${{ github.workspace }}/extracted/sofa_binaries/plugins/SofaPython3/lib/python3/site-packages + + - name: Build Sphinx documentation + run: | + cd docs/sphinx/ + mkdir build/ + sphinx-build -b html -a -E source/ build/ # Replace with your documentation source and build directories + + - name: Zip Documentation + run: | + # Create a zip file of the documentation + ls -lah docs/sphinx/build/ + cd docs/sphinx/build/ + # Create a zip file of the documentation + zip -r SofaPython3_${LATEST_RELEASE}_docs.zip . + ls . + + - name: Create tag (before release) + run: | + echo "RELEASE_TAG=${LATEST_RELEASE}-doc-generation" >> $GITHUB_ENV + echo "RELEASE_TAG=${LATEST_RELEASE}-doc-generation" + + - name: Upload to GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ env.RELEASE_TAG }} + files: | + docs/sphinx/build/SofaPython3_${{ env.LATEST_RELEASE }}_docs.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/docs/sphinx/source/requirements.txt b/docs/sphinx/source/requirements.txt index 64e3b225..20b945d1 100644 --- a/docs/sphinx/source/requirements.txt +++ b/docs/sphinx/source/requirements.txt @@ -1,5 +1,7 @@ mock sphinxcontrib-contentui -sphinx-search +readthedocs-sphinx-search sphinx-autodoc-typehints sphinx-rtd-theme +sphinx-tabs +sphinx-autosummary-autocollect From a4489ec00dfd28ed080656939f72e961db61a0e8 Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 19 Feb 2025 10:28:40 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Alex Bilger --- .github/workflows/build_sphinx_documentation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_sphinx_documentation.yml b/.github/workflows/build_sphinx_documentation.yml index 3c09d4d7..fae06072 100644 --- a/.github/workflows/build_sphinx_documentation.yml +++ b/.github/workflows/build_sphinx_documentation.yml @@ -19,7 +19,7 @@ jobs: - name: Install dependencies run: | cd docs/sphinx/ - pip install -r source/requirements.txt # Replace with your project's requirements file + pip install -r source/requirements.txt - name: Get latest release tag of the remote repository id: get_release @@ -59,7 +59,7 @@ jobs: run: | cd docs/sphinx/ mkdir build/ - sphinx-build -b html -a -E source/ build/ # Replace with your documentation source and build directories + sphinx-build -b html -a -E source/ build/ - name: Zip Documentation run: |