Skip to content

Commit 522374d

Browse files
authored
Merge pull request #5 from sommersoft/new_docs
Improve Ref Docs
2 parents 05865ee + 739a6e2 commit 522374d

File tree

9 files changed

+120
-10
lines changed

9 files changed

+120
-10
lines changed
File renamed without changes.

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ 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
2121
on:
2222
tags: true
2323

2424
install:
25-
- pip install pylint circuitpython-build-tools
25+
- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme
2626

2727
script:
2828
- pylint adafruit_bmp280.py
2929
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3030
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-bmp280 --library_location .
31+
- cd docs && sphinx-build -E -W -b html . _build/html

README.rst

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,49 @@ Contributions are welcome! Please read our `Code of Conduct
6060
<https://github.com/adafruit/Adafruit_CircuitPython_bmp280/blob/master/CODE_OF_CONDUCT.md>`_
6161
before contributing to help this project stay welcoming.
6262

63-
API Reference
64-
=============
63+
Building locally
64+
================
65+
66+
To build this library locally you'll need to install the
67+
`circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
68+
69+
.. code-block:: shell
70+
71+
python3 -m venv .env
72+
source .env/bin/activate
73+
pip install circuitpython-build-tools
74+
75+
Once installed, make sure you are in the virtual environment:
76+
77+
.. code-block:: shell
78+
79+
source .env/bin/activate
80+
81+
Then run the build:
82+
83+
.. code-block:: shell
84+
85+
circuitpython-build-bundles --filename_prefix adafruit-circuitpython-bmp280 --library_location .
86+
87+
Sphinx documentation
88+
-----------------------
89+
90+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
91+
install dependencies (feel free to reuse the virtual environment from above):
92+
93+
.. code-block:: shell
94+
95+
python3 -m venv .env
96+
source .env/bin/activate
97+
pip install Sphinx sphinx-rtd-theme
98+
99+
Now, once you have the virtual environment activated:
100+
101+
.. code-block:: shell
65102
66-
.. toctree::
67-
:maxdepth: 2
103+
cd docs
104+
sphinx-build -E -W -b html . _build/html
68105
69-
api
106+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
107+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
108+
locally verify it will pass.

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44
import sys
5-
sys.path.insert(0, os.path.abspath('.'))
5+
sys.path.insert(0, os.path.abspath('..'))
66

77
# -- General configuration ------------------------------------------------
88

@@ -15,6 +15,11 @@
1515
'sphinx.ext.viewcode',
1616
]
1717

18+
# Uncomment the below if you use native CircuitPython modules such as
19+
# digitalio, micropython and busio. List the modules you use. Without it, the
20+
# autodoc module docs will fail to generate with a warning.
21+
autodoc_mock_imports = ["micropython", "adafruit_bus_device"]
22+
1823
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/bus_device/en/latest/', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
1924

2025
# Add any paths that contain templates here, relative to this directory.
@@ -23,7 +28,7 @@
2328
source_suffix = '.rst'
2429

2530
# The master toctree document.
26-
master_doc = 'README'
31+
master_doc = 'index'
2732

2833
# General information about the project.
2934
project = u'Adafruit BMP280 Library'
@@ -49,7 +54,7 @@
4954
# List of patterns, relative to source directory, that match files and
5055
# directories to ignore when looking for source files.
5156
# This patterns also effect to html_static_path and html_extra_path
52-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
57+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
5358

5459
# The reST default role (used for this markup: `text`) to use for all
5560
# documents.
@@ -66,6 +71,10 @@
6671
# If true, `todo` and `todoList` produce output, else they produce nothing.
6772
todo_include_todos = False
6873

74+
# If this is True, todo emits a warning for each TODO entries. The default is False.
75+
todo_emit_warnings = True
76+
77+
6978

7079
# -- Options for HTML output ----------------------------------------------
7180

@@ -90,6 +99,12 @@
9099
# so a file named "default.css" will overwrite the builtin "default.css".
91100
html_static_path = ['_static']
92101

102+
# The name of an image file (relative to this directory) to use as a favicon of
103+
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
104+
# pixels large.
105+
#
106+
html_favicon = '_static/favicon.ico'
107+
93108
# Output file base name for HTML help builder.
94109
htmlhelp_basename = 'AdafruitBMP280Librarydoc'
95110

docs/examples.rst

Lines changed: 8 additions & 0 deletions
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/bmp280_simpletest.py
7+
:caption: examples/bmp280_simpletest.py
8+
:linenos:

docs/index.rst

Lines changed: 47 additions & 0 deletions
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 BMP280 I2C or SPI Barometric Pressure & Altitude Sensor <https://www.adafruit.com/product/2651>
30+
31+
.. toctree::
32+
:caption: Other Links
33+
34+
Download <https://github.com/adafruit/Adafruit_CircuitPython_BMP280/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)