diff --git a/readthedocs.yml b/.readthedocs.yml similarity index 100% rename from readthedocs.yml rename to .readthedocs.yml diff --git a/.travis.yml b/.travis.yml index d479da8..e02b140 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,15 +16,17 @@ deploy: provider: releases api_key: $GITHUB_TOKEN file_glob: true - file: bundles/* + file: $TRAVIS_BUILD_DIR/bundles/* skip_cleanup: true + overwrite: true on: tags: true install: - - pip install pylint circuitpython-build-tools + - pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme script: - pylint adafruit_ht16k33/*.py - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,undefined-variable,wildcard-import examples/*.py) - circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ht16k33 --library_location . + - cd docs && sphinx-build -E -W -b html . _build/html diff --git a/README.rst b/README.rst index 7726650..90c0a0f 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -Introduction +Introduction ============ .. image:: https://readthedocs.org/projects/adafruit-circuitpython-ht16k33/badge/?version=latest @@ -12,12 +12,21 @@ Introduction This is a library for using the I²C-based LED matrices with the HT16K33 chip. It supports both 16x8 and 8x8 matrices, as well as 7- and 14-segment displays. -Note this library is intended for Adafruit CircuitPython's API. For a library -compatible with MicroPython machine API see this library: https://github.com/adafruit/micropython-adafruit-ht16k33 +* **Notes** -Installation + #. This library is intended for Adafruit CircuitPython's API. For a library compatible with MicroPython machine API see this `library `_. + + #. This library does not work with the Trellis 4x4 LED+Keypad board. For that product use: `CircuitPython Trellis Library `_ + +Dependencies ============= -This driver depends on many other libraries! Please install it by downloading +This driver depends on: + +* `Adafruit CircuitPython `_ +* `Bus Device `_ + +Please ensure all dependencies are available on the CircuitPython filesystem. +This is easily achieved by downloading `the Adafruit library and driver bundle `_. Usage Example @@ -65,10 +74,49 @@ Contributions are welcome! Please read our `Code of Conduct `_ before contributing to help this project stay welcoming. -API Reference -============= +Building locally +================ + +To build this library locally you'll need to install the +`circuitpython-build-tools `_ package. + +.. code-block:: shell + + python3 -m venv .env + source .env/bin/activate + pip install circuitpython-build-tools + +Once installed, make sure you are in the virtual environment: + +.. code-block:: shell + + source .env/bin/activate + +Then run the build: + +.. code-block:: shell + + circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ht16k33 --library_location . + +Sphinx documentation +----------------------- + +Sphinx is used to build the documentation based on rST files and comments in the code. First, +install dependencies (feel free to reuse the virtual environment from above): + +.. code-block:: shell + + python3 -m venv .env + source .env/bin/activate + pip install Sphinx sphinx-rtd-theme + +Now, once you have the virtual environment activated: + +.. code-block:: shell -.. toctree:: - :maxdepth: 2 + cd docs + sphinx-build -E -W -b html . _build/html - adafruit_ht16k33/index +This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to +view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to +locally verify it will pass. \ No newline at end of file diff --git a/adafruit_ht16k33/ht16k33.py b/adafruit_ht16k33/ht16k33.py index a29a851..d02b689 100644 --- a/adafruit_ht16k33/ht16k33.py +++ b/adafruit_ht16k33/ht16k33.py @@ -20,7 +20,13 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -""".. currentmodule:: adafruit_ht16k33""" +""" +`adafruit_ht16k33.ht16k33` +=========================== + +* Authors: Radomir Dopieralski & Tony DiCola for Adafruit Industries + +""" from adafruit_bus_device import i2c_device from micropython import const @@ -51,7 +57,7 @@ def _write_cmd(self, byte): self.i2c_device.write(self._temp) def blink_rate(self, rate=None): - """Get or set the blink rate. Range 0-3.""" + """The blink rate. Range 0-3.""" if rate is None: return self._blink_rate rate = rate & 0x03 @@ -61,7 +67,7 @@ def blink_rate(self, rate=None): return None def brightness(self, brightness): - """Get or set the brightness. Range 0-15.""" + """The brightness. Range 0-15.""" if brightness is None: return self._brightness brightness = brightness & 0x0F diff --git a/adafruit_ht16k33/index.rst b/adafruit_ht16k33/index.rst deleted file mode 100644 index e7528fc..0000000 --- a/adafruit_ht16k33/index.rst +++ /dev/null @@ -1,21 +0,0 @@ - -Variety of HT16K33 displays -=========================================== - -`ht16k33` - Base class for the displays ------------------------------------------------------ - -.. automodule:: adafruit_ht16k33.ht16k33 - :members: - -`matrix` - Matrix of dots in the displays ------------------------------------------------------ - -.. automodule:: adafruit_ht16k33.matrix - :members: - -`segments` - Segment display such as those on alarm clocks ------------------------------------------------------------- - -.. automodule:: adafruit_ht16k33.segments - :members: diff --git a/adafruit_ht16k33/matrix.py b/adafruit_ht16k33/matrix.py index da1b44b..9b0bd06 100644 --- a/adafruit_ht16k33/matrix.py +++ b/adafruit_ht16k33/matrix.py @@ -20,10 +20,11 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Matrix Displays -**************** +""" +Matrix Displays +================ -.. currentmodule:: adafruit_ht16k33.matrix""" +""" from adafruit_ht16k33.ht16k33 import HT16K33 diff --git a/adafruit_ht16k33/segments.py b/adafruit_ht16k33/segments.py index d58f38a..3aab115 100644 --- a/adafruit_ht16k33/segments.py +++ b/adafruit_ht16k33/segments.py @@ -20,10 +20,10 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -"""Segment Displays -**************** - -.. currentmodule:: adafruit_ht16k33.segments""" +""" +Segment Displays +================= +""" from adafruit_ht16k33.ht16k33 import HT16K33 diff --git a/docs/_static/favicon.ico b/docs/_static/favicon.ico new file mode 100644 index 0000000..5aca983 Binary files /dev/null and b/docs/_static/favicon.ico differ diff --git a/docs/api.rst b/docs/api.rst new file mode 100644 index 0000000..93d4a76 --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,11 @@ + +.. If you created a package, create one automodule per module in the package. + +.. automodule:: adafruit_ht16k33.ht16k33 + :members: + +.. automodule:: adafruit_ht16k33.matrix + :members: + +.. automodule:: adafruit_ht16k33.segments + :members: \ No newline at end of file diff --git a/conf.py b/docs/conf.py similarity index 90% rename from conf.py rename to docs/conf.py index c720358..1a97cbd 100644 --- a/conf.py +++ b/docs/conf.py @@ -2,7 +2,7 @@ import os import sys -sys.path.insert(0, os.path.abspath('.')) +sys.path.insert(0, os.path.abspath('..')) # -- General configuration ------------------------------------------------ @@ -23,16 +23,13 @@ intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None), 'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} -# Libraries we depend on but don't need for generating docs. -autodoc_mock_imports = [] - # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] source_suffix = '.rst' # The master toctree document. -master_doc = 'README' +master_doc = 'index' # General information about the project. project = u'Adafruit HT16K33 Library' @@ -58,7 +55,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md'] # The reST default role (used for this markup: `text`) to use for all # documents. @@ -75,6 +72,9 @@ # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False +# If this is True, todo emits a warning for each TODO entries. The default is False. +todo_emit_warnings = True + # -- Options for HTML output ---------------------------------------------- @@ -99,6 +99,12 @@ # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# +html_favicon = '_static/favicon.ico' + # Output file base name for HTML help builder. htmlhelp_basename = 'AdafruitHT16K33Librarydoc' diff --git a/docs/examples.rst b/docs/examples.rst new file mode 100644 index 0000000..ab9c3a8 --- /dev/null +++ b/docs/examples.rst @@ -0,0 +1,12 @@ +Simple test +------------ + +Ensure your device works with this simple test. + +.. literalinclude:: ../examples/matrix.py + :caption: examples/matrix.py + :linenos: + +.. literalinclude:: ../examples/segments.py + :caption: examples/segments.py + :linenos: diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..8f1a122 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,47 @@ +.. include:: ../README.rst + +Table of Contents +================= + +.. toctree:: + :maxdepth: 4 + :hidden: + + self + +.. toctree:: + :caption: Examples + + examples + +.. toctree:: + :caption: API Reference + :maxdepth: 3 + + api + +.. toctree:: + :caption: Tutorials + +.. toctree:: + :caption: Related Products + + Adafruit HT16K33 Products + +.. toctree:: + :caption: Other Links + + Download + CircuitPython Reference Documentation + CircuitPython Support Forum + Discord Chat + Adafruit Learning System + Adafruit Blog + Adafruit Store + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search`