Skip to content

Commit fe7dcf8

Browse files
authored
Merge pull request #25 from sommersoft/new_docs
Improved Ref Docs
2 parents c72d18c + 7380271 commit fe7dcf8

File tree

10 files changed

+116
-12
lines changed

10 files changed

+116
-12
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 neopixel.py
2929
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3030
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-neopixel --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
@@ -76,10 +76,49 @@ Contributions are welcome! Please read our `Code of Conduct
7676
<https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/blob/master/CODE_OF_CONDUCT.md>`_
7777
before contributing to help this project stay welcoming.
7878

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

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

+11-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 CircuitPython NeoPixel 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,8 @@
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
7173

7274
# -- Options for HTML output ----------------------------------------------
7375

@@ -92,6 +94,12 @@
9294
# so a file named "default.css" will overwrite the builtin "default.css".
9395
html_static_path = ['_static']
9496

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

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/neopixel_simpletest.py
7+
:caption: examples/neopixel_simpletest.py
8+
:linenos:

docs/index.rst

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 NeoPixel Products <http://www.adafruit.com/category/168>
30+
31+
.. toctree::
32+
:caption: Other Links
33+
34+
Download <https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel/releases/latest>
35+
Adafruit NeoPixel Uberguide <https://learn.adafruit.com/adafruit-neopixel-uberguide>
36+
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
37+
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
38+
Discord Chat <https://adafru.it/discord>
39+
Adafruit Learning System <https://learn.adafruit.com>
40+
Adafruit Blog <https://blog.adafruit.com>
41+
Adafruit Store <https://www.adafruit.com>
42+
43+
Indices and tables
44+
==================
45+
46+
* :ref:`genindex`
47+
* :ref:`modindex`
48+
* :ref:`search`
File renamed without changes.

neopixel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class NeoPixel:
7171
7272
RED = 0x100000 # (0x10, 0, 0) also works
7373
74-
# Using `with` ensures pixels are cleared after we're done.
74+
# Using ``with`` ensures pixels are cleared after we're done.
7575
with neopixel.NeoPixel(NEOPIXEL, 10) as pixels:
7676
pixels[::2] = [RED] * (len(pixels) // 2)
7777
time.sleep(2)
@@ -197,7 +197,7 @@ def fill(self, color):
197197
def write(self):
198198
""".. deprecated: 1.0.0
199199
200-
Use `show` instead. It matches Micro:Bit and Arduino APIs."""
200+
Use ``show`` instead. It matches Micro:Bit and Arduino APIs."""
201201
self.show()
202202

203203
def show(self):

0 commit comments

Comments
 (0)