Skip to content

Commit 689301d

Browse files
authored
Merge pull request #6 from sommersoft/new_docs
Improve Ref Docs
2 parents 9149d64 + 28c2dcf commit 689301d

12 files changed

+227
-32
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
python:
2+
version: 3
13
requirements_file: requirements.txt
24

.travis.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,15 +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
21+
overwrite: true
2122
on:
2223
tags: true
2324

2425
install:
25-
- pip install pylint circuitpython-build-tools
26+
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
2627

2728
script:
2829
- pylint adafruit_ds3231.py
2930
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3031
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ds3231 --library_location .
32+
- cd docs && sphinx-build -E -W -b html . _build/html

CODE_OF_CONDUCT.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at [http://contributor-covenant.org/version/1/4][version]
72+
73+
[homepage]: http://contributor-covenant.org
74+
[version]: http://contributor-covenant.org/version/1/4/

README.rst

+71-22
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
Introduction
1+
Introduction
22
============
33

44
.. image:: https://readthedocs.org/projects/adafruit-micropython-ds3231/badge/?version=latest
55
:target: https://circuitpython.readthedocs.io/projects/ds3231/en/latest/
66
:alt: Documentation Status
77

8-
.. image :: https://badges.gitter.im/adafruit/circuitpython.svg
9-
:target: https://gitter.im/adafruit/circuitpython?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
10-
:alt: Gitter
8+
.. image :: https://img.shields.io/discord/327254708534116352.svg
9+
:target: https://discord.gg/nBQh6qu
10+
:alt: Discord
1111
1212
The datasheet for the DS3231 explains that this part is an
1313
"Extremely Accurate I²C-Integrated RTC/TCXO/Crystal". And,
@@ -33,16 +33,19 @@ timekeeping, even when main power is lost. Great for
3333
datalogging and clocks, or anything where you need to
3434
really know the time.
3535

36-
.. image:: 3013-01.jpg
36+
.. image:: ../docs/_static/3013-01.jpg
3737

3838
Dependencies
3939
=============
40+
This driver depends on:
4041

41-
This driver depends on the `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_
42-
and `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
43-
libraries. Please ensure they are also available on the CircuitPython filesystem.
42+
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
43+
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
44+
* `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_
45+
46+
Please ensure all dependencies are available on the CircuitPython filesystem.
4447
This is easily achieved by downloading
45-
`a library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
48+
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
4649

4750
Usage Notes
4851
===========
@@ -59,16 +62,16 @@ Of course, you must import the library to use it:
5962
import time
6063
6164
All the Adafruit RTC libraries take an instantiated and active I2C object
62-
(from the `busio` library) as an argument to their constructor. The way to
65+
(from the ``busio`` library) as an argument to their constructor. The way to
6366
create an I2C object depends on the board you are using. For boards with labeled
6467
SCL and SDA pins, you can:
6568

6669
.. code:: python
6770
6871
from board import *
6972
70-
You can also use pins defined by the onboard `microcontroller` through the
71-
`microcontroller.pin` module.
73+
You can also use pins defined by the onboard ``microcontroller`` through the
74+
``microcontroller.pin`` module.
7275

7376
Now, to initialize the I2C bus:
7477

@@ -86,15 +89,15 @@ the RTC object:
8689
Date and time
8790
-------------
8891

89-
To set the time, you need to set ``datetime`` to a `time.struct_time` object:
92+
To set the time, you need to set ``datetime`` to a ``time.struct_time`` object:
9093

9194
.. code:: python
9295
9396
rtc.datetime = time.struct_time((2017,1,9,15,6,0,0,9,-1))
9497
9598
After the RTC is set, you retrieve the time by reading the ``datetime``
96-
attribute and access the standard attributes of a struct_time such as `tm_year`,
97-
`tm_hour` and `tm_min`.
99+
attribute and access the standard attributes of a struct_time such as ``tm_year``,
100+
``tm_hour`` and ``tm_min``.
98101

99102
.. code:: python
100103
@@ -106,14 +109,14 @@ Alarm
106109
-----
107110

108111
To set the time, you need to set ``alarm1`` or ``alarm2`` to a tuple with a
109-
`time.struct_time` object and string representing the frequency such as "hourly":
112+
``time.struct_time`` object and string representing the frequency such as "hourly":
110113

111114
.. code:: python
112115
113116
rtc.alarm1 = (time.struct_time((2017,1,9,15,6,0,0,9,-1)), "daily")
114117
115118
After the RTC is set, you retrieve the alarm status by reading the corresponding
116-
`alarm1_status` or `alarm2_status` attributes. Once True, set it back to False
119+
``alarm1_status`` or ``alarm2_status`` attributes. Once True, set it back to False
117120
to reset.
118121

119122
.. code:: python
@@ -122,10 +125,56 @@ to reset.
122125
print("wake up!")
123126
rtc.alarm1_status = False
124127
125-
API Reference
126-
=============
128+
Contributing
129+
============
130+
131+
Contributions are welcome! Please read our `Code of Conduct
132+
<https://github.com/adafruit/Adafruit_CircuitPython_DS3231/blob/master/CODE_OF_CONDUCT.md>`_
133+
before contributing to help this project stay welcoming.
134+
135+
Building locally
136+
================
137+
138+
To build this library locally you'll need to install the
139+
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
140+
141+
.. code-block:: shell
142+
143+
python3 -m venv .env
144+
source .env/bin/activate
145+
pip install circuitpython-build-tools
146+
147+
Once installed, make sure you are in the virtual environment:
148+
149+
.. code-block:: shell
150+
151+
source .env/bin/activate
152+
153+
Then run the build:
154+
155+
.. code-block:: shell
156+
157+
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ds3231 --library_location .
158+
159+
Sphinx documentation
160+
-----------------------
161+
162+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
163+
install dependencies (feel free to reuse the virtual environment from above):
164+
165+
.. code-block:: shell
166+
167+
python3 -m venv .env
168+
source .env/bin/activate
169+
pip install Sphinx sphinx-rtd-theme
170+
171+
Now, once you have the virtual environment activated:
172+
173+
.. code-block:: shell
127174
128-
.. toctree::
129-
:maxdepth: 2
175+
cd docs
176+
sphinx-build -E -W -b html . _build/html
130177
131-
api
178+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
179+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
180+
locally verify it will pass.

adafruit_ds3231.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@
3434
**Hardware:**
3535
3636
* Adafruit `DS3231 Precision RTC FeatherWing <https://www.adafruit.com/products/3028>`_
37-
(Product ID: 3028)
37+
(Product ID: 3028)
38+
3839
* Adafruit `DS3231 RTC breakout <https://www.adafruit.com/products/3013>`_ (Product ID: 3013)
3940
* Adafruit `ChronoDot - Ultra-precise Real Time Clock -
40-
v2.1 <https://www.adafruit.com/products/255>`_ (Product ID: 3013)
41+
v2.1 <https://www.adafruit.com/products/255>`_ (Product ID: 3013)
4142
4243
**Software and Dependencies:**
4344
4445
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
45-
https://github.com/adafruit/circuitpython/releases
46+
https://github.com/adafruit/circuitpython/releases
47+
4648
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
4749
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
4850
File renamed without changes.

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

+14-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919
import os
2020
import sys
21-
sys.path.insert(0, os.path.abspath('.'))
21+
sys.path.insert(0, os.path.abspath('..'))
2222

2323
# -- General configuration ------------------------------------------------
2424

@@ -55,7 +55,7 @@
5555
# source_encoding = 'utf-8-sig'
5656

5757
# The master toctree document.
58-
master_doc = 'README'
58+
master_doc = 'index'
5959

6060
# General information about the project.
6161
project = u'Adafruit\'s DS3231 RTC Library'
@@ -90,7 +90,7 @@
9090
# List of patterns, relative to source directory, that match files and
9191
# directories to ignore when looking for source files.
9292
# This patterns also effect to html_static_path and html_extra_path
93-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
93+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
9494

9595
# The reST default role (used for this markup: `text`) to use for all
9696
# documents.
@@ -99,7 +99,7 @@
9999

100100
# If true, '()' will be appended to :func: etc. cross-reference text.
101101
#
102-
# add_function_parentheses = True
102+
add_function_parentheses = True
103103

104104
# If true, the current module name will be prepended to all description
105105
# unit titles (such as .. function::).
@@ -123,6 +123,9 @@
123123
# If true, `todo` and `todoList` produce output, else they produce nothing.
124124
todo_include_todos = True
125125

126+
# If this is True, todo emits a warning for each TODO entries. The default is False.
127+
todo_emit_warnings = True
128+
126129

127130
# -- Options for HTML output ----------------------------------------------
128131

@@ -176,6 +179,12 @@
176179
# so a file named "default.css" will overwrite the builtin "default.css".
177180
html_static_path = ['_static']
178181

182+
# The name of an image file (relative to this directory) to use as a favicon of
183+
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
184+
# pixels large.
185+
#
186+
html_favicon = '_static/favicon.ico'
187+
179188
# Add any extra paths that contain custom files (such as robots.txt or
180189
# .htaccess) here, relative to this directory. These files are copied
181190
# directly to the root of the documentation.
@@ -254,7 +263,7 @@
254263
# html_search_scorer = 'scorer.js'
255264

256265
# Output file base name for HTML help builder.
257-
# htmlhelp_basename = 'AdafruitsDS3231RTCLibrarydoc'
266+
htmlhelp_basename = 'AdafruitsDS3231RTCLibrarydoc'
258267

259268
# -- Options for LaTeX output ---------------------------------------------
260269

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

0 commit comments

Comments
 (0)