Skip to content

Commit a71adcd

Browse files
authored
Merge pull request #144 from lesamouraipourpre/docs
Add BaseLabel to the online documentation
2 parents 1f3dc11 + d97bb8c commit a71adcd

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

adafruit_display_text/__init__.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33
# SPDX-License-Identifier: MIT
44

55
"""
6-
Display Text module helper functions
6+
`adafruit_display_text`
7+
=======================
78
"""
9+
810
try:
9-
from typing import Tuple
11+
from typing import List, Tuple
1012
except ImportError:
1113
pass
1214
from displayio import Group, Palette
1315

1416

1517
def wrap_text_to_pixels(
1618
string: str, max_width: int, font=None, indent0: str = "", indent1: str = ""
17-
) -> None:
19+
) -> List[str]:
1820
"""wrap_text_to_pixels function
1921
A helper that will return a list of lines with word-break wrapping.
2022
Leading and trailing whitespace in your string will be removed. If
21-
you wish to use leading whitespace see `indend0` and `indent1`
23+
you wish to use leading whitespace see ``indent0`` and ``indent1``
2224
parameters.
2325
2426
:param str string: The text to be wrapped.
@@ -27,9 +29,9 @@ def wrap_text_to_pixels(
2729
:param str indent0: Additional character(s) to add to the first line.
2830
:param str indent1: Additional character(s) to add to all other lines.
2931
30-
31-
:return list lines: A list of the lines resulting from wrapping the
32-
input text at max_width pixels size
32+
:return: A list of the lines resulting from wrapping the
33+
input text at ``max_width`` pixels size
34+
:rtype: List[str]
3335
3436
"""
3537
# pylint: disable=too-many-locals, too-many-branches
@@ -100,16 +102,16 @@ def measure(string):
100102
return lines
101103

102104

103-
def wrap_text_to_lines(string, max_chars):
105+
def wrap_text_to_lines(string: str, max_chars: int) -> List[str]:
104106
"""wrap_text_to_lines function
105107
A helper that will return a list of lines with word-break wrapping
106108
107109
:param str string: The text to be wrapped
108110
:param int max_chars: The maximum number of characters on a line before wrapping
109111
110-
:return list the_lines: A list of lines where each line is separated based on the amount
111-
of max_chars provided
112-
112+
:return: A list of lines where each line is separated based on the amount
113+
of ``max_chars`` provided
114+
:rtype: List[str]
113115
"""
114116

115117
def chunks(lst, n):
@@ -151,21 +153,23 @@ def chunks(lst, n):
151153

152154

153155
class LabelBase(Group):
154-
"""Super class that all other types of labels will extend. This contains
156+
"""Superclass that all other types of labels will extend. This contains
155157
all of the properties and functions that work the same way in all labels.
156158
157-
subclasses should implement _set_text, _set_font, and _set_line_spacing to
158-
have the correct behavior fo rthat type of label.
159+
**Note:** This should be treated as an abstract base class.
160+
161+
Subclasses should implement ``_set_text``, ``_set_font``, and ``_set_line_spacing`` to
162+
have the correct behavior for that type of label.
159163
160164
:param Font font: A font class that has ``get_bounding_box`` and ``get_glyph``.
161165
Must include a capital M for measuring character size.
162166
:param str text: Text to display
163167
:param int max_glyphs: Unnecessary parameter (provided only for direct compability
164-
with label.py)
168+
with :py:func:`~adafruit_display_text.label.Label`)
165169
:param int color: Color of all text in RGB hex
166170
:param int background_color: Color of the background, use `None` for transparent
167-
:param double line_spacing: Line spacing of text to display
168-
:param boolean background_tight: Set `True` only if you want background box to tightly
171+
:param float line_spacing: Line spacing of text to display
172+
:param bool background_tight: Set `True` only if you want background box to tightly
169173
surround text. When set to 'True' Padding parameters will be ignored.
170174
:param int padding_top: Additional pixels added to background bounding box at top
171175
:param int padding_bottom: Additional pixels added to background bounding box at bottom

adafruit_display_text/bitmap_label.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: MIT
44

55
"""
6-
`bitmap_label`
6+
`adafruit_display_text.bitmap_label`
77
================================================================================
88
99
Text graphics handling for CircuitPython, including text boxes

docs/api.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
55
.. use this format as the module name: "adafruit_foo.foo"
66
7+
8+
.. automodule:: adafruit_display_text
9+
:members:
10+
711
.. automodule:: adafruit_display_text.label
812
:members:
913

0 commit comments

Comments
 (0)