Skip to content

Commit

Permalink
Merge pull request #3191 from Textualize/assorted-docs-and-tidying
Browse files Browse the repository at this point in the history
Various docstring fixes, removing unused variables
  • Loading branch information
willmcgugan authored Nov 7, 2023
2 parents 238cf7b + cb211d5 commit 9f620dc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
8 changes: 4 additions & 4 deletions rich/containers.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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".
Expand Down
3 changes: 3 additions & 0 deletions rich/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 13 additions & 9 deletions rich/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -634,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.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
"""
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9f620dc

Please sign in to comment.