From b44fd1b337cf3336c68e1127d3f92f0cfefb3b0f Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 7 Nov 2023 11:23:28 +0000 Subject: [PATCH 1/3] Various docstring fixes, removing unused variables --- rich/markup.py | 3 +++ rich/text.py | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/rich/markup.py b/rich/markup.py index cb927edd1..bd9c05a71 100644 --- a/rich/markup.py +++ b/rich/markup.py @@ -113,7 +113,10 @@ def render( Args: markup (str): A string containing console markup. + style: (Union[str, Style]): The style to use. emoji (bool, optional): Also render emoji code. Defaults to True. + emoji_variant (str, optional): Optional emoji variant, either "text" or "emoji". Defaults to None. + Raises: MarkupError: If there is a syntax error in the markup. diff --git a/rich/text.py b/rich/text.py index 90b1cb14b..b9b35055d 100644 --- a/rich/text.py +++ b/rich/text.py @@ -271,7 +271,9 @@ def from_markup( Args: text (str): A string containing console markup. + style (Union[str, Style], optional): Base style for text. Defaults to "". emoji (bool, optional): Also render emoji code. Defaults to True. + emoji_variant (str, optional): Optional emoji variant, either "text" or "emoji". Defaults to None. justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. end (str, optional): Character to end text with. Defaults to "\\\\n". @@ -369,6 +371,7 @@ def assemble( style (Union[str, Style], optional): Base style for text. Defaults to "". justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. + no_wrap (bool, optional): Disable text wrapping, or None for default. Defaults to None. end (str, optional): Character to end text with. Defaults to "\\\\n". tab_size (int): Number of spaces per tab, or ``None`` to use ``console.tab_size``. Defaults to None. meta (Dict[str, Any], optional). Meta data to apply to text, or None for no meta data. Default to None @@ -424,7 +427,7 @@ def spans(self, spans: List[Span]) -> None: self._spans = spans[:] def blank_copy(self, plain: str = "") -> "Text": - """Return a new Text instance with copied meta data (but not the string or spans).""" + """Return a new Text instance with copied metadata (but not the string or spans).""" copy_self = Text( plain, style=self.style, @@ -505,7 +508,7 @@ def stylize_before( def apply_meta( self, meta: Dict[str, Any], start: int = 0, end: Optional[int] = None ) -> None: - """Apply meta data to the text, or a portion of the text. + """Apply metadata to the text, or a portion of the text. Args: meta (Dict[str, Any]): A dict of meta information. @@ -823,8 +826,6 @@ def expand_tabs(self, tab_size: Optional[int] = None) -> None: if tab_size is None: tab_size = 8 - result = self.blank_copy() - new_text: List[Text] = [] append = new_text.append @@ -899,6 +900,7 @@ def pad(self, count: int, character: str = " ") -> None: Args: count (int): Width of padding. + character (str): The character to pad with. Must be a string of length 1. """ assert len(character) == 1, "Character must be a string of length 1" if count: @@ -1005,6 +1007,9 @@ def append_text(self, text: "Text") -> "Text": """Append another Text instance. This method is more performant that Text.append, but only works for Text. + Args: + text (Text): The Text instance to append to this instance. + Returns: Text: Returns self for chaining. """ @@ -1026,7 +1031,7 @@ def append_tokens( """Append iterable of str and style. Style may be a Style instance or a str style definition. Args: - pairs (Iterable[Tuple[str, Optional[StyleType]]]): An iterable of tuples containing str content and style. + tokens (Iterable[Tuple[str, Optional[StyleType]]]): An iterable of tuples containing str content and style. Returns: Text: Returns self for chaining. @@ -1204,8 +1209,7 @@ def wrap( Args: console (Console): Console instance. - width (int): Number of characters per line. - emoji (bool, optional): Also render emoji code. Defaults to True. + width (int): Number of cells available per line. justify (str, optional): Justify method: "default", "left", "center", "full", "right". Defaults to "default". overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to None. tab_size (int, optional): Default tab size. Defaults to 8. From 6fd3734f12f6fabc3ac85d4fdcf194077ff9fa37 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 7 Nov 2023 11:27:56 +0000 Subject: [PATCH 2/3] Improve wording in a docstring --- rich/containers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rich/containers.py b/rich/containers.py index e29cf3689..901ff8ba6 100644 --- a/rich/containers.py +++ b/rich/containers.py @@ -1,13 +1,13 @@ from itertools import zip_longest from typing import ( - Iterator, + TYPE_CHECKING, Iterable, + Iterator, List, Optional, + TypeVar, Union, overload, - TypeVar, - TYPE_CHECKING, ) if TYPE_CHECKING: @@ -119,7 +119,7 @@ def justify( Args: console (Console): Console instance. - width (int): Number of characters per line. + width (int): Number of cells available per line. justify (str, optional): Default justify method for text: "left", "center", "full" or "right". Defaults to "left". overflow (str, optional): Default overflow for text: "crop", "fold", or "ellipsis". Defaults to "fold". From cb211d5b89e7e80f61cb22f0e4b4dce0ee907d4b Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 7 Nov 2023 13:45:51 +0000 Subject: [PATCH 3/3] Fix docstring typos --- rich/text.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rich/text.py b/rich/text.py index b9b35055d..7091e4291 100644 --- a/rich/text.py +++ b/rich/text.py @@ -637,9 +637,9 @@ def highlight_words( """Highlight words with a style. Args: - words (Iterable[str]): Worlds to highlight. + words (Iterable[str]): Words to highlight. style (Union[str, Style]): Style to apply. - case_sensitive (bool, optional): Enable case sensitive matchings. Defaults to True. + case_sensitive (bool, optional): Enable case sensitive matching. Defaults to True. Returns: int: Number of words highlighted.