Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

Commit 65fa1f7

Browse files
authored
Merge pull request #3 from sommersoft/new_docs
Improve Ref Docs
2 parents c922272 + b8619ca commit 65fa1f7

13 files changed

+153
-40
lines changed
File renamed without changes.

.travis.yml

Lines changed: 4 additions & 2 deletions
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 --disable=missing-docstring adafruit_thermal_printer/*.py
2930
- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py)
3031
- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-thermal-printer --library_location .
32+
- cd docs && sphinx-build -E -W -b html . _build/html

README.rst

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Introduction
1010
:target: https://discord.gg/nBQh6qu
1111
:alt: Discord
1212
13+
.. image:: https://travis-ci.org/adafruit/Adafruit_CircuitPython_Thermal_Printer.svg?branch=master
14+
:target: https://travis-ci.org/adafruit/Adafruit_CircuitPython_Thermal_Printer
15+
:alt: Build Status
16+
1317
CircuitPython module for control of various small serial thermal printers.
1418

1519
Dependencies
@@ -25,15 +29,7 @@ This is easily achieved by downloading
2529
Usage Example
2630
=============
2731

28-
See examples/simpletest.py for a demo of basic printer usage.
29-
30-
API Reference
31-
=============
32-
33-
.. toctree::
34-
:maxdepth: 2
35-
36-
api
32+
See examples/thermal_printer_simpletest.py for a demo of basic printer usage.
3733

3834
Contributing
3935
============
@@ -65,3 +61,26 @@ Then run the build:
6561
.. code-block:: shell
6662
6763
circuitpython-build-bundles --filename_prefix adafruit_circuitpython_thermal_printer --library_location .
64+
65+
Sphinx documentation
66+
-----------------------
67+
68+
Sphinx is used to build the documentation based on rST files and comments in the code. First,
69+
install dependencies (feel free to reuse the virtual environment from above):
70+
71+
.. code-block:: shell
72+
73+
python3 -m venv .env
74+
source .env/bin/activate
75+
pip install Sphinx sphinx-rtd-theme
76+
77+
Now, once you have the virtual environment activated:
78+
79+
.. code-block:: shell
80+
81+
cd docs
82+
sphinx-build -E -W -b html . _build/html
83+
84+
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
85+
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
86+
locally verify it will pass.

adafruit_thermal_printer/thermal_printer.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,33 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222
"""
23-
`adafruit_thermal_printer`
24-
====================================================
23+
`adafruit_thermal_printer.thermal_printer` - Thermal Printer Driver
24+
=====================================================================
2525
2626
Thermal printer control module built to work with small serial thermal
2727
receipt printers. Note that these printers have many different firmware
2828
versions and care must be taken to select the appropriate module inside this
2929
package for your firmware printer:
30-
- thermal_printer = The latest printers with firmware version 2.68+
31-
- thermal_printer_264 = Printers with firmware version 2.64 up to 2.68.
32-
- thermal_printer_legacy = Printers with firmware version before 2.64.
30+
31+
* thermal_printer = The latest printers with firmware version 2.68+
32+
* thermal_printer_264 = Printers with firmware version 2.64 up to 2.68.
33+
* thermal_printer_legacy = Printers with firmware version before 2.64.
3334
3435
* Author(s): Tony DiCola
36+
37+
Implementation Notes
38+
--------------------
39+
40+
**Hardware:**
41+
42+
* Mini `Thermal Receipt Printer
43+
<https://www.adafruit.com/product/597>`_ (Product ID: 597)
44+
45+
**Software and Dependencies:**
46+
47+
* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
48+
https://github.com/adafruit/circuitpython/releases
49+
3550
"""
3651
import time
3752

@@ -319,7 +334,8 @@ def _print_bitmap(self, width, height, data):
319334
pre-process your images with a script, you CANNOT send .jpg/.bmp/etc.
320335
image formats. See this Processing sketch for preprocessing:
321336
https://github.com/adafruit/Adafruit-Thermal-Printer-Library/blob/master/processing/bitmapImageConvert/bitmapImageConvert.pde
322-
NOTE: This is currently not working because it appears the bytes are
337+
338+
.. note:: This is currently not working because it appears the bytes are
323339
sent too slowly and the printer gets confused with not enough data being
324340
sent to it in the expected time.
325341
"""

adafruit_thermal_printer/thermal_printer_264.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222
"""
23-
`adafruit_thermal_printer_264`
24-
====================================================
23+
`adafruit_thermal_printer.thermal_printer_264.ThermalPrinter`
24+
==============================================================
2525
2626
Thermal printer control module built to work with small serial thermal
2727
receipt printers. Note that these printers have many different firmware
2828
versions and care must be taken to select the appropriate module inside this
2929
package for your firmware printer:
30-
- thermal_printer = The latest printers with firmware version 2.68+
31-
- thermal_printer_264 = Printers with firmware version 2.64 up to 2.68.
32-
- thermal_printer_legacy = Printers with firmware version before 2.64.
30+
31+
* thermal_printer = The latest printers with firmware version 2.68+
32+
* thermal_printer_264 = Printers with firmware version 2.64 up to 2.68.
33+
* thermal_printer_legacy = Printers with firmware version before 2.64.
3334
3435
* Author(s): Tony DiCola
3536
"""

adafruit_thermal_printer/thermal_printer_legacy.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222
"""
23-
`adafruit_thermal_printer_legacy`
24-
====================================================
23+
`adafruit_thermal_printer.thermal_printer_legacy.ThermalPrinter`
24+
=================================================================
2525
2626
Thermal printer control module built to work with small serial thermal
2727
receipt printers. Note that these printers have many different firmware
2828
versions and care must be taken to select the appropriate module inside this
2929
package for your firmware printer:
30-
- thermal_printer = The latest printers with firmware version 2.68+
31-
- thermal_printer_264 = Printers with firmware version 2.64 up to 2.68.
32-
- thermal_printer_legacy = Printers with firmware version before 2.64.
30+
31+
* thermal_printer = The latest printers with firmware version 2.68+
32+
* thermal_printer_264 = Printers with firmware version 2.64 up to 2.68.
33+
* thermal_printer_legacy = Printers with firmware version before 2.64.
3334
3435
* Author(s): Tony DiCola
3536
"""
@@ -128,9 +129,13 @@ def feed(self, lines):
128129

129130
def has_paper(self):
130131
"""Return a boolean indicating if the printer has paper. You MUST have
131-
the serial RX line hooked up for this to work. NOTE: be VERY CAREFUL
132-
to ensure your board can handle a 5V serial input before hooking up
133-
the RX line!
132+
the serial RX line hooked up for this to work.
133+
134+
.. note::
135+
136+
be VERY CAREFUL to ensure your board can handle a 5V serial
137+
input before hooking up the RX line!
138+
134139
"""
135140
# The paper check command is different for older firmware:
136141
self.send_command('\x1Br\x00') # ESC + 'r' + 0

api.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/_static/favicon.ico

4.31 KB
Binary file not shown.

docs/api.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
.. If you created a package, create one automodule per module in the package.
3+
4+
.. automodule:: adafruit_thermal_printer.thermal_printer
5+
:members:
6+
7+
.. automodule:: adafruit_thermal_printer.thermal_printer_264
8+
:members:
9+
10+
.. automodule:: adafruit_thermal_printer.thermal_printer_legacy
11+
:members:

conf.py renamed to docs/conf.py

Lines changed: 14 additions & 5 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

@@ -18,7 +18,7 @@
1818
# Uncomment the below if you use native CircuitPython modules such as
1919
# digitalio, micropython and busio. List the modules you use. Without it, the
2020
# autodoc module docs will fail to generate with a warning.
21-
autodoc_mock_imports = ["micropython", "adafruit_thermal_printer"]
21+
autodoc_mock_imports = ["micropython"]#, "adafruit_thermal_printer"]
2222

2323
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
2424

@@ -28,7 +28,7 @@
2828
source_suffix = '.rst'
2929

3030
# The master toctree document.
31-
master_doc = 'README'
31+
master_doc = 'index'
3232

3333
# General information about the project.
3434
project = u'adafruit_thermal_printer Library'
@@ -54,7 +54,7 @@
5454
# List of patterns, relative to source directory, that match files and
5555
# directories to ignore when looking for source files.
5656
# This patterns also effect to html_static_path and html_extra_path
57-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
57+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
5858

5959
# The reST default role (used for this markup: `text`) to use for all
6060
# documents.
@@ -71,6 +71,9 @@
7171
# If true, `todo` and `todoList` produce output, else they produce nothing.
7272
todo_include_todos = False
7373

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

7578
# -- Options for HTML output ----------------------------------------------
7679

@@ -95,8 +98,14 @@
9598
# so a file named "default.css" will overwrite the builtin "default.css".
9699
html_static_path = ['_static']
97100

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

101110
# -- Options for LaTeX output ---------------------------------------------
102111

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/thermal_printer_simpletest.py
7+
:caption: examples/thermal_printer_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+
Mini Thermal Receipt Printer <https://www.adafruit.com/product/597>
30+
31+
.. toctree::
32+
:caption: Other Links
33+
34+
Download <https://github.com/adafruit/Adafruit_CircuitPython_Thermal_Printer/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)