Skip to content

Commit

Permalink
add docs + gh pages deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
dionhaefner committed Apr 11, 2024
1 parent ba08665 commit 6657073
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 6 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build documentation

on:
# only run on PRs, not on pushes to main
# (this is handled by deploy_docs.yml)
pull_request:

workflow_call:
inputs:
artifact_name:
description: "Name of the artifact to upload"
required: false
type: string

jobs:
test-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install system requirements
run: |
sudo apt-get update
sudo apt-get install -y pandoc
- name: Setup Python environment
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install doc requirements
run: |
pip install jax[cpu]
pip install .
pip install -r docs/requirements.txt
- name: Build docs
run: |
cd docs
export SPHINXOPTS="-W" # treat warnings as errors
make html
- name: Upload HTML files
uses: actions/upload-artifact@v3
if: ${{ inputs.artifact_name }}
with:
name: ${{ inputs.artifact_name }}
path: docs/build/html
if-no-files-found: error
48 changes: 48 additions & 0 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy docs to GitHub Pages

on:
push:
branches:
- main

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

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

jobs:
build-docs:
uses: ./.github/workflows/build_docs.yml
with:
artifact_name: exponax-docs-html

deploy:
needs: [build-docs]

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

runs-on: ubuntu-latest
steps:
- name: Setup Pages
uses: actions/configure-pages@v2

- name: Download HTML doc artifact
uses: actions/download-artifact@v3
with:
name: exponax-docs-html
path: docs_build

- name: Upload pages artifact
uses: actions/upload-pages-artifact@v1
with:
path: docs_build

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
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 = .
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) -c .
49 changes: 49 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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 re

from exponax import __version__ # noqa: E402

project = "exponax"
copyright = "2024, The exponax Team"
author = "The exponax Team"

# The short X.Y version
parsed_version = re.match(r"(\d+\.\d+\.\d+)", __version__)
if parsed_version:
version = parsed_version.group(1)
else:
version = "0.0.0"

# The full version, including alpha/beta/rc tags
release = __version__

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.intersphinx",
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
]

intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"numpy": ("http://docs.scipy.org/doc/numpy/", None),
}

templates_path = []
exclude_patterns = ["build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "alabaster"
html_static_path = ["static"]
6 changes: 6 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
API documentation
=================

.. automodule:: exponax
:members:
:undoc-members:
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sphinx==7.0.1
Empty file added docs/static/.empty
Empty file.
2 changes: 2 additions & 0 deletions exponax/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
wrap_bc,
)

__version__ = "0.1.0"

__all__ = [
"BaseStepper",
"ForcedStepper",
Expand Down
11 changes: 5 additions & 6 deletions exponax/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def make_grid(
- `domain_extent`: The extent of the domain in each spatial dimension.
- `num_points`: The number of points in each spatial dimension.
- `full`: Whether to include the right boundary point in the grid.
Default: `False`. The right point is redundant for periodic boundary
Default: `False`. The right point is redundant for periodic boundary
conditions and is not considered a degree of freedom. Use this
option, for example, if you need a full grid for plotting.
- `zero_centered`: Whether to center the grid around zero. Default:
Expand All @@ -38,8 +38,7 @@ def make_grid(
- `indexing`: The indexing convention to use. Default: `'ij'`.
**Returns:**
- `grid`: The grid in the spatial domain. Shape: `(num_spatial_dims,
..., num_points)`.
- `grid`: The grid in the spatial domain. Shape: `(num_spatial_dims, ..., num_points)`.
"""
if full:
grid_1d = jnp.linspace(0, domain_extent, num_points + 1, endpoint=True)
Expand Down Expand Up @@ -266,9 +265,9 @@ def stack_sub_trajectories(
condition in the subtrajectories.
**Returns:**
- `sub_trjs`: The stacked subtrajectories. Expected shape: `(n_stacks,
n, ...)`. `n_stacks` is the number of subtrajectories stacked
together, i.e., `n_timesteps - n + 1`.
- `sub_trjs`: The stacked subtrajectories. Expected shape: `(n_stacks, n, ...)`.
`n_stacks` is the number of subtrajectories stacked together, i.e.,
`n_timesteps - n + 1`.
"""
n_time_steps = [leaf.shape[0] for leaf in jtu.tree_leaves(trj)]

Expand Down

0 comments on commit 6657073

Please sign in to comment.