From 036902b032b580255bdb9a394edc1777e9d77663 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Thu, 16 Jan 2020 12:08:41 -0800 Subject: [PATCH] Sphinx doc first cut --- python/docs/Makefile | 20 +++++++++ python/docs/conf.py | 55 +++++++++++++++++++++++ python/docs/go | 4 ++ python/docs/index.rst | 101 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 180 insertions(+) create mode 100644 python/docs/Makefile create mode 100644 python/docs/conf.py create mode 100644 python/docs/go create mode 100644 python/docs/index.rst diff --git a/python/docs/Makefile b/python/docs/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/python/docs/Makefile @@ -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) diff --git a/python/docs/conf.py b/python/docs/conf.py new file mode 100644 index 0000000..4bebeee --- /dev/null +++ b/python/docs/conf.py @@ -0,0 +1,55 @@ +# 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 sys +import os +sys.path.insert(0, os.path.abspath('..')) + +# -- Project information ----------------------------------------------------- + +project = 'i2cdriver' +copyright = '2020, Excamera Labs' +author = 'Excamera Labs' + + +# -- 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.intersphinx" +] + +intersphinx_mapping = {'https://docs.python.org/3/': None} + +# 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 = 'alabaster' + +# 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'] diff --git a/python/docs/go b/python/docs/go new file mode 100644 index 0000000..81fb7d5 --- /dev/null +++ b/python/docs/go @@ -0,0 +1,4 @@ +set -e + +# pip install --upgrade --force-reinstall .. +make html diff --git a/python/docs/index.rst b/python/docs/index.rst new file mode 100644 index 0000000..067a176 --- /dev/null +++ b/python/docs/index.rst @@ -0,0 +1,101 @@ +.. i2cdriver documentation master file, created by + sphinx-quickstart on Thu Jan 16 10:21:28 2020. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Excamera I2CDriver Python API +============================= + + +zxxx + +.. toctree:: + :maxdepth: 2 + +xxcc + +Official packages are available on PyPI. + +https://pypi.org/project/i2cdriver/ + + +The main page for I2CDriver includes the complete User Guide: + +https://i2cdriver.com + + +System Requirements +------------------- + +Because it is a pure Python module, ``i2cdriver`` can run on any system supported by ``pyserial``. +This includes: + +- Windows 7 or 10 +- Mac OS +- Linux, including all Ubuntu distributions + +Both Python 2.7 and 3.x are supported. + +Installation +------------ + +The ``i2cdriver`` package can be installed from PyPI using ``pip``:: + + $ pip install i2cdriver + +Quick start +----------- + +To connect to the I2CDriver and scan the bus for connected devices:: + + >>> import i2cdriver + >>> i2c = i2cdriver.I2CDriver("/dev/ttyUSB0") + >>> i2c.scan() + -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- + -- -- -- -- 1C -- -- -- + -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- + 48 -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- + 68 -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- + [28, 72, 104] + +To read the temperature in Celsius from a connected LM75 sensor: + + >>> d=i2cdriver.EDS.Temp(i2c) + >>> d.read() + 17.875 + >>> d.read() + 18.0 + +The User Guide at https://i2cdriver.com has more examples. + +Module Contents +--------------- + +.. autoclass:: i2cdriver.I2CDriver + :member-order: bysource + :members: + setspeed, + setpullups, + scan, + reset, + start, + read, + write, + stop, + regwr, + regrd, + getstatus, + monitor + +.. autoclass:: i2cdriver.START +.. autoclass:: i2cdriver.STOP +.. autoclass:: i2cdriver.BYTE