diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 6abd651c..94385938 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -36,6 +36,18 @@ jobs: pip install -e ".[sparse,test]" python -m pytest -n auto optimism --cov=optimism -Wignore # we can also add the flag -n auto for parallel testing + - name: docs + run: | + pip install -e ".[docs,sparse,test]" + cd docs + sphinx-apidoc -o source/ ../optimism -P + make html + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/build/html # Adjust this if your output directory is different + publish_branch: gh-pages # The branch to deploy to - name: codecov uses: codecov/codecov-action@v4 with: diff --git a/.gitignore b/.gitignore index a8b52c05..a6fbd3c2 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,8 @@ spack.lock .spack-env/ *.npz *.vtk + +# docs stuff +build/ +docs/source/modules.rst +docs/source/optimism.* diff --git a/README.md b/README.md index 4fb0fd6e..dd22376f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # OptimiSM: Computational solid mechanics made easy with Jax ![Continuous integration](https://github.com/sandialabs/optimism/actions/workflows/ci-build.yml/badge.svg) +[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://sandialabs.github.io/optimism/) +[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://sandialabs.github.io/optimism/dev/) [![Coverage](https://codecov.io/gh/sandialabs/optimism/branch/main/graph/badge.svg)](https://codecov.io/gh/sandialabs/optimism) ## What is OptimiSM? diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 00000000..d0c3cbf1 --- /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 = 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) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 00000000..747ffb7b --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +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 diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 00000000..733f67e7 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,41 @@ +# 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 = 'optimism' +copyright = '2024, Brandon Talamini, Mike Tupek' +author = 'Brandon Talamini, Mike Tupek' +release = '0.1.0' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + 'sphinx_copybutton', + 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinx.ext.coverage', + 'sphinx.ext.napoleon', + 'sphinx.ext.viewcode' +] + +templates_path = ['_templates'] +exclude_patterns = [] +html_theme = 'sphinx_rtd_theme' + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_static_path = ['_static'] + +# autodoc_default_options = { +# 'members': True +# } diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 00000000..e7cbe97f --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,26 @@ +.. optimism documentation master file, created by + sphinx-quickstart on Fri Oct 18 12:13:55 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +optimism documentation +====================== + +Add your content using ``reStructuredText`` syntax. See the +`reStructuredText `_ +documentation for details. + + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + modules + optimism + +Indices and Tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/setup.py b/setup.py index c9407531..961cfb5e 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,8 @@ 'metis'], #tests_require=[], # could put chex and pytest here extras_require={'sparse': ['scikit-sparse'], - 'test': ['pytest', 'pytest-cov', 'pytest-xdist']}, + 'test': ['pytest', 'pytest-cov', 'pytest-xdist'], + 'docs': ['sphinx', 'sphinx-copybutton', 'sphinx-rtd-theme', 'sphinxcontrib-bibtex', 'sphinxcontrib-napoleon']}, python_requires='>=3.7', version='0.0.1', license='MIT',