Skip to content

Commit

Permalink
Added documentation. (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
byrdie authored Oct 28, 2024
1 parent 8f922af commit 0c82d6d
Show file tree
Hide file tree
Showing 11 changed files with 374 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2

build:
os: ubuntu-24.04
tools:
python: "3.12"
apt_packages:
- graphviz

sphinx:
configuration: docs/conf.py

python:
install:
- method: pip
path: .
extra_requirements:
- doc
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# optimize

[![Black](https://github.com/sun-data/optimize/actions/workflows/black.yml/badge.svg)](https://github.com/sun-data/optimize/actions/workflows/black.yml)
[![Ruff](https://github.com/sun-data/optimize/actions/workflows/ruff.yml/badge.svg)](https://github.com/sun-data/optimize/actions/workflows/ruff.yml)
[![Documentation Status](https://readthedocs.org/projects/optimize/badge/?version=latest)](https://sun-data-optimize.readthedocs.io/en/latest/?badge=latest)

Numba-accelerated minimization of objective functions.
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)
Empty file added docs/_static/.gitkeep
Empty file.
41 changes: 41 additions & 0 deletions docs/_templates/class_custom.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ fullname }}
:members:
:show-inheritance:
:inherited-members:
:undoc-members:
:member-order: groupwise

.. automethod:: __init__

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block methods %}
{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block dia %}
.. rubric:: {{ _('Inheritance Diagram') }}

.. inheritance-diagram:: {{ fullname }}
{% endblock %}

5 changes: 5 additions & 0 deletions docs/_templates/function_custom.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. autofunction:: {{ fullname }}
69 changes: 69 additions & 0 deletions docs/_templates/module_custom.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{ name | escape | underline}}

.. automodule:: {{ fullname }}

{% block attributes %}
{% if attributes %}
.. rubric:: Module Attributes

.. autosummary::
:toctree:
{% for item in attributes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block functions %}
{% if functions %}
.. rubric:: {{ _('Functions') }}

.. autosummary::
:toctree:
:template: function_custom.rst
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: {{ _('Classes') }}

.. autosummary::
:toctree:
:template: class_custom.rst
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: {{ _('Exceptions') }}

.. autosummary::
:toctree:
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block modules %}
{% if modules %}
.. rubric:: Modules

.. autosummary::
:toctree:
:template: module_custom.rst
:recursive:
{% for item in modules %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}


99 changes: 99 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# 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 os
import sys

package_path = os.path.abspath('../')
sys.path.insert(0, package_path)
os.environ['PYTHONPATH'] = ';'.join((package_path, os.environ.get('PYTHONPATH', '')))

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

project = 'optimize'
copyright = '2024, Roy T. Smart'
author = 'Roy T. Smart'

# -- 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.napoleon',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.intersphinx',
'sphinx.ext.inheritance_diagram',
'sphinx.ext.viewcode',
'jupyter_sphinx',
]
autosummary_generate = True # Turn on sphinx.ext.autosummary
autosummary_imported_members = True
# autoclass_content = 'both'
autodoc_typehints = "description"

# typehints_fully_qualified = True

graphviz_output_format = 'png'
inheritance_graph_attrs = dict(rankdir='TB')

# 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
# This pattern also affects html_static_path and html_extra_path.
# directories to ignore when looking for source files.
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 = 'pydata_sphinx_theme'

# 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_theme_options = {
"icon_links": [
{
"name": "GitHub",
"url": "https://github.com/sun-data/optimize/",
"icon": "fa-brands fa-github",
"type": "fontawesome",
},
{
"name": "PyPI",
"url": "https://pypi.org/project/optimize/",
"icon": "fa-brands fa-python",
},
],
"analytics": {
"google_analytics_id": "G-BZFB7C3V17"
}
}

# https://github.com/readthedocs/readthedocs.org/issues/2569
master_doc = 'index'

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'numpy': ('https://numpy.org/doc/stable/', None),
'numba': ('https://numba.readthedocs.io/en/stable/', None),
'scipy': ('https://docs.scipy.org/doc/scipy/', None),
'matplotlib': ('https://matplotlib.org/stable', None),
'astropy': ('https://docs.astropy.org/en/stable/', None),
}
36 changes: 36 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Introduction
============

:mod:`optimize` is a experimental library designed to parallelize and
accelerate objective function minimization, similar to the :mod:`scipy.optimize`
package, using the `Numba <https://numba.readthedocs.io/en/stable/>`_
just-in-time compiler.


Installation
============
:mod:`optimize` is published on PyPI and can be installed using::

pip install optimize


API Reference
=============

An in-depth description of the interfaces defined by this package.

.. autosummary::
:toctree: _autosummary
:template: module_custom.rst
:recursive:

optimize



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
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

if "%1" == "" goto help

%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.http://sphinx-doc.org/
exit /b 1
)

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

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

:end
popd
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "optimize"
authors = [
{name = "Roy T. Smart", email = "roytsmart@gmail.com"},
]
description = "Numba-accelerated minimization of objective functions."
readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
]
dependencies = [
"numpy",
"numba",
"astropy",
]
dynamic = ["version"]

[project.optional-dependencies]
test = [
"pytest",
"scipy",
]
doc = [
"pytest",
"matplotlib",
"graphviz",
"sphinx-autodoc-typehints",
"pydata-sphinx-theme",
"ipykernel",
"jupyter-sphinx",
"sphinx-favicon",
]

[project.urls]
Homepage = "https://github.com/sun-data/optimize"
Documentation = "https://sun-data-optimize.readthedocs.io/en/latest"

[tool.setuptools]
packages = ["optimize"]

[tool.setuptools_scm]

0 comments on commit 0c82d6d

Please sign in to comment.