diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..f3ecfd3 --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,80 @@ +name: Build & Deploy Documentation + +on: + workflow_run: + workflows: [Algorithm Analysis] + types: + - completed +permissions: + contents: read + pages: write + id-token: write +jobs: + build: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Set up Python + id: setup_python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Cache pip + uses: actions/cache@v3 + id: pip-cache + with: + key: ${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements.txt') }} + path: ${{ env.pythonLocation }} + if: steps.pip-cache.outputs.cache-hit != 'true' + + - name: Install dependencies + run: | + pip install -r requirements.txt + + # Action to download artifacts from a different workflow (analysis.yml) + - name: 'Download artifact' + if: ${{ github.event.workflow_run.conclusion == 'success' }} + uses: actions/github-script@v6 + with: + script: | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "Figures" + })[0]; + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + let fs = require('fs'); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/Figures.zip`, Buffer.from(download.data)); + + - name: 'Unzip artifact' + run: unzip Figures.zip + + - name: Build html + run: | + mkdir docs/_static + mv *.pdf docs/_static/ + sphinx-apidoc -o docs src + cd docs/ + make html + + - name: Upload docs artifact + uses: actions/upload-pages-artifact@v3 + with: + path: 'docs/_build/html' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..41c270b --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..e268db2 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,36 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +import os +import sys + +sys.path.insert(0, os.path.abspath("..")) + +project = 'TF2.4 IVIM MRI Code Collection' +copyright = '2024, OSIPI' +author = 'OSIPI team' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = ["sphinx.ext.todo", "sphinx.ext.viewcode", "sphinx.ext.autodoc"] + +templates_path = ['_templates'] +exclude_patterns = ['Thumbs.db', '.DS_Store'] + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +html_show_sphinx = False + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +html_show_copyright = False + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'sphinx_rtd_theme' +html_static_path = ['_static'] diff --git a/docs/figures.rst b/docs/figures.rst new file mode 100644 index 0000000..1291f6a --- /dev/null +++ b/docs/figures.rst @@ -0,0 +1,45 @@ +Algorithm Analysis Figures +=========== + +.. raw:: html + + + +
+ + +