Skip to content

Commit c7e8160

Browse files
authored
Merge pull request #4709 from jposada202020/adding_usage_template
adding_usage_template in Design Guide
2 parents 30c7aa8 + 0f60a3b commit c7e8160

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

docs/design_guide.rst

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,17 @@ After the license comment::
251251

252252
**Hardware:**
253253

254-
* Adafruit `Device Description
254+
* `Adafruit Device Description
255255
<hyperlink>`_ (Product ID: <Product Number>)
256256

257257
**Software and Dependencies:**
258258

259259
* Adafruit CircuitPython firmware for the supported boards:
260260
https://circuitpython.org/downloads
261+
261262
* Adafruit's Bus Device library:
262263
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
264+
263265
* Adafruit's Register library:
264266
https://github.com/adafruit/Adafruit_CircuitPython_Register
265267

@@ -525,6 +527,50 @@ SPI Example
525527
spi.readinto(self.buf)
526528
return self.buf[0]
527529
530+
531+
532+
Class documentation example template
533+
--------------------------------------------------------------------------------
534+
When documenting classes, you should use the following template to illustrate basic usage.
535+
It is similar with the simpletest example, however this will display the information in the Read The Docs
536+
documentation.
537+
The advantage of using this template is it makes the documentation consistent across the libraries.
538+
539+
This is an example for a AHT20 temperature sensor. Include the following after the class parameter:
540+
541+
542+
.. code-block:: python
543+
544+
"""
545+
546+
**Quickstart: Importing and using the AHT10/AHT20 temperature sensor**
547+
548+
Here is an example of using the :class:`AHTx0` class.
549+
First you will need to import the libraries to use the sensor
550+
551+
.. code-block:: python
552+
553+
import board
554+
import adafruit_ahtx0
555+
556+
Once this is done you can define your `board.I2C` object and define your sensor object
557+
558+
.. code-block:: python
559+
560+
i2c = board.I2C() # uses board.SCL and board.SDA
561+
aht = adafruit_ahtx0.AHTx0(i2c)
562+
563+
Now you have access to the temperature and humidity using
564+
the :attr:`temperature` and :attr:`relative_humidity` attributes
565+
566+
.. code-block:: python
567+
568+
temperature = aht.temperature
569+
relative_humidity = aht.relative_humidity
570+
571+
"""
572+
573+
528574
Use composition
529575
--------------------------------------------------------------------------------
530576

0 commit comments

Comments
 (0)