Skip to content

Commit 55e0be4

Browse files
authored
Merge pull request #29 from sommersoft/new_docs
Improve Ref Docs
2 parents 4df91b8 + 46919d9 commit 55e0be4

35 files changed

+167
-46
lines changed
File renamed without changes.

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

README.rst

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ Introduction
66
:target: https://circuitpython.readthedocs.io/projects/circuitplayground/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
12-
139
.. image :: https://img.shields.io/discord/327254708534116352.svg
1410
:target: https://adafru.it/discord
1511
:alt: Discord
@@ -46,10 +42,50 @@ Contributions are welcome! Please read our `Code of Conduct
4642
<https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground/blob/master/CODE_OF_CONDUCT.md>`_
4743
before contributing to help this project stay welcoming.
4844

49-
API Reference
50-
=============
45+
Building locally
46+
================
47+
48+
To build this library locally you'll need to install the
49+
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
50+
51+
.. code-block:: shell
52+
53+
python3 -m venv .env
54+
source .env/bin/activate
55+
pip install circuitpython-build-tools
56+
57+
Once installed, make sure you are in the virtual environment:
58+
59+
.. code-block:: shell
60+
61+
source .env/bin/activate
62+
63+
Then run the build:
64+
65+
.. code-block:: shell
66+
67+
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-circuitplayground --library_location .
68+
69+
Sphinx documentation
70+
-----------------------
71+
72+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
73+
install dependencies (feel free to reuse the virtual environment from above):
74+
75+
.. code-block:: shell
76+
77+
python3 -m venv .env
78+
source .env/bin/activate
79+
pip install Sphinx sphinx-rtd-theme
80+
81+
Now, once you have the virtual environment activated:
82+
83+
.. code-block:: shell
84+
85+
cd docs
86+
sphinx-build -E -W -b html . _build/html
5187
52-
.. toctree::
53-
:maxdepth: 2
88+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
89+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
90+
locally verify it will pass.
5491

55-
adafruit_circuitplayground/index

adafruit_circuitplayground/express.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def detect_taps(self):
131131
"""Configure what type of tap is detected by ``cpx.tapped``. Use ``1`` for single-tap
132132
detection and ``2`` for double-tap detection. This does nothing without ``cpx.tapped``.
133133
134-
.. image :: /_static/accelerometer.jpg
134+
.. image :: ../docs/_static/accelerometer.jpg
135135
:alt: Accelerometer
136136
137137
.. code-block:: python
@@ -160,7 +160,7 @@ def detect_taps(self, value):
160160
def tapped(self):
161161
"""True once after a detecting a tap. Requires ``cpx.detect_taps``.
162162
163-
.. image :: /_static/accelerometer.jpg
163+
.. image :: ../docs/_static/accelerometer.jpg
164164
:alt: Accelerometer
165165
166166
Tap the CPX once for a single-tap, or quickly tap twice for a double-tap.
@@ -215,7 +215,7 @@ def tapped(self):
215215
def acceleration(self):
216216
"""Obtain data from the x, y and z axes.
217217
218-
.. image :: /_static/accelerometer.jpg
218+
.. image :: ../docs/_static/accelerometer.jpg
219219
:alt: Accelerometer
220220
221221
This example prints the values. Try moving the board to see how the
@@ -236,7 +236,7 @@ def shake(self, shake_threshold=30):
236236
237237
:param int shake_threshold: The threshold shake must exceed to return true (Default: 30)
238238
239-
.. image :: /_static/accelerometer.jpg
239+
.. image :: ../docs/_static/accelerometer.jpg
240240
:alt: Accelerometer
241241
242242
.. code-block:: python
@@ -271,7 +271,7 @@ def shake(self, shake_threshold=30):
271271
def touch_A1(self): # pylint: disable=invalid-name
272272
"""Detect touch on capacitive touch pad A1.
273273
274-
.. image :: /_static/capacitive_touch_pad_A1.jpg
274+
.. image :: ../docs/_static/capacitive_touch_pad_A1.jpg
275275
:alt: Capacitive touch pad A1
276276
277277
.. code-block:: python
@@ -291,7 +291,7 @@ def touch_A1(self): # pylint: disable=invalid-name
291291
def touch_A2(self): # pylint: disable=invalid-name
292292
"""Detect touch on capacitive touch pad A2.
293293
294-
.. image :: /_static/capacitive_touch_pad_A2.jpg
294+
.. image :: ../docs/_static/capacitive_touch_pad_A2.jpg
295295
:alt: Capacitive touch pad A2
296296
297297
.. code-block:: python
@@ -311,7 +311,7 @@ def touch_A2(self): # pylint: disable=invalid-name
311311
def touch_A3(self): # pylint: disable=invalid-name
312312
"""Detect touch on capacitive touch pad A3.
313313
314-
.. image :: /_static/capacitive_touch_pad_A3.jpg
314+
.. image :: ../docs/_static/capacitive_touch_pad_A3.jpg
315315
:alt: Capacitive touch pad A3
316316
317317
.. code-block:: python
@@ -331,7 +331,7 @@ def touch_A3(self): # pylint: disable=invalid-name
331331
def touch_A4(self): # pylint: disable=invalid-name
332332
"""Detect touch on capacitive touch pad A4.
333333
334-
.. image :: /_static/capacitive_touch_pad_A4.jpg
334+
.. image :: ../docs/_static/capacitive_touch_pad_A4.jpg
335335
:alt: Capacitive touch pad A4
336336
337337
.. code-block:: python
@@ -351,7 +351,7 @@ def touch_A4(self): # pylint: disable=invalid-name
351351
def touch_A5(self): # pylint: disable=invalid-name
352352
"""Detect touch on capacitive touch pad A5.
353353
354-
.. image :: /_static/capacitive_touch_pad_A5.jpg
354+
.. image :: ../docs/_static/capacitive_touch_pad_A5.jpg
355355
:alt: Capacitive touch pad A5
356356
357357
.. code-block:: python
@@ -371,7 +371,7 @@ def touch_A5(self): # pylint: disable=invalid-name
371371
def touch_A6(self): # pylint: disable=invalid-name
372372
"""Detect touch on capacitive touch pad A6.
373373
374-
.. image :: /_static/capacitive_touch_pad_A6.jpg
374+
.. image :: ../docs/_static/capacitive_touch_pad_A6.jpg
375375
:alt: Capacitive touch pad A6
376376
377377
.. code-block:: python
@@ -391,7 +391,7 @@ def touch_A6(self): # pylint: disable=invalid-name
391391
def touch_A7(self): # pylint: disable=invalid-name
392392
"""Detect touch on capacitive touch pad A7.
393393
394-
.. image :: /_static/capacitive_touch_pad_A7.jpg
394+
.. image :: ../docs/_static/capacitive_touch_pad_A7.jpg
395395
:alt: Capacitive touch pad A7
396396
397397
.. code-block:: python
@@ -413,7 +413,7 @@ def adjust_touch_threshold(self, adjustment):
413413
414414
:param int adjustment: The desired threshold increase
415415
416-
.. image :: /_static/capacitive_touch_pads.jpg
416+
.. image :: ../docs/_static/capacitive_touch_pads.jpg
417417
:alt: Capacitive touch pads
418418
419419
.. code-block:: python
@@ -443,7 +443,7 @@ def pixels(self):
443443
444444
See `neopixel.NeoPixel` for more info.
445445
446-
.. image :: /_static/neopixel_numbering.jpg
446+
.. image :: ../docs/_static/neopixel_numbering.jpg
447447
:alt: NeoPixel order diagram
448448
449449
Here is an example that sets the first pixel green and the second red.
@@ -466,7 +466,7 @@ def pixels(self):
466466
def button_a(self):
467467
"""``True`` when Button A is pressed. ``False`` if not.
468468
469-
.. image :: /_static/button_a.jpg
469+
.. image :: ../docs/_static/button_a.jpg
470470
:alt: Button A
471471
472472
.. code-block:: python
@@ -483,7 +483,7 @@ def button_a(self):
483483
def button_b(self):
484484
"""``True`` when Button B is pressed. ``False`` if not.
485485
486-
.. image :: /_static/button_b.jpg
486+
.. image :: ../docs/_static/button_b.jpg
487487
:alt: Button B
488488
489489
.. code-block:: python
@@ -502,7 +502,7 @@ def switch(self):
502502
``True`` when the switch is to the left next to the music notes.
503503
``False`` when it is to the right towards the ear.
504504
505-
.. image :: ../_static/slide_switch.jpg
505+
.. image :: ../docs/_static/slide_switch.jpg
506506
:alt: Slide switch
507507
508508
.. code-block:: python
@@ -520,7 +520,7 @@ def switch(self):
520520
def temperature(self):
521521
"""The temperature of the CircuitPlayground in Celsius.
522522
523-
.. image :: /_static/thermistor.jpg
523+
.. image :: ../docs/_static/thermistor.jpg
524524
:alt: Temperature sensor
525525
526526
Converting this to Farenheit is easy!
@@ -543,7 +543,7 @@ def temperature(self):
543543
def light(self):
544544
"""The brightness of the CircuitPlayground in approximate Lux.
545545
546-
.. image :: /_static/light_sensor.jpg
546+
.. image :: ../docs/_static/light_sensor.jpg
547547
:alt: Light sensor
548548
549549
Try covering the sensor next to the eye to see it change.
@@ -563,7 +563,7 @@ def light(self):
563563
def red_led(self):
564564
"""The red led next to the USB plug marked D13.
565565
566-
.. image :: /_static/red_led.jpg
566+
.. image :: ../docs/_static/red_led.jpg
567567
:alt: D13 LED
568568
569569
.. code-block:: python
@@ -604,7 +604,7 @@ def play_tone(self, frequency, duration):
604604
:param int frequency: The frequency of the tone in Hz
605605
:param float duration: The duration of the tone in seconds
606606
607-
.. image :: /_static/speaker.jpg
607+
.. image :: ../docs/_static/speaker.jpg
608608
:alt: Onboard speaker
609609
610610
.. code-block:: python
@@ -624,7 +624,7 @@ def start_tone(self, frequency):
624624
625625
:param int frequency: The frequency of the tone in Hz
626626
627-
.. image :: /_static/speaker.jpg
627+
.. image :: ../docs/_static/speaker.jpg
628628
:alt: Onboard speaker
629629
630630
.. code-block:: python
@@ -649,7 +649,7 @@ def start_tone(self, frequency):
649649
def stop_tone(self):
650650
""" Use with start_tone to stop the tone produced.
651651
652-
.. image :: /_static/speaker.jpg
652+
.. image :: ../docs/_static/speaker.jpg
653653
:alt: Onboard speaker
654654
655655
.. code-block:: python
@@ -674,7 +674,7 @@ def play_file(self, file_name):
674674
675675
:param file_name: The name of your .wav file in quotation marks including .wav
676676
677-
.. image :: /_static/speaker.jpg
677+
.. image :: ../docs/_static/speaker.jpg
678678
:alt: Onboard speaker
679679
680680
.. code-block:: python

adafruit_circuitplayground/index.rst

Lines changed: 0 additions & 9 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/_static/favicon.ico

4.31 KB
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

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_circuitplayground.express
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 CircuitPlayground 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 = 'AdafruitCircuitPlaygroundLibrarydoc'
100109

docs/examples.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Simple test
2+
------------
3+
4+
Ensure your device works with this simple test.
5+
6+
.. literalinclude:: ../examples/acceleration_simpletest.py
7+
:caption: examples/acceleration_simpletest.py
8+
:linenos:
9+
10+
.. literalinclude:: ../examples/pixels_simpletest.py
11+
:caption: examples/pixels_simpletest.py
12+
:linenos:
13+
14+
.. literalinclude:: ../examples/shake_simpletest.py
15+
:caption: examples/shake_simpletest.py
16+
:linenos:
17+
18+
.. literalinclude:: ../examples/tapdetect_simpletest.py
19+
:caption: examples/tapdetect_simpletest.py
20+
:linenos:
21+
22+
.. literalinclude:: ../examples/tapdetectsimple_simpletest.py
23+
:caption: examples/tapdetectsimple_simpletest.py
24+
:linenos:
25+
26+
.. literalinclude:: ../examples/tone_simpletest.py
27+
:caption: examples/tone_simpletest.py
28+
:linenos:
29+
30+
.. literalinclude:: ../examples/touched_simpletest.py
31+
:caption: examples/touched_simpletest.py
32+
:linenos:

0 commit comments

Comments
 (0)