Skip to content

Commit

Permalink
add website documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengp0 committed Aug 5, 2023
1 parent 62556ee commit 28cd924
Show file tree
Hide file tree
Showing 20 changed files with 362 additions and 14 deletions.
32 changes: 18 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,29 @@ Advanced spline package that provides b-spline bases, their derivatives and inte
Installation
------------

XSpline can be install via
XSpline requires python 3.10 or higher. XSpline only depends on ``numpy>=1.25.1``.
It can be installed via

.. code-block:: bash
.. code:: bash
pip install xspline>=0.1.0
For developers, you can clone the repository and install the package in the
development mode.

Requirements
------------
.. code::
XSpline requires python 3.10 or higher. XSpline only depends on ``numpy>=1.25.1``.
git clone https://github.com/zhengp0/xspline.git
cd xspline
pip install -e ".[test,docs]"
Usage
-----

You can use XSpline as a univariate function or use it to get design matrix.

.. code-block:: python
.. code:: python
import numpy as np
import matplotlib.pyplot as plt
Expand All @@ -51,7 +55,7 @@ You can use XSpline as a univariate function or use it to get design matrix.
One is to use XSpline as a univariate function. In this case, user must provide
coefficients for the spline bases.

.. code-block:: python
.. code:: python
np.random.seed(123)
spline.coef = np.random.randn(len(spline))
Expand All @@ -61,35 +65,35 @@ coefficients for the spline bases.
ax[0].plot(x, y)
ax[1].plot(x, design_mat)
.. image:: images/readme_usage_0.png
.. image:: docs/images/readme_usage_0.png

XSpline can be used to obtain derivatives.

.. code-block:: python
.. code:: python
dy, ddesign_mat = spline(x, order=1), spline.get_design_mat(x, order=1)
fig, ax = plt.subplots(1, 2, figsize=(10, 3))
ax[0].plot(x, dy)
ax[1].plot(x, ddesign_mat)
.. image:: images/readme_usage_1.png
.. image:: docs/images/readme_usage_1.png

XSpline can be used to obtain definite integrals.

.. code-block:: python
.. code:: python
iy, idesign_mat = spline(x, order=-1), spline.get_design_mat(x, order=-1)
fig, ax = plt.subplots(1, 2, figsize=(10, 3))
ax[0].plot(x, iy)
ax[1].plot(x, idesign_mat)
.. image:: images/readme_usage_2.png
.. image:: docs/images/readme_usage_2.png

XSpline can extrapolate with different polynomial options

.. code-block:: python
.. code:: python
np.random.seed(123)
# constant extrapolation one the left and linear extrapolation on the right
Expand Down Expand Up @@ -117,4 +121,4 @@ XSpline can extrapolate with different polynomial options
color="grey",
)
.. image:: images/readme_usage_3.png
.. image:: docs/images/readme_usage_3.png
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)
20 changes: 20 additions & 0 deletions docs/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* reduce the size of the main text */

p {
font-size: 0.95rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: 500;
}

.sidebar-brand-text {
font-size: 1rem;
font-weight: 500;
margin: auto;
}
Binary file added docs/_static/logo/logo-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/logo/logo-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions docs/api_reference/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
API Reference
=============

.. toctree::
:maxdepth: 2
:glob:

*
7 changes: 7 additions & 0 deletions docs/api_reference/xspline.bspl.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
xspline.bspl
============

.. automodule:: xspline.bspl
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/api_reference/xspline.indi.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
xspline.indi
=============

.. automodule:: xspline.indi
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/api_reference/xspline.poly.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
xspline.poly
=============

.. automodule:: xspline.poly
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/api_reference/xspline.xfunction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
xspline.xfunction
=================

.. automodule:: xspline.xfunction
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/api_reference/xspline.xspl.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
xspline.xspl
=============

.. automodule:: xspline.xspl
:members:
:undoc-members:
:show-inheritance:
91 changes: 91 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import tomllib

with open("../pyproject.toml", "rb") as f:
meta = tomllib.load(f)["tool"]["sphinx"]


# -- Project information -----------------------------------------------------

project = meta["project"]
author = meta["author"]
copyright = meta["copyright"]


# The full version, including alpha/beta/rc tags
version = meta["version"]


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named "sphinx.ext.*") or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosectionlabel",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
]
autodoc_typehints = "description"
autodoc_member_order = "bysource"
autodoc_type_aliases = {
"ArrayLike": "ArrayLike",
"NDArray": "NDArray",
"DataFrame": "DataFrame",
}

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "furo"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_css_files = ["css/custom.css"]
html_title = f"{project} {version}"
html_theme_options = {
"sidebar_hide_name": False,
"light_logo": "logo/logo-light.png",
"dark_logo": "logo/logo-dark.png",
"light_css_variables": {
"color-brand-primary": "#008080",
"color-brand-content": "#008080",
"color-problematic": "#BF5844",
"color-background-secondary": "#F8F8F8",
},
"dark_css_variables": {
"color-brand-primary": "#6FD8D1",
"color-brand-content": "#6FD8D1",
"color-problematic": "#FA9F50",
"color-background-secondary": "#202020",
},
}
Binary file added docs/images/readme_usage_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/readme_usage_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/readme_usage_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/readme_usage_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
XSpline
=======

Advanced spline package that provides b-spline bases, their derivatives and integrals.


To get started please check section :ref:`User's Guide`.
And the full reference is provided in section :ref:`Interface Reference`.

User's guide
------------

.. toctree::
:maxdepth: 2

installation
quickstart


Interface reference
-------------------

.. toctree::
:maxdepth: 2

api_reference/index
20 changes: 20 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
============
Installation
============


XSpline requires python 3.10 or higher. XSpline only depends on ``numpy>=1.25.1``.
It can be installed via

.. code:: bash
pip install xspline>=0.1.0
For developers, you can clone the repository and install the package in the
development mode.

.. code::
git clone https://github.com/zhengp0/xspline.git
cd xspline
pip install -e ".[test,docs]"
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
Loading

0 comments on commit 28cd924

Please sign in to comment.