Skip to content

Improved Ref Docs #2

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 11 commits into from
Feb 22, 2018
File renamed without changes.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +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_veml6070.py
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-veml6070 --library_location .
- cd docs && sphinx-build -E -W -b html . _build/html
31 changes: 23 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ Usage Example
time.sleep(1)


API Reference
=============

.. toctree::
:maxdepth: 2

api

Contributing
============

Expand Down Expand Up @@ -85,3 +77,26 @@ Then run the build:
.. code-block:: shell

circuitpython-build-bundles --filename_prefix adafruit-circuitpython-veml6070 --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

cd docs
sphinx-build -E -W -b html . _build/html

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.
38 changes: 20 additions & 18 deletions adafruit_veml6070.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# CircuitPython Library Author: Michael Schroeder(sommersoft). No
# affiliation to Adafruit is implied.
"""
`adafruit_VEML6070` - VEML6070 UV Sensor
`adafruit_veml6070` - VEML6070 UV Sensor
====================================================

CircuitPython library to support VEML6070 UV Index sensor.
Expand All @@ -46,7 +46,7 @@

"""

__version__ = "1.0.0"
__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_VEML6070.git"

from adafruit_bus_device.i2c_device import I2CDevice
Expand Down Expand Up @@ -83,19 +83,20 @@ class VEML6070:

:param i2c_bus: The `busio.I2C` object to use. This is the only required parameter.
:param str _veml6070_it: The integration time you'd like to set initially. Availble
options: `VEML6070_HALF_T`, `VEML6070_1_T`, `VEML6070_2_T`, and
`VEML6070_4_T`. The higher the '_x_' value, the more accurate
options: ``VEML6070_HALF_T``, ``VEML6070_1_T``, ``VEML6070_2_T``, and
``VEML6070_4_T``. The higher the '_x_' value, the more accurate
the reading is (at the cost of less samples per reading).
Defaults to `VEML6070_1_T` if parameter not passed. To change
Defaults to ``VEML6070_1_T`` if parameter not passed. To change
setting after intialization, use
`[veml6070].set_integration_time(new_it)`.
:param bool ack: The inital setting of `ACKnowledge` on alert. Defaults to `False`
``[veml6070].set_integration_time(new_it)``.
:param bool ack: The inital setting of ``ACKnowledge`` on alert. Defaults to ``False``
if parameter not passed. To change setting after intialization,
use `[veml6070].set_ack(new_ack)`.
use ``[veml6070].set_ack(new_ack)``.

Example:

.. code-block:: python

from board import *
import busio, veml6070, time

Expand Down Expand Up @@ -164,7 +165,7 @@ def set_ack(self, new_ack=False):
"""
Turns on or off the ACKnowledge function of the sensor. The ACK function will send
a signal to the host when the value of the sensed UV light changes beyond the
programmed threshold. Use `[veml6070].set_ack_threshold` to change between the two
programmed threshold. Use ``[veml6070].set_ack_threshold`` to change between the two
available threshold settings.
"""
if new_ack not in (True, False):
Expand All @@ -178,8 +179,8 @@ def set_ack(self, new_ack=False):
def set_ack_threshold(self, new_ack_thd=0):
"""
Sets the ACKnowledge Threshold, which alerts the host controller to value changes
greater than the threshold. Available settings are: `0` = 102 steps; `1` = 145 steps.
`0` is the default setting.
greater than the threshold. Available settings are: ``0`` = 102 steps; ``1`` = 145 steps.
``0`` is the default setting.
"""
if new_ack_thd not in (0, 1):
raise ValueError("ACK Threshold must be '0' or '1'.")
Expand All @@ -194,8 +195,8 @@ def set_integration_time(self, new_it):
"""
Sets the Integration Time of the sensor. This is the refresh interval of the
sensor. The higher the refresh interval, the more accurate the reading is (at
the cost of less sampling). The available settings are: `VEML6070_HALF_T`,
`VEML6070_1_T`, `VEML6070_2_T`, `VEML6070_4_T`.
the cost of less sampling). The available settings are: ``VEML6070_HALF_T``,
``VEML6070_1_T``, ``VEML6070_2_T``, ``VEML6070_4_T``.
"""
if new_it not in _VEML6070_INTEGRATION_TIME:
raise ValueError("Integration Time invalid. Valid values are: ",
Expand All @@ -218,7 +219,7 @@ def sleep(self):

def wake(self):
"""
Wakes the VEML6070 from sleep. `[veml6070].read` will also wake from sleep.
Wakes the VEML6070 from sleep. ``[veml6070].read`` will also wake from sleep.
"""
self.buf[0] = (self._ack << 5 | self._ack_thd << 4 |
_VEML6070_INTEGRATION_TIME[self._it][0] << 2 | 0x02)
Expand All @@ -227,8 +228,8 @@ def wake(self):

def get_index(self, _raw):
"""
Calculates the UV Risk Level based on the captured UV reading. Requres the `_raw`
argument (from `veml6070.read`). Risk level is available for Integration Times (IT)
Calculates the UV Risk Level based on the captured UV reading. Requres the ``_raw``
argument (from ``veml6070.read``). Risk level is available for Integration Times (IT)
1, 2, & 4. The result is automatically scaled to the current IT setting.

LEVEL* UV Index
Expand All @@ -240,8 +241,9 @@ def get_index(self, _raw):
EXTREME >=11

* Not to be considered as accurate condition reporting.
Calculation is based on VEML6070 Application Notes:
http://www.vishay.com/docs/84310/designingveml6070.pdf
Calculation is based on VEML6070 Application Notes:
http://www.vishay.com/docs/84310/designingveml6070.pdf

"""

# get the divisor for the current IT
Expand Down
Binary file added docs/_static/favicon.ico
Binary file not shown.
File renamed without changes.
19 changes: 14 additions & 5 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 @@ -28,12 +28,12 @@
source_suffix = '.rst'

# The master toctree document.
master_doc = 'README'
master_doc = 'index'

# General information about the project.
project = u'Adafruit VEML6070 Library'
copyright = u'2017 Michael Schroeder(sommersoft)'
author = u'Michael Schroeder(sommersoft)'
copyright = u'2017 Limor Fried & Michael Schroeder'
author = u'Limor Fried & Michael Schroeder'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -54,7 +54,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 @@ -71,6 +71,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 @@ -95,6 +98,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 = 'AdafruitVeml6070Librarydoc'

Expand Down
8 changes: 8 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Simple test
------------

Ensure your device works with this simple test.

.. literalinclude:: ../examples/veml6070_simpletest.py
:caption: examples/veml6070_simpletest.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 VEML6070 UV Index Sensor Breakout <https://www.adafruit.com/product/2899>

.. toctree::
:caption: Other Links

Download <https://github.com/adafruit/Adafruit_CircuitPython_VEML6070/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`
File renamed without changes.