Skip to content

Commit 1d055af

Browse files
authored
Merge pull request #2 from sommersoft/new_docs
Improved Ref Docs
2 parents 3a28f32 + 61d169c commit 1d055af

10 files changed

+115
-33
lines changed
File renamed without changes.

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ deploy:
1616
provider: releases
1717
api_key: $GITHUB_TOKEN
1818
file_glob: true
19-
file: bundles/*
19+
file: $TRAVIS_BUILD_DIR/bundles/*
2020
skip_cleanup: true
2121
overwrite: true
2222
on:
2323
tags: true
2424

2525
install:
26-
- pip install pylint circuitpython-build-tools
26+
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
2727

2828
script:
2929
- pylint adafruit_veml6070.py
3030
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3131
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-veml6070 --library_location .
32+
- cd docs && sphinx-build -E -W -b html . _build/html

README.rst

+23-8
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ Usage Example
4747
time.sleep(1)
4848
4949
50-
API Reference
51-
=============
52-
53-
.. toctree::
54-
:maxdepth: 2
55-
56-
api
57-
5850
Contributing
5951
============
6052

@@ -85,3 +77,26 @@ Then run the build:
8577
.. code-block:: shell
8678
8779
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-veml6070 --library_location .
80+
81+
Sphinx documentation
82+
-----------------------
83+
84+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
85+
install dependencies (feel free to reuse the virtual environment from above):
86+
87+
.. code-block:: shell
88+
89+
python3 -m venv .env
90+
source .env/bin/activate
91+
pip install Sphinx sphinx-rtd-theme
92+
93+
Now, once you have the virtual environment activated:
94+
95+
.. code-block:: shell
96+
97+
cd docs
98+
sphinx-build -E -W -b html . _build/html
99+
100+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
101+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
102+
locally verify it will pass.

adafruit_veml6070.py

+20-18
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# CircuitPython Library Author: Michael Schroeder(sommersoft). No
2020
# affiliation to Adafruit is implied.
2121
"""
22-
`adafruit_VEML6070` - VEML6070 UV Sensor
22+
`adafruit_veml6070` - VEML6070 UV Sensor
2323
====================================================
2424
2525
CircuitPython library to support VEML6070 UV Index sensor.
@@ -46,7 +46,7 @@
4646
4747
"""
4848

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

5252
from adafruit_bus_device.i2c_device import I2CDevice
@@ -83,19 +83,20 @@ class VEML6070:
8383
8484
:param i2c_bus: The `busio.I2C` object to use. This is the only required parameter.
8585
:param str _veml6070_it: The integration time you'd like to set initially. Availble
86-
options: `VEML6070_HALF_T`, `VEML6070_1_T`, `VEML6070_2_T`, and
87-
`VEML6070_4_T`. The higher the '_x_' value, the more accurate
86+
options: ``VEML6070_HALF_T``, ``VEML6070_1_T``, ``VEML6070_2_T``, and
87+
``VEML6070_4_T``. The higher the '_x_' value, the more accurate
8888
the reading is (at the cost of less samples per reading).
89-
Defaults to `VEML6070_1_T` if parameter not passed. To change
89+
Defaults to ``VEML6070_1_T`` if parameter not passed. To change
9090
setting after intialization, use
91-
`[veml6070].set_integration_time(new_it)`.
92-
:param bool ack: The inital setting of `ACKnowledge` on alert. Defaults to `False`
91+
``[veml6070].set_integration_time(new_it)``.
92+
:param bool ack: The inital setting of ``ACKnowledge`` on alert. Defaults to ``False``
9393
if parameter not passed. To change setting after intialization,
94-
use `[veml6070].set_ack(new_ack)`.
94+
use ``[veml6070].set_ack(new_ack)``.
9595
9696
Example:
9797
9898
.. code-block:: python
99+
99100
from board import *
100101
import busio, veml6070, time
101102
@@ -164,7 +165,7 @@ def set_ack(self, new_ack=False):
164165
"""
165166
Turns on or off the ACKnowledge function of the sensor. The ACK function will send
166167
a signal to the host when the value of the sensed UV light changes beyond the
167-
programmed threshold. Use `[veml6070].set_ack_threshold` to change between the two
168+
programmed threshold. Use ``[veml6070].set_ack_threshold`` to change between the two
168169
available threshold settings.
169170
"""
170171
if new_ack not in (True, False):
@@ -178,8 +179,8 @@ def set_ack(self, new_ack=False):
178179
def set_ack_threshold(self, new_ack_thd=0):
179180
"""
180181
Sets the ACKnowledge Threshold, which alerts the host controller to value changes
181-
greater than the threshold. Available settings are: `0` = 102 steps; `1` = 145 steps.
182-
`0` is the default setting.
182+
greater than the threshold. Available settings are: ``0`` = 102 steps; ``1`` = 145 steps.
183+
``0`` is the default setting.
183184
"""
184185
if new_ack_thd not in (0, 1):
185186
raise ValueError("ACK Threshold must be '0' or '1'.")
@@ -194,8 +195,8 @@ def set_integration_time(self, new_it):
194195
"""
195196
Sets the Integration Time of the sensor. This is the refresh interval of the
196197
sensor. The higher the refresh interval, the more accurate the reading is (at
197-
the cost of less sampling). The available settings are: `VEML6070_HALF_T`,
198-
`VEML6070_1_T`, `VEML6070_2_T`, `VEML6070_4_T`.
198+
the cost of less sampling). The available settings are: ``VEML6070_HALF_T``,
199+
``VEML6070_1_T``, ``VEML6070_2_T``, ``VEML6070_4_T``.
199200
"""
200201
if new_it not in _VEML6070_INTEGRATION_TIME:
201202
raise ValueError("Integration Time invalid. Valid values are: ",
@@ -218,7 +219,7 @@ def sleep(self):
218219

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

228229
def get_index(self, _raw):
229230
"""
230-
Calculates the UV Risk Level based on the captured UV reading. Requres the `_raw`
231-
argument (from `veml6070.read`). Risk level is available for Integration Times (IT)
231+
Calculates the UV Risk Level based on the captured UV reading. Requres the ``_raw``
232+
argument (from ``veml6070.read``). Risk level is available for Integration Times (IT)
232233
1, 2, & 4. The result is automatically scaled to the current IT setting.
233234
234235
LEVEL* UV Index
@@ -240,8 +241,9 @@ def get_index(self, _raw):
240241
EXTREME >=11
241242
242243
* Not to be considered as accurate condition reporting.
243-
Calculation is based on VEML6070 Application Notes:
244-
http://www.vishay.com/docs/84310/designingveml6070.pdf
244+
Calculation is based on VEML6070 Application Notes:
245+
http://www.vishay.com/docs/84310/designingveml6070.pdf
246+
245247
"""
246248

247249
# get the divisor for the current IT

docs/_static/favicon.ico

4.31 KB
Binary file not shown.

api.rst renamed to docs/api.rst

File renamed without changes.

conf.py renamed to docs/conf.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44
import sys
5-
sys.path.insert(0, os.path.abspath('.'))
5+
sys.path.insert(0, os.path.abspath('..'))
66

77
# -- General configuration ------------------------------------------------
88

@@ -28,12 +28,12 @@
2828
source_suffix = '.rst'
2929

3030
# The master toctree document.
31-
master_doc = 'README'
31+
master_doc = 'index'
3232

3333
# General information about the project.
3434
project = u'Adafruit VEML6070 Library'
35-
copyright = u'2017 Michael Schroeder(sommersoft)'
36-
author = u'Michael Schroeder(sommersoft)'
35+
copyright = u'2017 Limor Fried & Michael Schroeder'
36+
author = u'Limor Fried & Michael Schroeder'
3737

3838
# The version info for the project you're documenting, acts as replacement for
3939
# |version| and |release|, also used in various other places throughout the
@@ -54,7 +54,7 @@
5454
# List of patterns, relative to source directory, that match files and
5555
# directories to ignore when looking for source files.
5656
# This patterns also effect to html_static_path and html_extra_path
57-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
57+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
5858

5959
# The reST default role (used for this markup: `text`) to use for all
6060
# documents.
@@ -71,6 +71,9 @@
7171
# If true, `todo` and `todoList` produce output, else they produce nothing.
7272
todo_include_todos = False
7373

74+
# If this is True, todo emits a warning for each TODO entries. The default is False.
75+
todo_emit_warnings = True
76+
7477

7578
# -- Options for HTML output ----------------------------------------------
7679

@@ -95,6 +98,12 @@
9598
# so a file named "default.css" will overwrite the builtin "default.css".
9699
html_static_path = ['_static']
97100

101+
# The name of an image file (relative to this directory) to use as a favicon of
102+
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
103+
# pixels large.
104+
#
105+
html_favicon = '_static/favicon.ico'
106+
98107
# Output file base name for HTML help builder.
99108
htmlhelp_basename = 'AdafruitVeml6070Librarydoc'
100109

docs/examples.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Simple test
2+
------------
3+
4+
Ensure your device works with this simple test.
5+
6+
.. literalinclude:: ../examples/veml6070_simpletest.py
7+
:caption: examples/veml6070_simpletest.py
8+
:linenos:

docs/index.rst

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.. include:: ../README.rst
2+
3+
Table of Contents
4+
=================
5+
6+
.. toctree::
7+
:maxdepth: 4
8+
:hidden:
9+
10+
self
11+
12+
.. toctree::
13+
:caption: Examples
14+
15+
examples
16+
17+
.. toctree::
18+
:caption: API Reference
19+
:maxdepth: 3
20+
21+
api
22+
23+
.. toctree::
24+
:caption: Tutorials
25+
26+
.. toctree::
27+
:caption: Related Products
28+
29+
Adafruit VEML6070 UV Index Sensor Breakout <https://www.adafruit.com/product/2899>
30+
31+
.. toctree::
32+
:caption: Other Links
33+
34+
Download <https://github.com/adafruit/Adafruit_CircuitPython_VEML6070/releases/latest>
35+
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
36+
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
37+
Discord Chat <https://adafru.it/discord>
38+
Adafruit Learning System <https://learn.adafruit.com>
39+
Adafruit Blog <https://blog.adafruit.com>
40+
Adafruit Store <https://www.adafruit.com>
41+
42+
Indices and tables
43+
==================
44+
45+
* :ref:`genindex`
46+
* :ref:`modindex`
47+
* :ref:`search`
File renamed without changes.

0 commit comments

Comments
 (0)