Skip to content

Commit d26758c

Browse files
authored
Merge pull request #3 from sommersoft/new_docs
Improve Ref Docs
2 parents a8c887b + 6f5ab0b commit d26758c

10 files changed

+143
-19
lines changed
File renamed without changes.

.travis.yml

Lines changed: 3 additions & 2 deletions
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_vl6180x.py
3030
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3131
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-vl6180x --library_location .
32+
- cd docs && sphinx-build -E -W -b html . _build/html

README.rst

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ Introduction
1010
:target: https://discord.gg/nBQh6qu
1111
:alt: Discord
1212
13+
.. image:: https://travis-ci.org/adafruit/Adafruit_CircuitPython_VL6180X.svg?branch=master
14+
:target: https://travis-ci.org/adafruit/Adafruit_CircuitPython_VL6180X
15+
:alt: Build Status
16+
1317
CircuitPython module for the VL6180X distance sensor. See
14-
examples/simpletest.py for a demo of the usage.
18+
examples/vl6180x_simpletest.py for a demo of the usage.
1519

1620
Dependencies
1721
=============
@@ -27,15 +31,7 @@ This is easily achieved by downloading
2731
Usage Example
2832
=============
2933

30-
See examples/simpletest.py for a demo of the usage.
31-
32-
API Reference
33-
=============
34-
35-
.. toctree::
36-
:maxdepth: 2
37-
38-
api
34+
See examples/vl6180x_simpletest.py for a demo of the usage.
3935

4036
Contributing
4137
============
@@ -67,3 +63,49 @@ Then run the build:
6763
.. code-block:: shell
6864
6965
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-vl6180x --library_location .
66+
67+
Sphinx documentation
68+
-----------------------
69+
70+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
71+
install dependencies (feel free to reuse the virtual environment from above):
72+
73+
.. code-block:: shell
74+
75+
python3 -m venv .env
76+
source .env/bin/activate
77+
pip install Sphinx sphinx-rtd-theme
78+
79+
Now, once you have the virtual environment activated:
80+
81+
.. code-block:: shell
82+
83+
cd docs
84+
sphinx-build -E -W -b html . _build/html
85+
86+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
87+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
88+
locally verify it will pass.
89+
90+
Sphinx documentation
91+
-----------------------
92+
93+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
94+
install dependencies (feel free to reuse the virtual environment from above):
95+
96+
.. code-block:: shell
97+
98+
python3 -m venv .env
99+
source .env/bin/activate
100+
pip install Sphinx sphinx-rtd-theme
101+
102+
Now, once you have the virtual environment activated:
103+
104+
.. code-block:: shell
105+
106+
cd docs
107+
sphinx-build -E -W -b html . _build/html
108+
109+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
110+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
111+
locally verify it will pass.

adafruit_vl6180x.py

Lines changed: 21 additions & 4 deletions
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_VL6180X`
23+
`adafruit_vl6180x`
2424
====================================================
2525
2626
CircuitPython module for the VL6180X distance sensor. See
2727
examples/simpletest.py for a demo of the usage.
2828
2929
* Author(s): Tony DiCola
30+
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
* Adafruit `VL6180X Time of Flight Distance Ranging Sensor (VL6180)
37+
<https://www.adafruit.com/product/3316>`_ (Product ID: 3316)
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

@@ -81,11 +95,13 @@
8195
class VL6180X:
8296
"""Create an instance of the VL6180X distance sensor. You must pass in
8397
the following parameters:
84-
- i2c: An instance of the I2C bus connected to the sensor.
98+
99+
:param i2c: An instance of the I2C bus connected to the sensor.
85100
86101
Optionally you can specify:
87-
- address: The I2C address of the sensor. If not specified the sensor's
88-
default value will be assumed.
102+
103+
:param address: The I2C address of the sensor. If not specified the sensor's
104+
default value will be assumed.
89105
"""
90106

91107
def __init__(self, i2c, address=_VL6180X_DEFAULT_I2C_ADDR):
@@ -169,6 +185,7 @@ def read_lux(self, gain):
169185
def range_status(self):
170186
"""Retrieve the status/error from a previous range read. This will
171187
return a constant value such as:
188+
172189
- ERROR_NONE - No error
173190
- ERROR_SYSERR_1 - System error 1 (see datasheet)
174191
- ERROR_SYSERR_5 - System error 5 (see datasheet)

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

Lines changed: 12 additions & 3 deletions
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 VL6180X 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 = 'AdafruitVl6180xLibrarydoc'
100109

docs/examples.rst

Lines changed: 8 additions & 0 deletions
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/vl6180x_simpletest.py
7+
:caption: examples/vl6180x_simpletest.py
8+
:linenos:

docs/index.rst

Lines changed: 47 additions & 0 deletions
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 VL6180X Time of Flight Distance Ranging Sensor (VL6180) <https://www.adafruit.com/product/3316>
30+
31+
.. toctree::
32+
:caption: Other Links
33+
34+
Download <https://github.com/adafruit/Adafruit_CircuitPython_VL6180X/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)