Skip to content

Commit 42bc581

Browse files
authored
Merge pull request #4 from sommersoft/new_docs
Improve Ref Docs
2 parents 617628d + b5d59b3 commit 42bc581

File tree

11 files changed

+151
-24
lines changed

11 files changed

+151
-24
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
python:
2+
version: 3
13
requirements_file: requirements.txt
24

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ 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
on:
2222
tags: true
2323

2424
install:
25-
- pip install pylint circuitpython-build-tools
25+
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
2626

2727
script:
2828
- pylint adafruit_dht.py
2929
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3030
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-dht --library_location .
31+
- 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
@@ -6,9 +6,10 @@ Introduction
66
:target: https://circuitpython.readthedocs.io/projects/dht/en/latest/
77
:alt: Documentation Status
88

9-
.. image :: https://badges.gitter.im/adafruit/circuitpython.svg
10-
:target: https://gitter.im/adafruit/circuitpython?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
11-
:alt: Gitter
9+
10+
.. image :: https://img.shields.io/discord/327254708534116352.svg
11+
:target: https://discord.gg/nBQh6qu
12+
:alt: Discord
1213
1314
CircuitPython support for the DHT11 and DHT22 temperature and humidity devices.
1415

@@ -23,17 +24,17 @@ This is easily achieved by downloading
2324
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
2425

2526
Usage Example
26-
=============
27+
==============
2728

2829
Hardware Set-up
29-
---------------
30+
----------------
3031

3132
The DHT11 and DHT22 devices both need a pull-resistor on the data signal wire.
3233
This resistor is in the range of 1k to 5k. Please check your device datasheet for the
3334
appropriate value.
3435

3536
Basics
36-
------
37+
-------
3738

3839
Of course, you must import the library to use it:
3940

@@ -60,7 +61,7 @@ OR initialize the DHT22 device:
6061
dht_device = adafruit_dht.DHT22(<pin>)
6162
6263
Read temperature and humidity
63-
----------------------------
64+
------------------------------
6465

6566
Now get the temperature and humidity values
6667

@@ -79,10 +80,50 @@ Contributions are welcome! Please read our `Code of Conduct
7980
<https://github.com/adafruit/Adafruit_CircuitPython_DHT/blob/master/CODE_OF_CONDUCT.md>`_
8081
before contributing to help this project stay welcoming.
8182

82-
API Reference
83-
=============
83+
Building locally
84+
================
85+
86+
To build this library locally you'll need to install the
87+
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
88+
89+
.. code-block:: shell
90+
91+
python3 -m venv .env
92+
source .env/bin/activate
93+
pip install circuitpython-build-tools
94+
95+
Once installed, make sure you are in the virtual environment:
96+
97+
.. code-block:: shell
98+
99+
source .env/bin/activate
100+
101+
Then run the build:
102+
103+
.. code-block:: shell
104+
105+
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-veml6070 --library_location .
106+
107+
Sphinx documentation
108+
-----------------------
109+
110+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
111+
install dependencies (feel free to reuse the virtual environment from above):
112+
113+
.. code-block:: shell
114+
115+
python3 -m venv .env
116+
source .env/bin/activate
117+
pip install Sphinx sphinx-rtd-theme
118+
119+
Now, once you have the virtual environment activated:
120+
121+
.. code-block:: shell
122+
123+
cd docs
124+
sphinx-build -E -W -b html . _build/html
84125
85-
.. toctree::
86-
:maxdepth: 2
126+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
127+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
128+
locally verify it will pass.
87129

88-
api

api.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/_static/favicon.ico

4.31 KB
Binary file not shown.

docs/api.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
.. If you created a package, create one automodule per module in the package.
3+
4+
.. automodule:: adafruit_dht
5+
:members:

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 CircuitPython DHT 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 = 'AdafruitCircuitPythonDHTLibrarydoc'
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/dht_simpletest.py
7+
:caption: examples/dht_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+
DHT11 basic temperature-humidity sensor + extras <https://www.adafruit.com/product/386>
30+
31+
DHT22 basic temperature-humidity sensor + extras <https://www.adafruit.com/product/385>
32+
33+
.. toctree::
34+
:caption: Other Links
35+
36+
Download <https://github.com/adafruit/Adafruit_CircuitPython_DHT/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`

examples/dht_simpletest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import time
2+
import adafruit_dht
3+
from board import D2
4+
5+
#initial the dht device
6+
dhtDevice = adafruit_dht.DHT22(D2)
7+
8+
while True:
9+
try:
10+
# show the values to the serial port
11+
temperature = dhtDevice.temperature * (9 / 5) + 32
12+
humidity = dhtDevice.humidity
13+
print("Temp: {:.1f} F Humidity: {}% ".format(temperature, humidity))
14+
15+
except RuntimeError as error:
16+
print(error.args)
17+
18+
time.sleep(2.0)

examples/dhttoleddisplay.py renamed to examples/dht_to_led_display.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
while True:
2626
try:
2727
# show the values to the serial port
28-
temperature = dhtDevice.temperature*9/5+32
28+
temperature = dhtDevice.temperature * (9 / 5) + 32
2929
humidity = dhtDevice.humidity
3030
#print("Temp: {:.1f} F Humidity: {}% ".format(temperature, humidity))
3131

0 commit comments

Comments
 (0)