Skip to content

Commit 2b763c3

Browse files
authored
Merge pull request #3 from sommersoft/new_docs
Improve Ref Docs
2 parents a305a54 + 9730497 commit 2b763c3

File tree

10 files changed

+149
-21
lines changed

10 files changed

+149
-21
lines changed
File renamed without changes.

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ 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
21+
overwrite: true
2122
on:
2223
tags: true
2324

2425
install:
25-
- pip install pylint circuitpython-build-tools
26+
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
2627

2728
script:
2829
- pylint adafruit_tcs34725.py
2930
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3031
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-tcs34725 --library_location .
32+
- cd docs && sphinx-build -E -W -b html . _build/html
33+

README.rst

Lines changed: 49 additions & 6 deletions
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_TCS34725.svg?branch=master
14+
:target: https://travis-ci.org/adafruit/Adafruit_CircuitPython_TCS34725
15+
:alt: Build Status
16+
1317
CircuitPython module for the TCS34725 color sensor.
1418

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

29-
See examples/simpletest.py for an example of the module's usage.
33+
See examples/tcs34725_simpletest.py for an example of the module's usage.
3034

3135
Contributing
3236
============
@@ -35,10 +39,49 @@ Contributions are welcome! Please read our `Code of Conduct
3539
<https://github.com/adafruit/Adafruit_CircuitPython_tcs34725/blob/master/CODE_OF_CONDUCT.md>`_
3640
before contributing to help this project stay welcoming.
3741

38-
API Reference
39-
=============
42+
Building locally
43+
================
44+
45+
To build this library locally you'll need to install the
46+
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
47+
48+
.. code-block:: shell
49+
50+
python3 -m venv .env
51+
source .env/bin/activate
52+
pip install circuitpython-build-tools
53+
54+
Once installed, make sure you are in the virtual environment:
55+
56+
.. code-block:: shell
57+
58+
source .env/bin/activate
59+
60+
Then run the build:
61+
62+
.. code-block:: shell
63+
64+
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-tcs34725 --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
4081
41-
.. toctree::
42-
:maxdepth: 2
82+
cd docs
83+
sphinx-build -E -W -b html . _build/html
4384
44-
api
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_tcs34725.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,28 @@
2525
2626
CircuitPython module for the TCS34725 color sensor. Ported from the
2727
micropython-adafruit-tcs34725 module by Radomir Dopieralski:
28-
https://github.com/adafruit/micropython-adafruit-tcs34725
28+
https://github.com/adafruit/micropython-adafruit-tcs34725
2929
30-
See examples/simpletest.py for an example of the usage.
30+
See examples/tcs34725_simpletest.py for an example of the usage.
3131
3232
* Author(s): Tony DiCola
33+
34+
Implementation Notes
35+
--------------------
36+
37+
**Hardware:**
38+
39+
* Adafruit `RGB Color Sensor with IR filter and White LED - TCS34725
40+
<https://www.adafruit.com/product/1334>`_ (Product ID: 1334)
41+
42+
* Flora `Color Sensor with White Illumination LED - TCS34725
43+
<https://www.adafruit.com/product/1356>`_ (Product ID: 1356)
44+
45+
**Software and Dependencies:**
46+
47+
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
48+
https://github.com/adafruit/circuitpython/releases
49+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
3350
"""
3451
import time
3552

@@ -127,7 +144,7 @@ def _write_u16(self, address, val):
127144

128145
@property
129146
def active(self):
130-
"""Get and set the active state of the sensor. Boolean value that will
147+
"""The active state of the sensor. Boolean value that will
131148
enable/activate the sensor with a value of True and disable with a
132149
value of False.
133150
"""
@@ -150,7 +167,7 @@ def active(self, val):
150167

151168
@property
152169
def integration_time(self):
153-
"""Get and set the integration time of the sensor in milliseconds."""
170+
"""The integration time of the sensor in milliseconds."""
154171
return self._integration_time
155172

156173
@integration_time.setter
@@ -162,7 +179,7 @@ def integration_time(self, val):
162179

163180
@property
164181
def gain(self):
165-
"""Get and set the gain of the sensor. Should be a value of 1, 4, 16,
182+
"""The gain of the sensor. Should be a value of 1, 4, 16,
166183
or 60.
167184
"""
168185
return _GAINS[self._read_u8(_REGISTER_CONTROL)]
@@ -174,8 +191,7 @@ def gain(self, val):
174191

175192
@property
176193
def interrupt(self):
177-
"""Get and clear the interrupt of the sensor. Returns a bool that's
178-
True if the interrupt is set. Can be set to False (and only False)
194+
"""True if the interrupt is set. Can be set to False (and only False)
179195
to clear the interrupt.
180196
"""
181197
return bool(self._read_u8(_REGISTER_STATUS) & _ENABLE_AIEN)
@@ -235,7 +251,7 @@ def lux(self):
235251

236252
@property
237253
def cycles(self):
238-
"""Get and set the persistence cycles of the sensor."""
254+
"""The persistence cycles of the sensor."""
239255
if self._read_u8(_REGISTER_ENABLE) & _ENABLE_AIEN:
240256
return _CYCLES[self._read_u8(_REGISTER_APERS) & 0x0f]
241257
return -1
@@ -252,7 +268,7 @@ def cycles(self, val):
252268

253269
@property
254270
def min_value(self):
255-
"""Get and set the minimum threshold value (AILT register) of the
271+
"""The minimum threshold value (AILT register) of the
256272
sensor as a 16-bit unsigned value.
257273
"""
258274
return self._read_u16(_REGISTER_AILT)
@@ -263,7 +279,7 @@ def min_value(self, val):
263279

264280
@property
265281
def max_value(self):
266-
"""Get and set the minimum threshold value (AIHT register) of the
282+
"""The minimum threshold value (AIHT register) of the
267283
sensor as a 16-bit unsigned value.
268284
"""
269285
return self._read_u16(_REGISTER_AIHT)

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 TCS34725 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 = 'AdafruitTCS34725Librarydoc'
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/tcs34725_simpletest.py
7+
:caption: examples/tcs34725_simpletest.py
8+
:linenos:

docs/index.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
RGB Color Sensor with IR filter and White LED - TCS34725 <https://www.adafruit.com/product/1334>
30+
31+
Flora Color Sensor with White Illumination LED - TCS34725 <https://www.adafruit.com/product/1356>
32+
33+
.. toctree::
34+
:caption: Other Links
35+
36+
Download <https://github.com/adafruit/Adafruit_CircuitPython_TCS34725/releases/latest>
37+
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
38+
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
39+
Discord Chat <https://adafru.it/discord>
40+
Adafruit Learning System <https://learn.adafruit.com>
41+
Adafruit Blog <https://blog.adafruit.com>
42+
Adafruit Store <https://www.adafruit.com>
43+
44+
Indices and tables
45+
==================
46+
47+
* :ref:`genindex`
48+
* :ref:`modindex`
49+
* :ref:`search`
File renamed without changes.

0 commit comments

Comments
 (0)