Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build and Deploy Documentation

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq pandoc
python -m pip install --upgrade pip
pip install numpy==2.3.5 numba==0.63.1
pip install sphinx>=7.0.0 sphinx-rtd-theme>=2.0.0 nbsphinx>=0.9.0 ipython>=8.0.0

- name: Build documentation
run: |
cd docs
make html
touch build/html/.nojekyll

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/build/html'

deploy:
# Only deploy on push to main branch
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
needs: build

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ venv/
ENV/
env/

# Documentation builds
docs/build/
docs/source/_build/

# Jupyter Notebook checkpoints
.ipynb_checkpoints

# IDE
.vscode/
.idea/
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -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 = source
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)
147 changes: 147 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Documentation Build Guide

This guide explains how to build the CudAkima documentation locally.

## Prerequisites

You need to install the documentation dependencies:

```bash
# Using pip
pip install -e ".[docs]"

# Or install dependencies individually
pip install sphinx>=7.0.0 sphinx-rtd-theme>=2.0.0 nbsphinx>=0.9.0 ipython>=8.0.0
```

## Building the Documentation

To build the HTML documentation:

```bash
cd docs
make html
```

The generated documentation will be in `docs/build/html/`. Open `docs/build/html/index.html` in your browser to view it.

## Cleaning Build Files

To clean the build directory:

```bash
cd docs
make clean
```

## Other Output Formats

Sphinx supports multiple output formats. Some useful ones:

```bash
# PDF (requires LaTeX)
make latexpdf

# Plain text
make text

# ePub
make epub
```

## GitHub Pages Deployment

The documentation is automatically built and deployed to GitHub Pages when changes are pushed to the `main` branch. The workflow is defined in `.github/workflows/docs.yml`.

To enable GitHub Pages:

1. Go to your repository settings on GitHub
2. Navigate to "Pages" in the left sidebar
3. Under "Source", select "GitHub Actions"
4. The documentation will be available at `https://<username>.github.io/<repository>/`

## Documentation Structure

```
docs/
├── source/
│ ├── conf.py # Sphinx configuration
│ ├── index.rst # Main documentation page
│ ├── api.rst # API reference
│ ├── tutorial.rst # Tutorial page
│ ├── examples.rst # Examples page
│ ├── notebooks/ # Jupyter notebooks
│ │ └── tutorial.ipynb (symlink to examples/tutorial.ipynb)
│ ├── _static/ # Static files (CSS, images, etc.)
│ └── _templates/ # Custom templates
├── build/ # Generated documentation (git-ignored)
└── Makefile # Build commands
```

## Updating Documentation

1. **Class/Function Documentation**: Update docstrings in the source code (`src/cudakima/`)
2. **Tutorial**: Edit `examples/tutorial.ipynb`
3. **Examples**: Edit `docs/source/examples.rst`
4. **Main Pages**: Edit `.rst` files in `docs/source/`

After making changes, rebuild the documentation to see the updates:

```bash
cd docs
make clean
make html
```

## Docstring Format

CudAkima uses NumPy-style docstrings. Here's an example:

```python
def my_function(x, y):
"""
Short description.

Longer description if needed.

Parameters
----------
x : array_like
Description of x
y : float
Description of y

Returns
-------
result : ndarray
Description of return value

Examples
--------
>>> my_function([1, 2, 3], 2.0)
array([2., 4., 6.])
"""
pass
```

## Troubleshooting

### Import Errors

If you get import errors when building the documentation, make sure the package is installed:

```bash
pip install -e .
```

### Notebook Execution Errors

The notebooks are set to not execute during the build (`nbsphinx_execute = 'never'`). If you want to execute them, change this setting in `docs/source/conf.py`.

### Missing Dependencies

If you get warnings about missing dependencies, install them:

```bash
pip install -e ".[docs]"
```
Empty file added docs/source/.nojekyll
Empty file.
90 changes: 90 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
API Reference
=============

This page documents the complete API for CudAkima.

Main Classes
------------

.. currentmodule:: cudakima

AkimaInterpolant1D
~~~~~~~~~~~~~~~~~~

.. autoclass:: cudakima.AkimaInterpolant1D
:members:
:special-members: __init__, __call__
:show-inheritance:

AkimaInterpolant1DMultiDim
~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: cudakima.AkimaInterpolant1DMultiDim
:members:
:special-members: __init__, __call__
:show-inheritance:

AkimaInterpolant1DFlexible
~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: cudakima.AkimaInterpolant1DFlexible
:members:
:special-members: __init__, __call__
:show-inheritance:

Kernel Functions
----------------

This section documents the low-level numba kernels used for GPU and CPU computation.

GPU Kernels
~~~~~~~~~~~

.. currentmodule:: cudakima.kernels

.. autofunction:: linearslope_gpu

.. autofunction:: splineslope_gpu

.. autofunction:: splineslope_gpu_optimized

.. autofunction:: binary_search_gpu

.. autofunction:: akima_spline_kernel_gpu

.. autofunction:: akima_spline_kernel_optimized

.. autofunction:: akima_linear_kernel

.. autofunction:: precompute_slopes_kernel

.. autofunction:: precompute_spline_slopes_kernel

.. autofunction:: akima_linear_kernel_gpu_multidim

.. autofunction:: akima_spline_kernel_gpu_multidim

CPU Kernels
~~~~~~~~~~~

.. autofunction:: linearslope_cpu

.. autofunction:: splineslope_cpu

.. autofunction:: splineslope_cpu_optimized

.. autofunction:: binary_search_cpu

.. autofunction:: akima_spline_kernel_cpu

.. autofunction:: akima_spline_kernel_cpu_optimized

.. autofunction:: akima_linear_kernel_cpu

.. autofunction:: precompute_all_linear_slopes_cpu

.. autofunction:: precompute_all_spline_slopes_cpu

.. autofunction:: akima_linear_kernel_cpu_multidim

.. autofunction:: akima_spline_kernel_cpu_multidim
Loading