Skip to content

Commit 4b595ea

Browse files
authored
Merge pull request #3 from sommersoft/new_docs
Improve Ref Docs
2 parents c059338 + ff79ea0 commit 4b595ea

10 files changed

+128
-27
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_vcnl4010.py
3030
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3131
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-vcnl4010 --library_location .
32+
- cd docs && sphinx-build -E -W -b html . _build/html

README.rst

+28-9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Introduction
1010
:target: https://discord.gg/nBQh6qu
1111
:alt: Discord
1212
13+
.. image:: https://travis-ci.org/adafruit/Adafruit_CircuitPython_VCNL4010.svg?branch=master
14+
:target: https://travis-ci.org/adafruit/Adafruit_CircuitPython_VCNL4010
15+
:alt: Build Status
16+
1317
CircuitPython module for the VCNL4010 proximity and light sensor.
1418

1519
Dependencies
@@ -26,15 +30,7 @@ This is easily achieved by downloading
2630
Usage Example
2731
=============
2832

29-
See examples/simpletest.py for an example of the usage.
30-
31-
API Reference
32-
=============
33-
34-
.. toctree::
35-
:maxdepth: 2
36-
37-
api
33+
See examples/vcnl4010_simpletest.py for an example of the usage.
3834

3935
Contributing
4036
============
@@ -66,3 +62,26 @@ Then run the build:
6662
.. code-block:: shell
6763
6864
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-vcnl4010 --library_location .
65+
66+
Sphinx documentation
67+
-----------------------
68+
69+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
70+
install dependencies (feel free to reuse the virtual environment from above):
71+
72+
.. code-block:: shell
73+
74+
python3 -m venv .env
75+
source .env/bin/activate
76+
pip install Sphinx sphinx-rtd-theme
77+
78+
Now, once you have the virtual environment activated:
79+
80+
.. code-block:: shell
81+
82+
cd docs
83+
sphinx-build -E -W -b html . _build/html
84+
85+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
86+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
87+
locally verify it will pass.

adafruit_vcnl4010.py

+29-13
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,27 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222
"""
23-
`Adafruit_VCNL4010`
23+
`adafruit_vcnl4010`
2424
====================================================
2525
2626
CircuitPython module for the VCNL4010 proximity and light sensor. See
27-
examples/simpletest.py for an example of the usage.
27+
examples/vcnl4010_simpletest.py for an example of the usage.
2828
2929
* Author(s): Tony DiCola
30+
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
* Adafruit `VCNL4010 Proximity/Light sensor breakout
37+
<https://www.adafruit.com/product/466>`_ (Product ID: 466)
38+
39+
**Software and Dependencies:**
40+
41+
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
42+
https://github.com/adafruit/circuitpython/releases
43+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
3044
"""
3145
from micropython import const
3246

@@ -114,7 +128,7 @@ def _write_u8(self, address, val):
114128

115129
@property
116130
def led_current(self):
117-
"""Get and set the current of the LED. The value is in units of 10mA
131+
"""The current of the LED. The value is in units of 10mA
118132
and can only be set to 0 (0mA/off) to 20 (200mA). See the datasheet
119133
for how LED current impacts proximity measurements. The default is
120134
200mA.
@@ -128,7 +142,7 @@ def led_current(self, val):
128142

129143
@property
130144
def led_current_mA(self):
131-
"""Get and set the current of the LED in milli-amps. The value here is
145+
"""The current of the LED in milli-amps. The value here is
132146
specified in a milliamps from 0-200. Note that this value will be
133147
quantized down to a smaller less-accurate value as the chip only
134148
supports current changes in 10mA increments, i.e. a value of 123 mA will
@@ -144,12 +158,14 @@ def led_current_mA(self, val):
144158

145159
@property
146160
def frequency(self):
147-
"""Get and set the frequency of proximity measurements. Must be a value
148-
of:
149-
- FREQUENCY_3M125: 3.125 Mhz
150-
- FREQUENCY_1M5625: 1.5625 Mhz
151-
- FREQUENCY_781K25: 781.25 Khz
152-
- FREQUENCY_390K625: 390.625 Khz (default)
161+
"""
162+
The frequency of proximity measurements. Must be a value of:
163+
164+
- FREQUENCY_3M125: 3.125 Mhz
165+
- FREQUENCY_1M5625: 1.5625 Mhz
166+
- FREQUENCY_781K25: 781.25 Khz
167+
- FREQUENCY_390K625: 390.625 Khz (default)
168+
153169
See the datasheet for how frequency changes the proximity detection
154170
accuracy.
155171
"""
@@ -168,7 +184,7 @@ def frequency(self, val):
168184
# pylint: disable=inconsistent-return-statements
169185
@property
170186
def proximity(self):
171-
"""Get the detected proximity of an object in front of the sensor. This
187+
"""The detected proximity of an object in front of the sensor. This
172188
is a unit-less unsigned 16-bit value (0-65535) INVERSELY proportional
173189
to the distance of an object in front of the sensor (up to a max of
174190
~200mm). For example a value of 10 is an object farther away than a
@@ -189,7 +205,7 @@ def proximity(self):
189205

190206
@property
191207
def ambient(self):
192-
"""Get the detected ambient light in front of the sensor. This is
208+
"""The detected ambient light in front of the sensor. This is
193209
a unit-less unsigned 16-bit value (0-65535) with higher values for
194210
more detected light. See the ambient_lux property for a value in lux.
195211
"""
@@ -208,7 +224,7 @@ def ambient(self):
208224

209225
@property
210226
def ambient_lux(self):
211-
"""Get the detected ambient light in front of the sensor as a value in
227+
"""The detected ambient light in front of the sensor as a value in
212228
lux.
213229
"""
214230
return self.ambient * _VCNL4010_AMBIENT_LUX_SCALE

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

+12-3
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,7 +28,7 @@
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 VCNL4010 Library'
@@ -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 = 'AdafruitVcnl4010Librarydoc'
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/vcnl4010_simpletest.py
7+
:caption: examples/vcnl4010_simpletest.py
8+
:linenos:

docs/index.rst

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
VCNL4010 Proximity/Light sensor <https://www.adafruit.com/product/466>
30+
31+
32+
.. toctree::
33+
:caption: Other Links
34+
35+
Download <https://github.com/adafruit/Adafruit_CircuitPython_VCNL4010/releases/latest>
36+
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
37+
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
38+
Discord Chat <https://adafru.it/discord>
39+
Adafruit Learning System <https://learn.adafruit.com>
40+
Adafruit Blog <https://blog.adafruit.com>
41+
Adafruit Store <https://www.adafruit.com>
42+
43+
Indices and tables
44+
==================
45+
46+
* :ref:`genindex`
47+
* :ref:`modindex`
48+
* :ref:`search`
File renamed without changes.

0 commit comments

Comments
 (0)