Skip to content

Commit cb4e223

Browse files
authored
Merge pull request #4 from sommersoft/new_docs
Improve Ref Docs
2 parents 6d53cf9 + a88a3a3 commit cb4e223

11 files changed

+150
-27
lines changed
File renamed without changes.

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

README.rst

+68-18
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Introduction
66
:target: https://circuitpython.readthedocs.io/projects/ds1307/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
9+
.. image :: https://img.shields.io/discord/327254708534116352.svg
10+
:target: https://discord.gg/nBQh6qu
11+
:alt: Discord
1212
1313
This is a great battery-backed real time clock (RTC) that allows your
1414
microcontroller project to keep track of time even if it is reprogrammed,
@@ -24,16 +24,20 @@ If you do not need a DS1307, or you need a 3.3V-power/logic capable RTC
2424
please check out our affordable
2525
`PCF8523 RTC breakout <https://www.adafruit.com/products/3295>`_.
2626

27-
.. image:: 3296-00.jpg
27+
.. image:: ../docs/_static/3296-00.jpg
28+
:alt: DS1307
2829

2930
Dependencies
3031
=============
32+
This driver depends on:
3133

32-
This driver depends on the `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_
33-
and `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
34-
libraries. Please ensure they are also available on the CircuitPython filesystem.
34+
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
35+
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
36+
* `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_
37+
38+
Please ensure all dependencies are available on the CircuitPython filesystem.
3539
This is easily achieved by downloading
36-
`a library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
40+
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
3741

3842
Usage Notes
3943
===========
@@ -47,16 +51,16 @@ Of course, you must import the library to use it:
4751
import time
4852
4953
All the Adafruit RTC libraries take an instantiated and active I2C object
50-
(from the `busio` library) as an argument to their constructor. The way to
54+
(from the ``busio`` library) as an argument to their constructor. The way to
5155
create an I2C object depends on the board you are using. For boards with labeled
5256
SCL and SDA pins, you can:
5357

5458
.. code:: python
5559
5660
from board import *
5761
58-
You can also use pins defined by the onboard `microcontroller` through the
59-
`microcontroller.pin` module.
62+
You can also use pins defined by the onboard ``microcontroller`` through the
63+
``microcontroller.pin`` module.
6064

6165
Now, to initialize the I2C bus:
6266

@@ -78,19 +82,65 @@ To set the time, you need to set ``datetime`` to a `time.struct_time` object:
7882
rtc.datetime = time.struct_time((2017,1,9,15,6,0,0,9,-1))
7983
8084
After the RTC is set, you retrieve the time by reading the ``datetime``
81-
attribute and access the standard attributes of a struct_time such as `tm_year`,
82-
`tm_hour` and `tm_min`.
85+
attribute and access the standard attributes of a struct_time such as ``tm_year``,
86+
``tm_hour`` and ``tm_min``.
8387

8488
.. code:: python
8589
8690
t = rtc.datetime
8791
print(t)
8892
print(t.tm_hour, t.tm_min)
8993
90-
API Reference
91-
=============
94+
Contributing
95+
============
96+
97+
Contributions are welcome! Please read our `Code of Conduct
98+
<https://github.com/adafruit/Adafruit_CircuitPython_VEML6070/blob/master/CODE_OF_CONDUCT.md>`_
99+
before contributing to help this project stay welcoming.
100+
101+
Building locally
102+
================
103+
104+
To build this library locally you'll need to install the
105+
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
106+
107+
.. code-block:: shell
108+
109+
python3 -m venv .env
110+
source .env/bin/activate
111+
pip install circuitpython-build-tools
112+
113+
Once installed, make sure you are in the virtual environment:
114+
115+
.. code-block:: shell
116+
117+
source .env/bin/activate
118+
119+
Then run the build:
120+
121+
.. code-block:: shell
122+
123+
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ds1307 --library_location .
124+
125+
Sphinx documentation
126+
-----------------------
127+
128+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
129+
install dependencies (feel free to reuse the virtual environment from above):
130+
131+
.. code-block:: shell
132+
133+
python3 -m venv .env
134+
source .env/bin/activate
135+
pip install Sphinx sphinx-rtd-theme
136+
137+
Now, once you have the virtual environment activated:
138+
139+
.. code-block:: shell
92140
93-
.. toctree::
94-
:maxdepth: 2
141+
cd docs
142+
sphinx-build -E -W -b html . _build/html
95143
96-
api
144+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
145+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
146+
locally verify it will pass.

api.rst

-3
This file was deleted.
File renamed without changes.

docs/_static/favicon.ico

4.31 KB
Binary file not shown.

docs/api.rst

+5
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_ds1307
5+
:members:

conf.py renamed to docs/conf.py

+18-4
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

@@ -35,6 +35,11 @@
3535
'sphinx.ext.viewcode',
3636
]
3737

38+
# Uncomment the below if you use native CircuitPython modules such as
39+
# digitalio, micropython and busio. List the modules you use. Without it, the
40+
# autodoc module docs will fail to generate with a warning.
41+
autodoc_mock_imports = ["adafruit_register", "adafruit_bus_device"]
42+
3843
# Add any paths that contain templates here, relative to this directory.
3944
templates_path = ['_templates']
4045

@@ -49,7 +54,7 @@
4954
# source_encoding = 'utf-8-sig'
5055

5156
# The master toctree document.
52-
master_doc = 'README'
57+
master_doc = 'index'
5358

5459
# General information about the project.
5560
project = u'Adafruit DS1307 Library'
@@ -84,7 +89,7 @@
8489
# List of patterns, relative to source directory, that match files and
8590
# directories to ignore when looking for source files.
8691
# This patterns also effect to html_static_path and html_extra_path
87-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
92+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
8893

8994
# The reST default role (used for this markup: `text`) to use for all
9095
# documents.
@@ -93,7 +98,7 @@
9398

9499
# If true, '()' will be appended to :func: etc. cross-reference text.
95100
#
96-
# add_function_parentheses = True
101+
add_function_parentheses = True
97102

98103
# If true, the current module name will be prepended to all description
99104
# unit titles (such as .. function::).
@@ -117,6 +122,9 @@
117122
# If true, `todo` and `todoList` produce output, else they produce nothing.
118123
todo_include_todos = False
119124

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

121129
# -- Options for HTML output ----------------------------------------------
122130

@@ -170,6 +178,12 @@
170178
# so a file named "default.css" will overwrite the builtin "default.css".
171179
html_static_path = ['_static']
172180

181+
# The name of an image file (relative to this directory) to use as a favicon of
182+
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
183+
# pixels large.
184+
#
185+
html_favicon = '_static/favicon.ico'
186+
173187
# Add any extra paths that contain custom files (such as robots.txt or
174188
# .htaccess) here, relative to this directory. These files are copied
175189
# directly to the root of the documentation.

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

docs/index.rst

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

0 commit comments

Comments
 (0)