Skip to content

Commit 312e118

Browse files
authored
Merge pull request #3 from sommersoft/new_docs
Improve Ref Docs
2 parents 89754c1 + f765ec7 commit 312e118

10 files changed

+118
-27
lines changed
File renamed without changes.

.travis.yml

Lines changed: 3 additions & 2 deletions
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_mcp4725.py
3030
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*.py)
3131
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-mcp4725 --library_location .
32+
- cd docs && sphinx-build -E -W -b html . _build/html

README.rst

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ Introduction
1010
:target: https://discord.gg/nBQh6qu
1111
:alt: Discord
1212
13-
.. image:: https://travis-ci.org/adafruit/Adafruit_CircuitPython_MCP4725.svg?branch=master
14-
:target: https://travis-ci.org/adafruit/Adafruit_CircuitPython_MCP4725
15-
:alt: Build Status
16-
1713
CircuitPython module for the MCP4725 digital to analog converter.
1814

1915
Dependencies
@@ -29,15 +25,7 @@ This is easily achieved by downloading
2925
Usage Example
3026
=============
3127

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

4230
Contributing
4331
============
@@ -69,3 +57,26 @@ Then run the build:
6957
.. code-block:: shell
7058
7159
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-mcp4725 --library_location .
60+
61+
Sphinx documentation
62+
-----------------------
63+
64+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
65+
install dependencies (feel free to reuse the virtual environment from above):
66+
67+
.. code-block:: shell
68+
69+
python3 -m venv .env
70+
source .env/bin/activate
71+
pip install Sphinx sphinx-rtd-theme
72+
73+
Now, once you have the virtual environment activated:
74+
75+
.. code-block:: shell
76+
77+
cd docs
78+
sphinx-build -E -W -b html . _build/html
79+
80+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
81+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
82+
locally verify it will pass.

adafruit_mcp4725.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,22 @@
2424
========================================================
2525
2626
CircuitPython module for the MCP4725 digital to analog converter. See
27-
examples/simpletest.py for a demo of the usage.
27+
examples/mcp4725_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 `MCP4725 Breakout Board - 12-Bit DAC w/I2C Interface
37+
<https://www.adafruit.com/product/935>`_ (Product ID: 935)
38+
39+
**Software and Dependencies:**
40+
41+
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
42+
https://github.com/adafruit/circuitpython/releases
3043
"""
3144
from micropython import const
3245

@@ -40,12 +53,13 @@
4053

4154

4255
class MCP4725:
43-
"""MCP4725 12-bit digital to analog converter. This class has a similar
44-
interface as the CircuitPython AnalogOut class and can be used in place
45-
of that module.
56+
"""
57+
MCP4725 12-bit digital to analog converter. This class has a similar
58+
interface as the CircuitPython AnalogOut class and can be used in place
59+
of that module.
4660
47-
:param ~busio.I2C i2c: The I2C bus.
48-
:param int address: The address of the device if set differently from the default.
61+
:param ~busio.I2C i2c: The I2C bus.
62+
:param int address: The address of the device if set differently from the default.
4963
"""
5064

5165

@@ -97,12 +111,13 @@ def _read(self):
97111

98112
@property
99113
def value(self):
100-
"""The DAC value as a 16-bit unsigned value compatible with the
114+
"""
115+
The DAC value as a 16-bit unsigned value compatible with the
101116
:py:class:`~analogio.AnalogOut` class.
102117
103118
Note that the MCP4725 is still just a 12-bit device so quantization will occur. If you'd
104-
like to instead deal with the raw 12-bit value use the raw_value property, or the
105-
normalized_value property to deal with a 0...1 float value.
119+
like to instead deal with the raw 12-bit value use the ``raw_value`` property, or the
120+
``normalized_value`` property to deal with a 0...1 float value.
106121
"""
107122
raw_value = self._read()
108123
# Scale up to 16-bit range.

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: 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 MCP4725 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 = 'AdafruitMcp4725Librarydoc'
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/mcp4725_simpletest.py
7+
:caption: examples/mcp4725_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 MCP4725 Breakout Board - 12-Bit DAC w/I2C Interface <https://www.adafruit.com/product/935>
30+
31+
.. toctree::
32+
:caption: Other Links
33+
34+
Download <https://github.com/adafruit/Adafruit_CircuitPython_MCP4725/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)