Skip to content

Improve Ref Docs #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ deploy:
provider: releases
api_key: $GITHUB_TOKEN
file_glob: true
file: bundles/*
file: $TRAVIS_BUILD_DIR/bundles/*
skip_cleanup: true
overwrite: true
on:
tags: true

install:
- pip install pylint circuitpython-build-tools
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme

script:
- pylint adafruit_ds1307.py
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ds1307 --library_location .
- cd docs && sphinx-build -E -W -b html . _build/html
86 changes: 68 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Introduction
:target: https://circuitpython.readthedocs.io/projects/ds1307/en/latest/
:alt: Documentation Status

.. image :: https://badges.gitter.im/adafruit/circuitpython.svg
:target: https://gitter.im/adafruit/circuitpython?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
:alt: Gitter
.. image :: https://img.shields.io/discord/327254708534116352.svg
:target: https://discord.gg/nBQh6qu
:alt: Discord

This is a great battery-backed real time clock (RTC) that allows your
microcontroller project to keep track of time even if it is reprogrammed,
Expand All @@ -24,16 +24,20 @@ If you do not need a DS1307, or you need a 3.3V-power/logic capable RTC
please check out our affordable
`PCF8523 RTC breakout <https://www.adafruit.com/products/3295>`_.

.. image:: 3296-00.jpg
.. image:: ../docs/_static/3296-00.jpg
:alt: DS1307

Dependencies
=============
This driver depends on:

This driver depends on the `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_
and `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
libraries. Please ensure they are also available on the CircuitPython filesystem.
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
* `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_

Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`a library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.

Usage Notes
===========
Expand All @@ -47,16 +51,16 @@ Of course, you must import the library to use it:
import time

All the Adafruit RTC libraries take an instantiated and active I2C object
(from the `busio` library) as an argument to their constructor. The way to
(from the ``busio`` library) as an argument to their constructor. The way to
create an I2C object depends on the board you are using. For boards with labeled
SCL and SDA pins, you can:

.. code:: python

from board import *

You can also use pins defined by the onboard `microcontroller` through the
`microcontroller.pin` module.
You can also use pins defined by the onboard ``microcontroller`` through the
``microcontroller.pin`` module.

Now, to initialize the I2C bus:

Expand All @@ -78,19 +82,65 @@ To set the time, you need to set ``datetime`` to a `time.struct_time` object:
rtc.datetime = time.struct_time((2017,1,9,15,6,0,0,9,-1))

After the RTC is set, you retrieve the time by reading the ``datetime``
attribute and access the standard attributes of a struct_time such as `tm_year`,
`tm_hour` and `tm_min`.
attribute and access the standard attributes of a struct_time such as ``tm_year``,
``tm_hour`` and ``tm_min``.

.. code:: python

t = rtc.datetime
print(t)
print(t.tm_hour, t.tm_min)

API Reference
=============
Contributing
============

Contributions are welcome! Please read our `Code of Conduct
<https://github.com/adafruit/Adafruit_CircuitPython_VEML6070/blob/master/CODE_OF_CONDUCT.md>`_
before contributing to help this project stay welcoming.

Building locally
================

To build this library locally you'll need to install the
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.

.. code-block:: shell

python3 -m venv .env
source .env/bin/activate
pip install circuitpython-build-tools

Once installed, make sure you are in the virtual environment:

.. code-block:: shell

source .env/bin/activate

Then run the build:

.. code-block:: shell

circuitpython-build-bundles --filename_prefix adafruit-circuitpython-ds1307 --library_location .

Sphinx documentation
-----------------------

Sphinx is used to build the documentation based on rST files and comments in the code. First,
install dependencies (feel free to reuse the virtual environment from above):

.. code-block:: shell

python3 -m venv .env
source .env/bin/activate
pip install Sphinx sphinx-rtd-theme

Now, once you have the virtual environment activated:

.. code-block:: shell

.. toctree::
:maxdepth: 2
cd docs
sphinx-build -E -W -b html . _build/html

api
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
locally verify it will pass.
3 changes: 0 additions & 3 deletions api.rst

This file was deleted.

File renamed without changes
Binary file added docs/_static/favicon.ico
Binary file not shown.
5 changes: 5 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

.. If you created a package, create one automodule per module in the package.

.. automodule:: adafruit_ds1307
:members:
22 changes: 18 additions & 4 deletions conf.py → docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('..'))

# -- General configuration ------------------------------------------------

Expand All @@ -35,6 +35,11 @@
'sphinx.ext.viewcode',
]

# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
autodoc_mock_imports = ["adafruit_register", "adafruit_bus_device"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand All @@ -49,7 +54,7 @@
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'README'
master_doc = 'index'

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

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

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

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

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


# -- Options for HTML output ----------------------------------------------

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

# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#
html_favicon = '_static/favicon.ico'

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
Expand Down
8 changes: 8 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Simple test
------------

Ensure your device works with this simple test.

.. literalinclude:: ../examples/ds1307_simpletest.py
:caption: examples/ds1307_simpletest.py
:linenos:
47 changes: 47 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.. include:: ../README.rst

Table of Contents
=================

.. toctree::
:maxdepth: 4
:hidden:

self

.. toctree::
:caption: Examples

examples

.. toctree::
:caption: API Reference
:maxdepth: 3

api

.. toctree::
:caption: Tutorials

.. toctree::
:caption: Related Products

Adafruit DS1307 Real Time Clock Assembled Breakout Board <https://www.adafruit.com/product/3296>

.. toctree::
:caption: Other Links

Download <https://github.com/adafruit/Adafruit_CircuitPython_DS1307/releases/latest>
CircuitPython Reference Documentation <https://circuitpython.readthedocs.io>
CircuitPython Support Forum <https://forums.adafruit.com/viewforum.php?f=60>
Discord Chat <https://adafru.it/discord>
Adafruit Learning System <https://learn.adafruit.com>
Adafruit Blog <https://blog.adafruit.com>
Adafruit Store <https://www.adafruit.com>

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
File renamed without changes.