Skip to content

Commit d8fe708

Browse files
authored
Merge pull request #3 from sommersoft/new_docs
Improve Ref Docs
2 parents b0a3641 + c0fd0a4 commit d8fe708

10 files changed

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

README.rst

+25-9
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,7 @@ This is easily achieved by downloading
3030
Usage Example
3131
=============
3232

33-
See examples/simpletest.py for a demo of the usage.
34-
35-
API Reference
36-
=============
37-
38-
.. toctree::
39-
:maxdepth: 2
40-
41-
api
33+
See examples/tsl2591_simpletest.py for a demo of the usage.
4234

4335
Contributing
4436
============
@@ -70,3 +62,27 @@ Then run the build:
7062
.. code-block:: shell
7163
7264
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-tsl2591 --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.
88+

adafruit_tsl2591.py

+24-10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@
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 `TSL2591 High Dynamic Range Digital Light Sensor
37+
<https://www.adafruit.com/product/1980>`_ (Product ID: 1980)
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

@@ -149,10 +163,10 @@ def disable(self):
149163
def gain(self):
150164
"""Get and set the gain of the sensor. Can be a value of:
151165
152-
- `GAIN_LOW` (1x)
153-
- `GAIN_MED` (25x)
154-
- `GAIN_HIGH` (428x)
155-
- `GAIN_MAX` (9876x)
166+
- ``GAIN_LOW`` (1x)
167+
- ``GAIN_MED`` (25x)
168+
- ``GAIN_HIGH`` (428x)
169+
- ``GAIN_MAX`` (9876x)
156170
"""
157171
control = self._read_u8(_TSL2591_REGISTER_CONTROL)
158172
return control & 0b00110000
@@ -172,12 +186,12 @@ def gain(self, val):
172186
def integration_time(self):
173187
"""Get and set the integration time of the sensor. Can be a value of:
174188
175-
- `INTEGRATIONTIME_100MS` (100 millis)
176-
- `INTEGRATIONTIME_200MS` (200 millis)
177-
- `INTEGRATIONTIME_300MS` (300 millis)
178-
- `INTEGRATIONTIME_400MS` (400 millis)
179-
- `INTEGRATIONTIME_500MS` (500 millis)
180-
- `INTEGRATIONTIME_600MS` (600 millis)
189+
- ``INTEGRATIONTIME_100MS`` (100 millis)
190+
- ``INTEGRATIONTIME_200MS`` (200 millis)
191+
- ``INTEGRATIONTIME_300MS`` (300 millis)
192+
- ``INTEGRATIONTIME_400MS`` (400 millis)
193+
- ``INTEGRATIONTIME_500MS`` (500 millis)
194+
- ``INTEGRATIONTIME_600MS`` (600 millis)
181195
"""
182196
control = self._read_u8(_TSL2591_REGISTER_CONTROL)
183197
return control & 0b00000111

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

+13-4
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 TSL2591 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

@@ -93,7 +96,13 @@
9396
# Add any paths that contain custom static files (such as style sheets) here,
9497
# relative to this directory. They are copied after the builtin static files,
9598
# so a file named "default.css" will overwrite the builtin "default.css".
96-
#html_static_path = ['_static']
99+
html_static_path = ['_static']
100+
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'
97106

98107
# Output file base name for HTML help builder.
99108
htmlhelp_basename = 'AdafruitTsl2591Librarydoc'

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/tsl2591_simpletest.py
7+
:caption: examples/tsl2591_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 TSL2591 High Dynamic Range Digital Light Sensor <https://www.adafruit.com/product/1980>
30+
31+
.. toctree::
32+
:caption: Other Links
33+
34+
Download <https://github.com/adafruit/Adafruit_CircuitPython_TSL2591/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)