Skip to content

Commit 55ca36b

Browse files
committed
Rework docs and prepare for release at version 0.12.
1 parent 0b5eb13 commit 55ca36b

19 files changed

Lines changed: 345 additions & 270 deletions

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
<img src="https://raw.githubusercontent.com/mmulqueen/pyStrich/main/docs/logo.png" alt="pyStrich" width="200">
2+
13
pyStrich
24
========
3-
pyStrich is a Python module to generate 1D and 2D barcodes. Currently it
4-
supports
5+
pyStrich is a Python module to generate 1D and 2D barcodes in PNG, SVG and other image formats. Currently it
6+
supports:
57

68
* code39
79
* code128
810
* ean13
911
* datamatrix
1012
* qrcode
1113

14+
pyStrich only depends on Pillow and has no other dependencies.
15+
1216
Available from PyPI: https://pypi.org/project/pyStrich/
1317

1418
Documentation: https://www.method-b.uk/pyStrich/docs/

docs/changelog.rst

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Changelog
22
=========
33

4-
0.12 — unreleased
4+
0.12 — 2026-05-09
55
-----------------
66

77
- New ``pystrich`` console script with a subcommand per format and PNG /
@@ -25,12 +25,13 @@ Changelog
2525
:class:`~pystrich.ean13.EAN13Encoder`.
2626
- The human-readable labels for 1D barcodes are rendered with bundled Courier Prime glyph outlines (SIL Open
2727
Font License).
28-
- DXF: :meth:`~pystrich.qrcode.QRCodeEncoder.get_dxf` and
29-
:meth:`~pystrich.datamatrix.DataMatrixEncoder.get_dxf` now write the
30-
correct ``$INSUNITS`` value for ``"in"``, ``"ft"``, ``"mi"``,
31-
``"cm"`` and ``"m"`` (previously any value other than ``"mm"`` was
32-
silently treated as unspecified); you should now pass ``units=None``
33-
if unspecified is desired.
28+
- DXF: ``get_dxf()`` on
29+
:class:`~pystrich.qrcode.QRCodeEncoder` and
30+
:class:`~pystrich.datamatrix.DataMatrixEncoder` now writes the correct
31+
``$INSUNITS`` value for ``"in"``, ``"ft"``, ``"mi"``, ``"cm"`` and
32+
``"m"`` (previously any value other than ``"mm"`` was silently treated
33+
as unspecified); you should now pass ``units=None`` if unspecified is
34+
desired.
3435
- All vector outputs accept a ``mark_shape`` keyword argument
3536
(:class:`~pystrich.marks.MarkShape`) selecting how matched cells are
3637
grouped and drawn: horizontal runs (the SVG / EPS default), one
@@ -50,13 +51,13 @@ Changelog
5051

5152
.. note::
5253

53-
Erratum: the
54-
:meth:`~pystrich.qrcode.QRCodeEncoder.get_dxf` and
55-
:meth:`~pystrich.datamatrix.DataMatrixEncoder.get_dxf` docstrings
56-
stated that ``inverse=True`` (the default) draws dark modules as
57-
filled cells. In fact ``inverse=True`` draws the *light* modules;
58-
``inverse=False`` draws the dark ones. Behaviour is unchanged --
59-
only the description was wrong. Corrected in 0.12.
54+
Erratum: the ``get_dxf()`` docstrings on
55+
:class:`~pystrich.qrcode.QRCodeEncoder` and
56+
:class:`~pystrich.datamatrix.DataMatrixEncoder` stated that
57+
``inverse=True`` (the default) draws dark modules as filled cells.
58+
In fact ``inverse=True`` draws the *light* modules; ``inverse=False``
59+
draws the dark ones. Behaviour is unchanged -- only the description
60+
was wrong. Corrected in 0.12.
6061

6162
- Documentation: full Sphinx-built docs are now published at
6263
https://www.method-b.uk/pyStrich/docs/, covering each symbology, recipes

docs/code128.rst

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,21 @@ Example
1717
1818
from pystrich.code128 import Code128Encoder
1919
20-
encoder = Code128Encoder("PyStrich-2026")
21-
encoder.save("code128-example.png")
20+
encoder = Code128Encoder("WDBCA45D2HA327260")
21+
encoder.save_svg("code128-example.svg")
2222
23-
.. image:: examples/code128-example.png
24-
:alt: Code 128 barcode encoding "PyStrich-2026".
23+
.. image:: examples/code128-example.svg
24+
:alt: Code 128 barcode encoding "WDBCA45D2HA327260".
2525

26-
Sizing
27-
------
26+
Sizing, label, font and layout
27+
------------------------------
2828

2929
The ``bar_width`` argument to :meth:`~Code128Encoder.save` and
3030
:meth:`~Code128Encoder.get_imagedata` sets the pixel width of the narrowest
3131
bar (default ``3``).
3232

33-
.. code-block:: python
34-
35-
encoder = Code128Encoder("PyStrich-2026")
36-
encoder.save("code128-wide.png", bar_width=6)
37-
38-
.. image:: examples/code128-wide.png
39-
:alt: Code 128 barcode encoding "PyStrich-2026" rendered with bar_width=6.
40-
41-
.. seealso::
42-
43-
:doc:`printing` for guidance on selecting ``bar_width`` for printed
44-
output.
45-
46-
Label, font and layout
47-
----------------------
48-
4933
The ``options`` dict passed to :class:`Code128Encoder` controls the
50-
human-readable label and the surrounding layout (see also the identical
51-
options on :doc:`code39`). All keys are optional.
34+
human-readable label and the surrounding layout. All keys are optional.
5235

5336
``show_label``
5437
Whether to render the human-readable label underneath the bars. Defaults
@@ -66,6 +49,11 @@ options on :doc:`code39`). All keys are optional.
6649
``bottom_border``
6750
Pixels of vertical space between the label and the bottom edge.
6851

52+
.. seealso::
53+
54+
:doc:`printing` for guidance on selecting ``bar_width`` for printed
55+
output.
56+
6957
.. code-block:: python
7058
7159
options = {
@@ -75,42 +63,55 @@ options on :doc:`code39`). All keys are optional.
7563
"ttf_fontsize": 24,
7664
# "ttf_font": "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
7765
}
78-
encoder = Code128Encoder("PyStrich-2026", options=options)
66+
encoder = Code128Encoder("WDBCA45D2HA327260", options=options)
7967
encoder.save("code128-custom.png", bar_width=4)
8068
8169
.. image:: examples/code128-custom.png
82-
:alt: Code 128 barcode encoding "PyStrich-2026" with a taller image and larger label.
70+
:alt: Code 128 barcode encoding "WDBCA45D2HA327260" with a taller image and larger label.
71+
72+
Output formats
73+
--------------
8374

8475
SVG output
85-
----------
76+
~~~~~~~~~~
8677

8778
For embedding in web pages or any workflow that benefits from
8879
resolution-independent output, use :meth:`~Code128Encoder.save_svg` (or
8980
:meth:`~Code128Encoder.get_svg` to receive the SVG as a string).
9081

9182
.. code-block:: python
9283
93-
Code128Encoder("PyStrich-2026").save_svg("code128.svg")
84+
Code128Encoder("WDBCA45D2HA327260").save_svg("code128.svg")
9485
9586
.. image:: examples/code128-example.svg
96-
:alt: SVG Code 128 barcode encoding "PyStrich-2026".
87+
:alt: SVG Code 128 barcode encoding "WDBCA45D2HA327260".
9788

9889
The SVG's ``viewBox`` is in module units (one narrow bar = one unit), while
9990
``width`` and ``height`` scale by ``bar_width``. The 10-module quiet zones
10091
mandated by the standard are applied automatically on each side.
10192

10293
.. versionadded:: 0.12
10394

95+
PNG output
96+
~~~~~~~~~~
97+
98+
For raster output, use :meth:`~Code128Encoder.save` to write a PNG file or
99+
:meth:`~Code128Encoder.get_imagedata` to receive the raw PNG bytes.
100+
101+
.. code-block:: python
102+
103+
Code128Encoder("WDBCA45D2HA327260").save("code128.png")
104+
104105
EPS output
105-
----------
106+
~~~~~~~~~~
106107

107108
For embedding in LaTeX (``\includegraphics``) or other vector print
108109
workflows, use :meth:`~Code128Encoder.save_eps` (or
109110
:meth:`~Code128Encoder.get_eps` to receive the EPS as a string).
110111

111112
.. code-block:: python
112113
113-
Code128Encoder("PyStrich-2026").save_eps("code128.eps")
114+
Code128Encoder("WDBCA45D2HA327260").save_eps("code128.eps")
114115
115116
The ``bar_width`` argument is the width of the narrowest bar in PostScript
116117
points (1 point = 1/72 inch). The 10-module quiet zones are applied

docs/code39.rst

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Code 39 is a 1D symbology widely used for industrial labelling. The default
55
character set is uppercase letters, digits, space and ``-.$/+%``; pass
66
``full_ascii=True`` to encode any 7-bit character as a pair of symbols.
77

8+
.. code-block:: python
9+
10+
Code39Encoder("17 E North 32 St", full_ascii=True).save("code39-address.png")
11+
812
.. seealso::
913

1014
`Code 39 on Wikipedia <https://en.wikipedia.org/wiki/Code_39>`_ for
@@ -17,35 +21,19 @@ Example
1721
1822
from pystrich.code39 import Code39Encoder
1923
20-
encoder = Code39Encoder("PART-1234")
21-
encoder.save("code39-example.png")
24+
encoder = Code39Encoder("64755")
25+
encoder.save_svg("code39-example.svg")
2226
23-
.. image:: examples/code39-example.png
24-
:alt: Code 39 barcode encoding "PART-1234".
27+
.. image:: examples/code39-example.svg
28+
:alt: Code 39 barcode encoding "64755".
2529

26-
Sizing
27-
------
30+
Sizing, label, font and layout
31+
------------------------------
2832

2933
The ``bar_width`` argument to :meth:`~Code39Encoder.save` and
3034
:meth:`~Code39Encoder.get_imagedata` sets the pixel width of the narrowest
3135
bar (default ``3``).
3236

33-
.. code-block:: python
34-
35-
encoder = Code39Encoder("PART-1234")
36-
encoder.save("code39-wide.png", bar_width=6)
37-
38-
.. image:: examples/code39-wide.png
39-
:alt: Code 39 barcode encoding "PART-1234" rendered with bar_width=6.
40-
41-
.. seealso::
42-
43-
:doc:`printing` for guidance on selecting ``bar_width`` for printed
44-
output.
45-
46-
Label, font and layout
47-
----------------------
48-
4937
The ``options`` dict passed to :class:`Code39Encoder` controls the
5038
human-readable label and the surrounding layout. All keys are optional.
5139

@@ -64,6 +52,11 @@ human-readable label and the surrounding layout. All keys are optional.
6452
``bottom_border``
6553
Pixels of vertical space between the label and the bottom edge.
6654

55+
.. seealso::
56+
57+
:doc:`printing` for guidance on selecting ``bar_width`` for printed
58+
output.
59+
6760
.. code-block:: python
6861
6962
options = {
@@ -73,42 +66,55 @@ human-readable label and the surrounding layout. All keys are optional.
7366
"ttf_fontsize": 24,
7467
# "ttf_font": "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
7568
}
76-
encoder = Code39Encoder("PART-1234", options=options)
69+
encoder = Code39Encoder("64755", options=options)
7770
encoder.save("code39-custom.png", bar_width=4)
7871
7972
.. image:: examples/code39-custom.png
80-
:alt: Code 39 barcode encoding "PART-1234" with a taller image and larger label.
73+
:alt: Code 39 barcode encoding "64755" with a taller image and larger label.
74+
75+
Output formats
76+
--------------
8177

8278
SVG output
83-
----------
79+
~~~~~~~~~~
8480

8581
For embedding in web pages or any workflow that benefits from
8682
resolution-independent output, use :meth:`~Code39Encoder.save_svg` (or
8783
:meth:`~Code39Encoder.get_svg` to receive the SVG as a string).
8884

8985
.. code-block:: python
9086
91-
Code39Encoder("PART-1234").save_svg("code39.svg")
87+
Code39Encoder("64755").save_svg("code39.svg")
9288
9389
.. image:: examples/code39-example.svg
94-
:alt: SVG Code 39 barcode encoding "PART-1234".
90+
:alt: SVG Code 39 barcode encoding "64755".
9591

9692
The SVG's ``viewBox`` is in module units (one narrow bar = one unit), while
9793
``width`` and ``height`` scale by ``bar_width``. The 10-module quiet zones
9894
mandated by the standard are applied automatically on each side.
9995

10096
.. versionadded:: 0.12
10197

98+
PNG output
99+
~~~~~~~~~~
100+
101+
For raster output, use :meth:`~Code39Encoder.save` to write a PNG file or
102+
:meth:`~Code39Encoder.get_imagedata` to receive the raw PNG bytes.
103+
104+
.. code-block:: python
105+
106+
Code39Encoder("64755").save("code39.png")
107+
102108
EPS output
103-
----------
109+
~~~~~~~~~~
104110

105111
For embedding in LaTeX (``\includegraphics``) or other vector print
106112
workflows, use :meth:`~Code39Encoder.save_eps` (or
107113
:meth:`~Code39Encoder.get_eps` to receive the EPS as a string).
108114

109115
.. code-block:: python
110116
111-
Code39Encoder("PART-1234").save_eps("code39.eps")
117+
Code39Encoder("64755").save_eps("code39.eps")
112118
113119
The ``bar_width`` argument is the width of the narrowest bar in PostScript
114120
points (1 point = 1/72 inch). The 10-module quiet zones are applied

0 commit comments

Comments
 (0)