Skip to content

Commit

Permalink
Sphinx docs (#29)
Browse files Browse the repository at this point in the history
* adding sphinx docs

* small changes

* removing build dir from git
  • Loading branch information
tabacof authored Dec 6, 2023
1 parent 7b8758e commit 0e18b5c
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.env/
__pycache__/
*.cpython-*
docs/_build
21 changes: 21 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
rust: "1.70"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

python:
install:
- requirements: docs/requirements.txt
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

sys.path.insert(0, os.path.abspath("../python/"))

# 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

project = "rustrees"
copyright = "2023, Pedro Tabacof, Guilherme Lázari"
author = "Pedro Tabacof, Guilherme Lázari"

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

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

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

autoclass_content = "both"

# -- 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"]
42 changes: 42 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.. rustrees documentation master file, created by
sphinx-quickstart on Wed Dec 6 19:31:26 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to rustrees's documentation!
====================================

.. toctree::
:maxdepth: 2
:caption: Contents:

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

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

Decision trees
===============

.. automodule:: rustrees.decision_tree
:members:
:undoc-members:
:show-inheritance:

Random forests
===============

.. automodule:: rustrees.random_forest
:members:
:undoc-members:
:show-inheritance:

Utils
===============

.. automodule:: rustrees.utils
:members:
:undoc-members:
:show-inheritance:
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
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx
sphinx_rtd_theme
10 changes: 10 additions & 0 deletions python/rustrees/decision_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def predict_proba(self, X) -> List:


class DecisionTreeRegressor(DecisionTree, ClassifierMixin):
"""
Decision tree regressor implemented using Rust.
Usage should be similar to scikit-learn's DecisionTreeRegressor.
"""

def __init__(self, **kwargs):
super(DecisionTreeRegressor, self).__init__(**kwargs)

Expand All @@ -104,6 +109,11 @@ def predict(self, X) -> List:


class DecisionTreeClassifier(DecisionTree, RegressorMixin):
"""
Decision tree classifier implemented using Rust.
Usage should be similar to scikit-learn's DecisionTreeClassifier.
"""

def __init__(self, **kwargs):
super(DecisionTreeClassifier, self).__init__(**kwargs)

Expand Down
10 changes: 10 additions & 0 deletions python/rustrees/random_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ def predict_proba(self, X) -> List:


class RandomForestRegressor(RandomForest, RegressorMixin):
"""
A random forest regressor implemented using Rust.
Usage should be similar to scikit-learn's RandomForestRegressor.
"""

def __init__(self, **kwargs):
super(RandomForestRegressor, self).__init__(**kwargs)

Expand All @@ -109,6 +114,11 @@ def predict(self, X) -> List:


class RandomForestClassifier(RandomForest, ClassifierMixin):
"""
A random forest classifier implemented using Rust.
Usage should be similar to scikit-learn's RandomForestClassifier.
"""

def __init__(self, **kwargs):
super(RandomForestClassifier, self).__init__(**kwargs)

Expand Down

0 comments on commit 0e18b5c

Please sign in to comment.