Skip to content

Commit 271f99f

Browse files
authored
Merge pull request #4 from sommersoft/new_docs
Improve Ref Docs
2 parents 4061b4d + 46b7270 commit 271f99f

10 files changed

+126
-50
lines changed
File renamed without changes.

.travis.yml

+3-2
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_bme680.py
2929
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3030
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-bme680 --library_location .
31+
- cd docs && sphinx-build -E -W -b html . _build/html

README.rst

+44-5
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,49 @@ Contributions are welcome! Please read our `Code of Conduct
6161
<https://github.com/adafruit/Adafruit_CircuitPython_bme680/blob/master/CODE_OF_CONDUCT.md>`_
6262
before contributing to help this project stay welcoming.
6363

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

adafruit_bme680.py

+10-37
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
# pylint: disable=too-many-instance-attributes
2525

2626
"""
27-
`adafruit_bme680`
28-
====================================================
27+
`adafruit_bme680` - Adafruit BME680 - Temperature, Humidity, Pressure & Gas Sensor
28+
===================================================================================
2929
3030
CircuitPython driver from BME680 air quality sensor
3131
@@ -104,11 +104,11 @@ def __init__(self):
104104
# set up heater
105105
self._write(_BME680_BME680_RES_WAIT_0, [0x73, 0x64, 0x65])
106106
self.sea_level_pressure = 1013.25
107-
"""Pressure in hectoPascals at sea level. Used to calibrate `altitude`."""
108-
self.pressure_oversample = 4
109-
self.temperature_oversample = 8
110-
self.humidity_oversample = 2
111-
self.filter_size = 3
107+
"""Pressure in hectoPascals at sea level. Used to calibrate ``altitude``."""
108+
self._pressure_oversample = 4
109+
self._temp_oversample = 8
110+
self._humidity_oversample = 2
111+
self._filter = 3
112112

113113
self._adc_pres = None
114114
self._adc_temp = None
@@ -145,7 +145,7 @@ def humidity_oversample(self, sample_rate):
145145
@property
146146
def temperature_oversample(self):
147147
"""The oversampling for temperature sensor"""
148-
return _BME680_SAMPLERATES[self._pressure_oversample]
148+
return _BME680_SAMPLERATES[self._temp_oversample]
149149

150150
@temperature_oversample.setter
151151
def temperature_oversample(self, sample_rate):
@@ -223,8 +223,8 @@ def humidity(self):
223223

224224
@property
225225
def altitude(self):
226-
"""The altitude based on current `pressure` vs the sea level pressure
227-
(`sea_level_pressure`) - which you must enter ahead of time)"""
226+
"""The altitude based on current ``pressure`` vs the sea level pressure
227+
(``sea_level_pressure``) - which you must enter ahead of time)"""
228228
pressure = self.pressure # in Si units for hPascal
229229
return 44330 * (1.0 - math.pow(pressure / self.sea_level_pressure, 0.1903))
230230

@@ -300,33 +300,6 @@ def _read_calibration(self):
300300
self._heat_val = self._read(0x00, 1)[0]
301301
self._sw_err = (self._read(0x04, 1)[0] & 0xF0) / 16
302302

303-
"""
304-
print("T1-3: %d %d %d" % (self._temp_calibration[0],
305-
self._temp_calibration[1],
306-
self._temp_calibration[2]))
307-
print("P1-3: %d %d %d" % (self._pressure_calibration[0],
308-
self._pressure_calibration[1],
309-
self._pressure_calibration[2]))
310-
print("P4-6: %d %d %d" % (self._pressure_calibration[3],
311-
self._pressure_calibration[4],
312-
self._pressure_calibration[5]))
313-
print("P7-9: %d %d %d" % (self._pressure_calibration[6],
314-
self._pressure_calibration[7],
315-
self._pressure_calibration[8]))
316-
print("P10: %d" % self._pressure_calibration[9])
317-
print("H1-3: %d %d %d" % (self._humidity_calibration[0],
318-
self._humidity_calibration[1],
319-
self._humidity_calibration[2]))
320-
print("H4-7: %d %d %d %d" % (self._humidity_calibration[3],
321-
self._humidity_calibration[4],
322-
self._humidity_calibration[5],
323-
self._humidity_calibration[6]))
324-
print("G1-3: %d %d %d" % (self._gas_calibration[0],
325-
self._gas_calibration[1],
326-
self._gas_calibration[2]))
327-
print("HR %d HV %d SWERR %d" % (self._heat_range, self._heat_val, self._sw_err))
328-
"""
329-
330303
def _read_byte(self, register):
331304
"""Read a byte register value and return it"""
332305
return self._read(register, 1)[0]

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

+12-3
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

@@ -25,7 +25,7 @@
2525
source_suffix = '.rst'
2626

2727
# The master toctree document.
28-
master_doc = 'README'
28+
master_doc = 'index'
2929

3030
# General information about the project.
3131
project = u'Adafruit BME680 Library'
@@ -51,7 +51,7 @@
5151
# List of patterns, relative to source directory, that match files and
5252
# directories to ignore when looking for source files.
5353
# This patterns also effect to html_static_path and html_extra_path
54-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
54+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
5555

5656
# The reST default role (used for this markup: `text`) to use for all
5757
# documents.
@@ -68,6 +68,9 @@
6868
# If true, `todo` and `todoList` produce output, else they produce nothing.
6969
todo_include_todos = False
7070

71+
# If this is True, todo emits a warning for each TODO entries. The default is False.
72+
todo_emit_warnings = True
73+
7174

7275
# -- Options for HTML output ----------------------------------------------
7376

@@ -92,6 +95,12 @@
9295
# so a file named "default.css" will overwrite the builtin "default.css".
9396
html_static_path = ['_static']
9497

98+
# The name of an image file (relative to this directory) to use as a favicon of
99+
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
100+
# pixels large.
101+
#
102+
html_favicon = '_static/favicon.ico'
103+
95104
# Output file base name for HTML help builder.
96105
htmlhelp_basename = 'AdafruitBME680Librarydoc'
97106

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/bme680_simpletest.py
7+
:caption: examples/bme680_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 BME680 - Temperature, Humidity, Pressure and Gas Sensor <https://www.adafruit.com/product/3660>
30+
31+
.. toctree::
32+
:caption: Other Links
33+
34+
Download <https://github.com/adafruit/Adafruit_CircuitPython_BME680/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`

examples/main.py renamed to examples/bme680_simpletest.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import gc
1+
import time
22
from busio import I2C
33
import adafruit_bme680
4-
import time
54
import board
65

76
# Create library object using our Bus I2C port
@@ -17,5 +16,5 @@
1716
print("Humidity: %0.1f %%" % bme680.humidity)
1817
print("Pressure: %0.3f hPa" % bme680.pressure)
1918
print("Altitude = %0.2f meters" % bme680.altitude)
20-
19+
2120
time.sleep(1)

0 commit comments

Comments
 (0)