From 7c0c1362631da968ce7ec9c781ddf626a18b0307 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Tue, 2 Feb 2021 19:20:44 -0500 Subject: [PATCH 1/3] Intial review of documentation --- adafruit_display_text/label.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/adafruit_display_text/label.py b/adafruit_display_text/label.py index 202e969..5f4e398 100755 --- a/adafruit_display_text/label.py +++ b/adafruit_display_text/label.py @@ -39,7 +39,27 @@ class Label(displayio.Group): :param str text: Text to display :param int max_glyphs: The largest quantity of glyphs we will display :param int color: Color of all text in RGB hex - :param double line_spacing: Line spacing of text to display""" + :param float line_spacing: Line spacing of text to display + :param bool background_tight: Set `True` only if you want background box to tightly + surround text. When set to 'True' Padding parameters will be ignored. + :param int padding_top: Additional pixels added to background bounding box at top. + This parameter could be negative indicating additional pixels subtracted to background + bounding box. + :param int padding_bottom: Additional pixels added to background bounding box at bottom. + This parameter could be negative indicating additional pixels subtracted to background + bounding box. + :param int padding_left: Additional pixels added to background bounding box at left. + This parameter could be negative indicating additional pixels subtracted to background + bounding box. + :param int padding_right: Additional pixels added to background bounding box at right. + This parameter could be negative indicating additional pixels subtracted to background + bounding box. + :param (float,float) anchor_point: Point that anchored_position moves relative to. + Tuple with decimal percentage of width and height. + (E.g. (0,0) is top left, (1.0, 0.5): is middle right.) + :param (int,int) anchored_position: Position relative to the anchor_point. Tuple + containing x,y pixel coordinates. + :param int scale: Integer value of the pixel scaling""" # pylint: disable=too-many-instance-attributes, too-many-locals # This has a lot of getters/setters, maybe it needs cleanup. @@ -120,6 +140,9 @@ def __init__( self.anchored_position = anchored_position def _create_background_box(self, lines, y_offset): + """Private Class function to create a background_box + :param lines: int number of lines + :param y_offset: int y pixel bottom coordinate for the background_box""" left = self._boundingbox[0] @@ -156,6 +179,7 @@ def _create_background_box(self, lines, y_offset): return tile_grid def _get_ascent_descent(self): + """ Private function to calculate ascent and descent font values """ if hasattr(self.font, "ascent"): return self.font.ascent, self.font.descent @@ -179,6 +203,8 @@ def _get_ascent(self): return self._get_ascent_descent()[0] def _update_background_color(self, new_color): + """ Private class function that allows updating the font box background color + :param new_color: int color as an RGB hex number.""" if new_color is None: self._background_palette.make_transparent(0) From 5bfae81a1b4fd1920c16be90aac629b42d48a400 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Tue, 2 Feb 2021 21:10:07 -0500 Subject: [PATCH 2/3] Add parameters description in class documentation. pylint and Black checked --- adafruit_display_text/label.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/adafruit_display_text/label.py b/adafruit_display_text/label.py index 5f4e398..22a3b4a 100755 --- a/adafruit_display_text/label.py +++ b/adafruit_display_text/label.py @@ -83,7 +83,7 @@ def __init__( anchor_point=None, anchored_position=None, scale=1, - **kwargs + **kwargs, ): if not max_glyphs and not text: raise RuntimeError("Please provide a max size, or initial text") @@ -94,12 +94,10 @@ def __init__( # instance the Group # self Group will contain a single local_group which contains a Group (self.local_group) # which contains a TileGrid - super().__init__( - max_size=1, scale=1, **kwargs - ) # The self scale should always be 1 - self.local_group = displayio.Group( - max_size=max_glyphs + 1, scale=scale - ) # local_group will set the scale + # The self scale should always be 1 + super().__init__(max_size=1, scale=1, **kwargs) + # local_group will set the scale + self.local_group = displayio.Group(max_size=max_glyphs + 1, scale=scale) self.append(self.local_group) self.width = max_glyphs @@ -203,7 +201,7 @@ def _get_ascent(self): return self._get_ascent_descent()[0] def _update_background_color(self, new_color): - """ Private class function that allows updating the font box background color + """Private class function that allows updating the font box background color :param new_color: int color as an RGB hex number.""" if new_color is None: @@ -230,9 +228,8 @@ def _update_background_color(self, new_color): self._boundingbox[3] + self._padding_top + self._padding_bottom > 0 ) ): - if ( - len(self.local_group) > 0 - ): # This can be simplified in CP v6.0, when group.append(0) bug is corrected + # This can be simplified in CP v6.0, when group.append(0) bug is corrected + if len(self.local_group) > 0: self.local_group.insert( 0, self._create_background_box(lines, y_offset) ) From 6e350578509f836b1f9ab33983fa6354d7337f16 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Tue, 2 Feb 2021 21:13:53 -0500 Subject: [PATCH 3/3] Add parameters description in class documentation. Verified pylint and black --- adafruit_display_text/label.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_display_text/label.py b/adafruit_display_text/label.py index 22a3b4a..486a14f 100755 --- a/adafruit_display_text/label.py +++ b/adafruit_display_text/label.py @@ -83,7 +83,7 @@ def __init__( anchor_point=None, anchored_position=None, scale=1, - **kwargs, + **kwargs ): if not max_glyphs and not text: raise RuntimeError("Please provide a max size, or initial text")