Skip to content

Commit 49c1475

Browse files
authored
Merge pull request #9 from sommersoft/new_docs
Improve Ref Docs
2 parents 9c637e1 + 10c5f54 commit 49c1475

12 files changed

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

README.rst

+48-8
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Introduction
66
:target: https://circuitpython.readthedocs.io/projects/CircuitPython_ADS1x15/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+
.. image :: https://img.shields.io/discord/327254708534116352.svg
10+
:target: https://discord.gg/nBQh6qu
11+
:alt: Discord
1212
1313
Support for the ADS1x15 series of analog-to-digital converters. Available in 12-bit (ADS1015)
1414
and 16-bit (ADS1115) versions.
@@ -65,10 +65,50 @@ Contributions are welcome! Please read our `Code of Conduct
6565
<https://github.com/adafruit/Adafruit_CircuitPython_CircuitPython_ADS1x15/blob/master/CODE_OF_CONDUCT.md>`_
6666
before contributing to help this project stay welcoming.
6767

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

74-
api

adafruit_ads1x15/differential.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ def __getitem__(self, key):
4646
def read_adc_difference(self, differential, gain=1, data_rate=None):
4747
"""Read the difference between two ADC channels and return the ADC value
4848
as a signed integer result. Differential must be one of:
49-
- 0 = Channel 0 minus channel 1
50-
- 1 = Channel 0 minus channel 3
51-
- 2 = Channel 1 minus channel 3
52-
- 3 = Channel 2 minus channel 3
49+
- 0 = Channel 0 minus channel 1
50+
- 1 = Channel 0 minus channel 3
51+
- 2 = Channel 1 minus channel 3
52+
- 3 = Channel 2 minus channel 3
5353
"""
5454
assert 0 <= differential <= 3, 'Differential must be a value within 0-3!'
5555
# Perform a single shot read using the provided differential value
@@ -59,10 +59,10 @@ def read_adc_difference(self, differential, gain=1, data_rate=None):
5959
def read_volts_difference(self, differential, gain=1, data_rate=None):
6060
"""Read the difference between two ADC channels and return the voltage value
6161
as a floating point result. Differential must be one of:
62-
- 0 = Channel 0 minus channel 1
63-
- 1 = Channel 0 minus channel 3
64-
- 2 = Channel 1 minus channel 3
65-
- 3 = Channel 2 minus channel 3
62+
- 0 = Channel 0 minus channel 1
63+
- 1 = Channel 0 minus channel 3
64+
- 2 = Channel 1 minus channel 3
65+
- 3 = Channel 2 minus channel 3
6666
"""
6767
assert 0 <= differential <= 3, 'Differential must be a value within 0-3!'
6868
raw = self.read_adc_difference(differential, gain, data_rate)
@@ -72,10 +72,10 @@ def read_volts_difference(self, differential, gain=1, data_rate=None):
7272
def start_adc_difference(self, differential, gain=1, data_rate=None):
7373
"""Start continuous ADC conversions between two ADC channels. Differential
7474
must be one of:
75-
- 0 = Channel 0 minus channel 1
76-
- 1 = Channel 0 minus channel 3
77-
- 2 = Channel 1 minus channel 3
78-
- 3 = Channel 2 minus channel 3
75+
- 0 = Channel 0 minus channel 1
76+
- 1 = Channel 0 minus channel 3
77+
- 2 = Channel 1 minus channel 3
78+
- 3 = Channel 2 minus channel 3
7979
Will return an initial conversion result, then call the get_last_result()
8080
function continuously to read the most recent conversion result. Call
8181
stop_adc() to stop conversions.

api.rst

-11
This file was deleted.

docs/_static/favicon.ico

4.31 KB
Binary file not shown.

docs/api.rst

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
.. If you created a package, create one automodule per module in the package.
3+
4+
.. automodule:: adafruit_ads1x15.adafruit_ads1x15
5+
:members:
6+
7+
.. automodule:: adafruit_ads1x15.differential
8+
:members:
9+
10+
.. automodule:: adafruit_ads1x15.single_ended
11+
:members:

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

@@ -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_ADS1X15 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 = 'AdafruitCIRCUITPYTHON_ADS1X15Librarydoc'
100109

docs/examples.rst

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Simple test
2+
------------
3+
4+
Ensure your device works with this simple test.
5+
6+
.. literalinclude:: ../examples/ads1115_single_ended_simpletest.py
7+
:caption: examples/ads1115_single_ended_simpletest.py
8+
:linenos:
9+
10+
.. literalinclude:: ../examples/ads1115_differential_simpletest.py
11+
:caption: examples/ads1115_differential_simpletest.py
12+
:linenos:

docs/index.rst

+49
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+
ADS1015 12-Bit ADC - 4 Channel with Programmable Gain Amplifier <https://www.adafruit.com/product/1083>
30+
31+
ADS1115 16-Bit ADC - 4 Channel with Programmable Gain Amplifier <https://www.adafruit.com/product/1085>
32+
33+
.. toctree::
34+
:caption: Other Links
35+
36+
Download <https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15/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`

0 commit comments

Comments
 (0)