Skip to content

Commit 222f0f8

Browse files
authored
Merge pull request #7 from sommersoft/new_docs
Improve Ref Docs
2 parents 785f8ba + a2aaa21 commit 222f0f8

10 files changed

+147
-20
lines changed
File renamed without changes.

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +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
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_si7021.py
2930
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3031
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-si7021 --library_location .
32+
- cd docs && sphinx-build -E -W -b html . _build/html

README.rst

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ Introduction
99
:target: https://adafru.it/discord
1010
:alt: Discord
1111

12+
CircuitPython module for use with the SI7021 Temperature and Humidity Sensor.
13+
1214
Dependencies
1315
=============
16+
This driver depends on:
1417

15-
This driver depends on the `Bus Device
16-
<https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_ library.
17-
Please ensure is is also available on the CircuitPython filesystem. This is
18-
easily achieved by downloading `a library and driver bundle
19-
<https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
18+
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
19+
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
2020

21+
Please ensure all dependencies are available on the CircuitPython filesystem.
22+
This is easily achieved by downloading
23+
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
2124

2225
Usage Notes
2326
===========
@@ -28,8 +31,8 @@ Of course, you must import the library to use it:
2831
2932
import adafruit_si7021
3033
31-
This driver takes an instantiated and active I2C object (from the `busio` or
32-
the `bitbangio` library) as an argument to its constructor. The way to create
34+
This driver takes an instantiated and active I2C object (from the ``busio`` or
35+
the ``bitbangio`` library) as an argument to its constructor. The way to create
3336
an I2C object depends on the board you are using. For boards with labeled SCL
3437
and SDA pins, you can:
3538

@@ -63,11 +66,49 @@ Contributions are welcome! Please read our `Code of Conduct
6366
<https://github.com/adafruit/Adafruit_CircuitPython_SI7021/blob/master/CODE_OF_CONDUCT.md>`_
6467
before contributing to help this project stay welcoming.
6568

69+
Building locally
70+
================
6671

67-
API Reference
68-
=============
72+
To build this library locally you'll need to install the
73+
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
74+
75+
.. code-block:: shell
76+
77+
python3 -m venv .env
78+
source .env/bin/activate
79+
pip install circuitpython-build-tools
80+
81+
Once installed, make sure you are in the virtual environment:
82+
83+
.. code-block:: shell
84+
85+
source .env/bin/activate
86+
87+
Then run the build:
88+
89+
.. code-block:: shell
90+
91+
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-si7021 --library_location .
92+
93+
Sphinx documentation
94+
-----------------------
95+
96+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
97+
install dependencies (feel free to reuse the virtual environment from above):
98+
99+
.. code-block:: shell
100+
101+
python3 -m venv .env
102+
source .env/bin/activate
103+
pip install Sphinx sphinx-rtd-theme
104+
105+
Now, once you have the virtual environment activated:
106+
107+
.. code-block:: shell
69108
70-
.. toctree::
71-
:maxdepth: 2
109+
cd docs
110+
sphinx-build -E -W -b html . _build/html
72111
73-
api
112+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
113+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
114+
locally verify it will pass.

adafruit_si7021.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@
2626
2727
This is a CircuitPython driver for the SI7021 temperature and humidity sensor.
2828
29+
* Author(s): Radomir Dopieralski
30+
31+
Implementation Notes
32+
--------------------
33+
34+
**Hardware:**
35+
36+
* Adafruit `Si7021 Temperature & Humidity Sensor Breakout Board
37+
<https://www.adafruit.com/product/3251>`_ (Product ID: 3251)
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
2944
"""
3045
try:
3146
import struct
@@ -60,6 +75,9 @@ def _crc(data):
6075
class SI7021:
6176
"""
6277
A driver for the SI7021 temperature and humidity sensor.
78+
79+
:param i2c_bus: The `busio.I2C` object to use. This is the only required parameter.
80+
:param int address: (optional) The I2C address of the device.
6381
"""
6482

6583
def __init__(self, i2c_bus, address=0x40):

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: 17 additions & 6 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

@@ -15,6 +15,11 @@
1515
'sphinx.ext.viewcode',
1616
]
1717

18+
# Uncomment the below if you use native CircuitPython modules such as
19+
# digitalio, micropython and busio. List the modules you use. Without it, the
20+
# autodoc module docs will fail to generate with a warning.
21+
autodoc_mock_imports = ["adafruit_bus_device", "micropython"]
22+
1823
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/bus_device/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
1924

2025
# Add any paths that contain templates here, relative to this directory.
@@ -23,16 +28,13 @@
2328
source_suffix = '.rst'
2429

2530
# The master toctree document.
26-
master_doc = 'README'
31+
master_doc = 'index'
2732

2833
# General information about the project.
2934
project = u'Adafruit SI7021 Library'
3035
copyright = u'2017 Radomir Dopieralski'
3136
author = u'Radomir Dopieralski'
3237

33-
# Ignore imports of these modules, which sphinx will not know about.
34-
autodoc_mock_imports = ['micropython']
35-
3638
# The version info for the project you're documenting, acts as replacement for
3739
# |version| and |release|, also used in various other places throughout the
3840
# built documents.
@@ -52,7 +54,7 @@
5254
# List of patterns, relative to source directory, that match files and
5355
# directories to ignore when looking for source files.
5456
# This patterns also effect to html_static_path and html_extra_path
55-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
57+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
5658

5759
# The reST default role (used for this markup: `text`) to use for all
5860
# documents.
@@ -69,6 +71,9 @@
6971
# If true, `todo` and `todoList` produce output, else they produce nothing.
7072
todo_include_todos = False
7173

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

7378
# -- Options for HTML output ----------------------------------------------
7479

@@ -93,6 +98,12 @@
9398
# so a file named "default.css" will overwrite the builtin "default.css".
9499
html_static_path = ['_static']
95100

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+
96107
# Output file base name for HTML help builder.
97108
htmlhelp_basename = 'AdafruitSI7021Librarydoc'
98109

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/si7021_simpletest.py
7+
:caption: examples/si7021_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 Si7021 Temperature & Humidity Sensor Breakout Board <https://www.adafruit.com/product/3251>
30+
31+
.. toctree::
32+
:caption: Other Links
33+
34+
Download <https://github.com/adafruit/Adafruit_CircuitPython_SI7021/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)