/ README.rst
README.rst
1 Introduction 2 ============ 3 4 .. image:: https://readthedocs.org/projects/adafruit-circuitpython-itertools/badge/?version=latest 5 :target: https://circuitpython.readthedocs.io/projects/adafruit_itertools/en/latest/ 6 :alt: Documentation Status 7 8 .. image:: https://img.shields.io/discord/327254708534116352.svg 9 :target: https://discord.gg/nBQh6qu 10 :alt: Discord 11 12 .. image:: https://travis-ci.com/adafruit/Adafruit_CircuitPython_IterTools.svg?branch=master 13 :target: https://travis-ci.com/adafruit/Adafruit_CircuitPython_IterTools 14 :alt: Build Status 15 16 Python's itertools for CircuitPython 17 18 19 Dependencies 20 ============= 21 This driver depends on: 22 23 * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_ 24 25 Please ensure all dependencies are available on the CircuitPython filesystem. 26 This is easily achieved by downloading 27 `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_. 28 29 30 Usage Example 31 ============= 32 33 .. code-block:: python 34 35 import time 36 import board 37 import busio 38 import adafruit_si7021 39 from adafruit_itertools.adafruit_itertools import count 40 from adafruit_itertools.adafruit_itertools_extras import repeatfunc 41 42 i2c = busio.I2C(board.SCL, board.SDA) 43 sensor = adafruit_si7021.SI7021(i2c) 44 45 def read_temperature(): 46 return sensor.temperature 47 48 def now(): 49 return time.monotonic() 50 51 datapoints = zip(count(1), repeatfunc(now), map(int, repeatfunc(read_temperature))) 52 53 while True: 54 print(next(datapoints)) 55 time.sleep(20.0) 56 57 Contributing 58 ============ 59 60 Contributions are welcome! Please read our `Code of Conduct 61 <https://github.com/adafruit/Adafruit_CircuitPython_itertools/blob/master/CODE_OF_CONDUCT.md>`_ 62 before contributing to help this project stay welcoming. 63 64 Building locally 65 ================ 66 67 Zip release files 68 ----------------- 69 70 To build this library locally you'll need to install the 71 `circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package. 72 73 .. code-block:: shell 74 75 python3 -m venv .env 76 source .env/bin/activate 77 pip install circuitpython-build-tools 78 79 Once installed, make sure you are in the virtual environment: 80 81 .. code-block:: shell 82 83 source .env/bin/activate 84 85 Then run the build: 86 87 .. code-block:: shell 88 89 circuitpython-build-bundles --filename_prefix adafruit-circuitpython-itertools --library_location . 90 91 Sphinx documentation 92 ----------------------- 93 94 Sphinx is used to build the documentation based on rST files and comments in the code. First, 95 install dependencies (feel free to reuse the virtual environment from above): 96 97 .. code-block:: shell 98 99 python3 -m venv .env 100 source .env/bin/activate 101 pip install Sphinx sphinx-rtd-theme 102 103 Now, once you have the virtual environment activated: 104 105 .. code-block:: shell 106 107 cd docs 108 sphinx-build -E -W -b html . _build/html 109 110 This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to 111 view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to 112 locally verify it will pass.