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 21521c8..51987ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/README.rst b/README.rst index a96fbc6..c30f7f4 100644 --- a/README.rst +++ b/README.rst @@ -47,14 +47,6 @@ Usage Example time.sleep(1) -API Reference -============= - -.. toctree:: - :maxdepth: 2 - - api - Contributing ============ @@ -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. \ No newline at end of file diff --git a/adafruit_veml6070.py b/adafruit_veml6070.py index ad28cd7..db8fb98 100644 --- a/adafruit_veml6070.py +++ b/adafruit_veml6070.py @@ -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. @@ -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 @@ -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 @@ -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): @@ -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'.") @@ -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: ", @@ -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) @@ -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 @@ -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 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/api.rst b/docs/api.rst similarity index 100% rename from api.rst rename to docs/api.rst diff --git a/conf.py b/docs/conf.py similarity index 89% rename from conf.py rename to docs/conf.py index 1d2a3ac..16c3e67 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 ------------------------------------------------ @@ -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 @@ -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. @@ -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 ---------------------------------------------- @@ -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' diff --git a/docs/examples.rst b/docs/examples.rst new file mode 100644 index 0000000..3f68c96 --- /dev/null +++ b/docs/examples.rst @@ -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: diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..b517e97 --- /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 VEML6070 UV Index Sensor Breakout + +.. 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` diff --git a/examples/read_uv.py b/examples/veml6070_simpletest.py similarity index 100% rename from examples/read_uv.py rename to examples/veml6070_simpletest.py