diff --git a/.gitignore b/.gitignore index 5ca0c96..ac65a80 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ venv/ .ipynb_checkpoints/ __pycache__/ .mpy_ld_cache/ + +**/dist diff --git a/doc/developing-c-modules.md b/doc/developing-c-modules.md index 3c2cd63..8fda539 100644 --- a/doc/developing-c-modules.md +++ b/doc/developing-c-modules.md @@ -27,8 +27,8 @@ Standard external C modules build. ! Windows only supported using Windows Subsystem for Linux? - API refererence documentation. Using stub files sphinx with sphinx-autodoc-typehints -- ?? How to use the stubs for typechecking, like micropython stubs - +- stubs can be installed from a local clone using : `pip install ./stubs` + or from the github repository using : `pip install git+https://github.com/emlearn/emlearn-micropython#subdirectory=stubs` ## Examples - emlearn-micropython, https://github.com/emlearn/emlearn-micropython/ diff --git a/docs/api_reference.rst b/docs/api_reference.rst index 0108c21..c3e1240 100644 --- a/docs/api_reference.rst +++ b/docs/api_reference.rst @@ -21,21 +21,21 @@ API reference emlearn_trees - Decision tree ensembles ---------------------------------------------------- -.. automodule:: emlearn_trees +.. autoapimodule:: emlearn_trees :members: .. _emlearn_linreg: emlearn_linreg - Linear regression ---------------------------------------------------- -.. automodule:: emlearn_linreg +.. autoapimodule:: emlearn_linreg :members: .. _emlearn_cnn: emlearn_cnn - Convolutional Neural Networks ---------------------------------------------------------- -.. automodule:: emlearn_cnn +.. autoapimodule:: emlearn_cnn :members: @@ -43,7 +43,7 @@ emlearn_cnn - Convolutional Neural Networks emlearn_neighbors - K Nearest Neighbors (KNN) --------------------------------------------------------- -.. automodule:: emlearn_neighbors +.. autoapimodule:: emlearn_neighbors :members: @@ -51,7 +51,7 @@ emlearn_neighbors - K Nearest Neighbors (KNN) emlearn_fft - Fast Fourier Transform --------------------------------------------------------- -.. automodule:: emlearn_fft +.. autoapimodule:: emlearn_fft :members: @@ -59,7 +59,7 @@ emlearn_fft - Fast Fourier Transform emlearn_iir - Infinite Impulse Reponse filters --------------------------------------------------------- -.. automodule:: emlearn_iir +.. autoapimodule:: emlearn_iir :members: @@ -67,6 +67,6 @@ emlearn_iir - Infinite Impulse Reponse filters emlearn_arrayutils - Efficient utilities for array.array --------------------------------------------------------- -.. automodule:: emlearn_arrayutils +.. autoapimodule:: emlearn_arrayutils :members: diff --git a/docs/conf.py b/docs/conf.py index e64d7fc..a705040 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,9 +17,6 @@ import sys import subprocess -# Adjust path so we can find the .py files with API documentation -sys.path.insert(0, os.path.abspath('../stubs')) - # -- Project information ----------------------------------------------------- project = 'emlearn-micropython' @@ -44,8 +41,7 @@ extensions = [ 'sphinx.ext.mathjax', 'sphinx.ext.viewcode', - 'sphinx.ext.autodoc', - 'sphinx_autodoc_typehints', + 'autoapi.extension', 'sphinx.ext.doctest', 'sphinx.ext.coverage', 'sphinx.ext.autosectionlabel', @@ -202,6 +198,22 @@ # -- Extension configuration ------------------------------------------------- +# -- AutoAPI +autoapi_dirs = [os.path.abspath('../stubs')] +autoapi_file_patterns = ['*.pyi'] +autoapi_type = 'python' +autoapi_member_order = 'groupwise' +autoapi_generate_api_docs = False +autoapi_keep_files = False +autoapi_add_toctree_entry = False +autoapi_options = [ + 'members', + 'undoc-members', + 'show-inheritance', + 'show-module-summary', + 'special-members', +] + # -- Intersphinx intersphinx_mapping = { "emlearn": ("https://emlearn.readthedocs.io/en/latest/", None), @@ -213,9 +225,7 @@ # https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_disabled_reftypes intersphinx_disabled_reftypes = ["*"] -# -- autodoc typehints -always_document_param_types = True -typehints_fully_qualified = True -always_use_bars_union = True +# -- type display preferences +python_use_unqualified_type_names = True diff --git a/requirements.dev.txt b/requirements.dev.txt index d33d003..e36e389 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -1,4 +1,5 @@ sphinx>=4.0.0 +sphinx-autoapi>=3.0.0 recommonmark>=0.6.0 sphinx_rtd_theme>=0.5.2 sphinx-gallery>=0.10.1 diff --git a/stubs/emlearn_arrayutils.py b/stubs/emlearn_arrayutils.pyi similarity index 100% rename from stubs/emlearn_arrayutils.py rename to stubs/emlearn_arrayutils.pyi diff --git a/stubs/emlearn_cnn.py b/stubs/emlearn_cnn.pyi similarity index 100% rename from stubs/emlearn_cnn.py rename to stubs/emlearn_cnn.pyi diff --git a/stubs/emlearn_fft.py b/stubs/emlearn_fft.pyi similarity index 100% rename from stubs/emlearn_fft.py rename to stubs/emlearn_fft.pyi diff --git a/stubs/emlearn_iir.py b/stubs/emlearn_iir.pyi similarity index 100% rename from stubs/emlearn_iir.py rename to stubs/emlearn_iir.pyi diff --git a/stubs/emlearn_linreg.py b/stubs/emlearn_linreg.pyi similarity index 100% rename from stubs/emlearn_linreg.py rename to stubs/emlearn_linreg.pyi diff --git a/stubs/emlearn_neighbors.py b/stubs/emlearn_neighbors.pyi similarity index 100% rename from stubs/emlearn_neighbors.py rename to stubs/emlearn_neighbors.pyi diff --git a/stubs/emlearn_trees.py b/stubs/emlearn_trees.pyi similarity index 100% rename from stubs/emlearn_trees.py rename to stubs/emlearn_trees.pyi diff --git a/stubs/pyproject.toml b/stubs/pyproject.toml new file mode 100644 index 0000000..0197b0d --- /dev/null +++ b/stubs/pyproject.toml @@ -0,0 +1,22 @@ +[build-system] +requires = ["hatchling>=1.24"] +build-backend = "hatchling.build" + +[project] +name = "emlearn-micropython-stubs" +version = "0.11.1" +description = "Stub-only package for emlearn MicroPython modules" +requires-python = ">=3.8" +license = { text = "MIT" } +authors = [ + { name = "Jon Nordby" } +] +classifiers = [ + "Programming Language :: Python :: 3", + "Typing :: Stubs Only", +] + +[tool.hatch.build.targets.wheel] +include = [ + "*.pyi", +]