Skip to content

Improve Ref Docs #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 28, 2018
File renamed without changes.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
68 changes: 58 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Introduction
Introduction
============

.. image:: https://readthedocs.org/projects/adafruit-circuitpython-ht16k33/badge/?version=latest
Expand All @@ -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 <https://github.com/adafruit/micropython-adafruit-ht16k33>`_.

#. This library does not work with the Trellis 4x4 LED+Keypad board. For that product use: `CircuitPython Trellis Library <https://github.com/adafruit/Adafruit_CircuitPython_Trellis/releases/latest>`_

Dependencies
=============
This driver depends on many other libraries! Please install it by downloading
This driver depends on:

* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_

Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.

Usage Example
Expand Down Expand Up @@ -65,10 +74,49 @@ Contributions are welcome! Please read our `Code of Conduct
<https://github.com/adafruit/Adafruit_CircuitPython_HT16K33/blob/master/CODE_OF_CONDUCT.md>`_
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 <https://github.com/adafruit/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.
12 changes: 9 additions & 3 deletions adafruit_ht16k33/ht16k33.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
21 changes: 0 additions & 21 deletions adafruit_ht16k33/index.rst

This file was deleted.

7 changes: 4 additions & 3 deletions adafruit_ht16k33/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 6 additions & 5 deletions adafruit_ht16k33/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
# 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

# pylint disable=bad-whitespace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the white space issue here is that there should be two spaces before the #. If this is the case, I would rather we add the extra space than disable pylint. If that's not the issue, let me know and we can discuss the options.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it was a guess. Per the "my Travis is borked" commit, Travis was taking time in resyncing the deleted->re-forked repo. It showed me the overall status, but wouldn't load the log so I didn't know what was failing. I can easily remove the disable and see if it passes.

CHARS = (
0b00000000, 0b00000000, #
0b01000000, 0b00000110, # !
Expand Down Expand Up @@ -144,7 +145,7 @@
0x71, # F
0x40, # -
)

# pylint enable=bad-whitespace

class Seg14x4(HT16K33):
"""Alpha-numeric, 14-segment display."""
Expand Down
Binary file added docs/_static/favicon.ico
Binary file not shown.
11 changes: 11 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -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:
18 changes: 12 additions & 6 deletions conf.py → docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import os
import sys
sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('..'))

# -- General configuration ------------------------------------------------

Expand All @@ -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'
Expand All @@ -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.
Expand All @@ -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 ----------------------------------------------

Expand All @@ -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'

Expand Down
12 changes: 12 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -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:
47 changes: 47 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -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 <https://www.adafruit.com/?q=ht16k33>

.. toctree::
:caption: Other Links

Download <https://github.com/adafruit/Adafruit_CircuitPython_HT16K33/releases/latest>
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
Discord Chat <https://adafru.it/discord>
Adafruit Learning System <https://learn.adafruit.com>
Adafruit Blog <https://blog.adafruit.com>
Adafruit Store <https://www.adafruit.com>

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

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