Skip to content

Commit 09b0a91

Browse files
committed
Generate API documentation using Sphinx.
1 parent f72525e commit 09b0a91

File tree

5 files changed

+128
-1
lines changed

5 files changed

+128
-1
lines changed

.github/workflows/sphinx.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
jobs:
12+
build:
13+
environment:
14+
name: github-pages
15+
url: ${{ steps.deployment.outputs.page_url }}
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Setup Pages
20+
uses: actions/configure-pages@v4
21+
- name: Set up Python
22+
id: setup_python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: "3.11"
26+
- name: Cache pip
27+
uses: actions/cache@v3
28+
id: pip-cache
29+
with:
30+
key: ${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements.txt') }}
31+
path: ${{ env.pythonLocation }}
32+
if: steps.pip-cache.outputs.cache-hit != 'true'
33+
34+
- name: Install dependencies
35+
run: |
36+
pip install -r requirements.txt
37+
38+
- name: Build html
39+
run: |
40+
sphinx-apidoc -o doc src
41+
cd doc/
42+
make html
43+
44+
- name: Upload docs artifact
45+
uses: actions/upload-pages-artifact@v3
46+
with:
47+
path: 'doc/_build/html'
48+
49+
- name: Deploy to GitHub Pages
50+
id: deployment
51+
uses: actions/deploy-pages@v4

doc/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

doc/conf.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
import os
10+
import sys
11+
12+
sys.path.insert(0, os.path.abspath(".."))
13+
14+
project = 'TF2.4 IVIM MRI Code Collection'
15+
copyright = '2024, OSIPI'
16+
author = 'OSIPI team'
17+
18+
# -- General configuration ---------------------------------------------------
19+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
20+
21+
extensions = ["sphinx.ext.todo", "sphinx.ext.viewcode", "sphinx.ext.autodoc"]
22+
23+
templates_path = ['_templates']
24+
exclude_patterns = ['Thumbs.db', '.DS_Store']
25+
26+
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
27+
html_show_sphinx = False
28+
29+
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
30+
html_show_copyright = False
31+
32+
# -- Options for HTML output -------------------------------------------------
33+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
34+
35+
html_theme = 'sphinx_rtd_theme'
36+
html_static_path = ['_static']

doc/index.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.. TF2.4 IVIM MRI Code Collection documentation master file, created by
2+
sphinx-quickstart on Wed Mar 6 00:06:13 2024.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to TF2.4 IVIM MRI Code Collection's documentation!
7+
==========================================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
:caption: Contents:
12+
13+
modules
14+
15+
Indices and tables
16+
==================
17+
18+
* :ref:`modindex`

requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ scienceplots
1010
cvxpy
1111
zenodo-get
1212
pytest
13-
tqdm
13+
tqdm
14+
sphinx
15+
sphinx_rtd_theme

0 commit comments

Comments
 (0)