33# SPDX-License-Identifier: MIT
44
55"""
6- Display Text module helper functions
6+ `adafruit_display_text`
7+ =======================
78"""
9+
810try :
9- from typing import Tuple
11+ from typing import List , Tuple
1012except ImportError :
1113 pass
1214from displayio import Group , Palette
1315
1416
1517def 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
153155class 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
0 commit comments