Skip to content

Commit

Permalink
Add Sphinx documentation (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
tachyonicClock authored Feb 22, 2024
1 parent 9e3bf45 commit 5fe9cf3
Show file tree
Hide file tree
Showing 22 changed files with 454 additions and 40 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Build Documentation"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths:
- '**.py'
- '.github/workflows/unit_test.yml'
- 'pyproject.toml'
jobs:
documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: 'pip' # caching pip dependencies
- name: Install Dependencies
run: |
sudo apt-get install -y pandoc
python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
python -m pip install ".[dev,doc]"
- name: Build Documentation
run: |
cd docs
make html
- name: Upload Documentation
uses: actions/upload-artifact@v4
with:
name: docs
path: docs/_build/html
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,5 @@ src/capymoa/jar/moa.jar
condaenv.*.requirements.txt
data
notebooks/*.png

docs/notebooks
*tfevents*
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ Python wrapper for MOA to allow efficient use of existing algorithms with a more
# Tutorial notebooks
These notebooks show how to do things. Data is available in the ```/data/``` directory (some of which will need to be downloaded, see instrucitons there).

* **DEMO.ipynb**: Contains simple examples on how to execute classification and regression, using MOA objets to configure synthetic generators or classifiers/regressors.
* **Evaluation_and_Data_Reading.ipynb**: Many examples showing how to perform different evaluations for classification and regression using different methods (i.e. a loop or buildin functions).
* **Learners_API_Examples.ipynb**: Similar to the DEMO, but shows more capabilities of the evaluator and learner objects.
* **Using_sklearn_pytorch.ipynb**: Shows how one can use the API to run sklearn algorithms (those that implement ```partial_fit```) and PyTorch models.
* [`00_getting_started.ipynb`](notebooks/00_getting_started.ipynb): Contains simple examples on how to execute classification and regression, using MOA objets to configure synthetic generators or classifiers/regressors.
* [`01_evaluation_and_data_reading.ipynb`](notebooks/01_evaluation_and_data_reading.ipynb): Many examples showing how to perform different evaluations for classification and regression using different methods (i.e. a loop or buildin functions).
* [`02_learners_api_examples.ipynb`](notebooks/02_learners_api_examples.ipynb): Shows more capabilities of the evaluator and learner objects.
* [`03_using_sklearn_pytorch.ipynb`](notebooks/03_using_sklearn_pytorch.ipynb): Shows how one can use the API to run sklearn algorithms (those that implement ```partial_fit```) and PyTorch models.
* [`04_drift_streams.ipynb`](notebooks/04_drift_streams.ipynb): Shows how to setup
simulated concept drifts in data streams.

# Test notebooks
These show how some parts of the library were developed and provide comparisons of different options on how to do things.
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 = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@python -m $(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
@python -m $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
36 changes: 36 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Contributing to Docs
There are three source of documentation in this repository:

1. Auto-generated documentation from the source code using Autodoc. See this
[link](https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html)
for more information.

2. Juptyer notebooks in the `/notebooks` directory are converted to markdown
files and included in the documentation with `nbsphinx`. See this
[link](https://nbsphinx.readthedocs.io) for more information.

To add a notebook to the documentation, add the notebook to the
`/notebooks` directory and add the filename to the `toctree` in
`index.rst`.

3. Manually written documentation in the `/docs` directory.

## Prerequisites
Install the documentation dependencies by running the following command in the
root directory of the repository:

```bash
pip install --editable ".[doc,dev]"
```

## Building the Documentation
To build the documentation, run the following command in `/docs`:

```sh
make html
```

Or on Windows:
```cmd
make.bat html
```
38 changes: 38 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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
from pathlib import Path

project = 'CapyMOA'
copyright = '2024, Heitor Murilo Gomes, Anton Lee, Nuwan Gunasekara, Marco Heyden'
author = 'Heitor Murilo Gomes, Anton Lee, Nuwan Gunasekara, Marco Heyden'
release = '0.0.1'

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

extensions = ['sphinx.ext.autodoc', 'nbsphinx', 'sphinx.ext.mathjax']

templates_path = ['_templates']
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 = "sphinx_rtd_theme"
html_static_path = ['_static']

# Setup symbolic links for notebooks

notebooks = Path("../notebooks")
notebook_doc_source = Path("notebooks")
if not notebook_doc_source.exists():
os.symlink(notebooks, notebook_doc_source)

33 changes: 33 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. CapyMOA documentation master file, created by
sphinx-quickstart on Fri Feb 23 08:41:28 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to CapyMOA's documentation!
===================================

.. toctree::
:maxdepth: 1
:caption: Tutorials:

notebooks/00_getting_started.ipynb
notebooks/01_evaluation_and_data_reading.ipynb
notebooks/02_learners_api_examples.ipynb
notebooks/03_using_sklearn_pytorch.ipynb
notebooks/04_drift_streams.ipynb

.. toctree::
:maxdepth: 1
:caption: Modules:

source/capymoa.datasets
source/capymoa.evaluation
source/capymoa.learner
source/capymoa.stream

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

%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
29 changes: 29 additions & 0 deletions docs/source/capymoa.datasets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Datasets
========================

Submodules
----------

capymoa.datasets.datasets module
--------------------------------

.. automodule:: capymoa.datasets.datasets
:members:
:undoc-members:
:show-inheritance:

capymoa.datasets.downloader module
----------------------------------

.. automodule:: capymoa.datasets.downloader
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: capymoa.datasets
:members:
:undoc-members:
:show-inheritance:
29 changes: 29 additions & 0 deletions docs/source/capymoa.evaluation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Evaluation
==========================

Submodules
----------

capymoa.evaluation.evaluation module
------------------------------------

.. automodule:: capymoa.evaluation.evaluation
:members:
:undoc-members:
:show-inheritance:

capymoa.evaluation.visualization module
---------------------------------------

.. automodule:: capymoa.evaluation.visualization
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: capymoa.evaluation
:members:
:undoc-members:
:show-inheritance:
45 changes: 45 additions & 0 deletions docs/source/capymoa.learner.classifier.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
capymoa.learner.classifier package
==================================

Submodules
----------

capymoa.learner.classifier.CPSSDS module
----------------------------------------

.. automodule:: capymoa.learner.classifier.CPSSDS
:members:
:undoc-members:
:show-inheritance:

capymoa.learner.classifier.OSNN module
--------------------------------------

.. automodule:: capymoa.learner.classifier.OSNN
:members:
:undoc-members:
:show-inheritance:

capymoa.learner.classifier.batch module
---------------------------------------

.. automodule:: capymoa.learner.classifier.batch
:members:
:undoc-members:
:show-inheritance:

capymoa.learner.classifier.classifiers module
---------------------------------------------

.. automodule:: capymoa.learner.classifier.classifiers
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: capymoa.learner.classifier
:members:
:undoc-members:
:show-inheritance:
21 changes: 21 additions & 0 deletions docs/source/capymoa.learner.regressor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
capymoa.learner.regressor package
=================================

Submodules
----------

capymoa.learner.regressor.regressors module
-------------------------------------------

.. automodule:: capymoa.learner.regressor.regressors
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: capymoa.learner.regressor
:members:
:undoc-members:
:show-inheritance:
30 changes: 30 additions & 0 deletions docs/source/capymoa.learner.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Learners
=======================

Subpackages
-----------

.. toctree::
:maxdepth: 4

capymoa.learner.classifier
capymoa.learner.regressor

Submodules
----------

capymoa.learner.learners module
-------------------------------

.. automodule:: capymoa.learner.learners
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: capymoa.learner
:members:
:undoc-members:
:show-inheritance:
Loading

0 comments on commit 5fe9cf3

Please sign in to comment.