Merge pull request #1158 from davep/docstring-tidying

Assorted docstring tweaks
This commit is contained in:
Will McGugan
2022-11-11 18:08:03 +00:00
committed by GitHub
5 changed files with 45 additions and 28 deletions

View File

@@ -587,7 +587,7 @@ class App(Generic[ReturnType], DOMNode):
Args:
filename (str | None, optional): Filename of screenshot, or None to auto-generate. Defaults to None.
path (str, optional): Path to directory. Defaults to "~/".
path (str, optional): Path to directory. Defaults to current working directory.
"""
self.save_screenshot(filename, path)

View File

@@ -21,11 +21,7 @@ class Pilot:
@property
def app(self) -> App:
"""Get a reference to the application.
Returns:
App: The App instance.
"""
"""App: A reference to the application."""
return self._app
async def press(self, *keys: str) -> None:

View File

@@ -171,9 +171,9 @@ class Button(Static, can_focus=True):
label (str): The text that appears within the button.
disabled (bool): Whether the button is disabled or not.
variant (ButtonVariant): The variant of the button.
name: The name of the button.
id: The ID of the button in the DOM.
classes: The CSS classes of the button.
name (str | None, optional): The name of the button.
id (str | None, optional): The ID of the button in the DOM.
classes (str | None, optional): The CSS classes of the button.
"""
super().__init__(name=name, id=id, classes=classes)
@@ -269,9 +269,9 @@ class Button(Static, can_focus=True):
Args:
label (str): The text that appears within the button.
disabled (bool): Whether the button is disabled or not.
name: The name of the button.
id: The ID of the button in the DOM.
classes: The CSS classes of the button.
name (str | None, optional): The name of the button.
id (str | None, optional): The ID of the button in the DOM.
classes(str | None, optional): The CSS classes of the button.
Returns:
Button: A Button widget of the 'success' variant.
@@ -300,9 +300,9 @@ class Button(Static, can_focus=True):
Args:
label (str): The text that appears within the button.
disabled (bool): Whether the button is disabled or not.
name: The name of the button.
id: The ID of the button in the DOM.
classes: The CSS classes of the button.
name (str | None, optional): The name of the button.
id (str | None, optional): The ID of the button in the DOM.
classes (str | None, optional): The CSS classes of the button.
Returns:
Button: A Button widget of the 'warning' variant.
@@ -331,9 +331,9 @@ class Button(Static, can_focus=True):
Args:
label (str): The text that appears within the button.
disabled (bool): Whether the button is disabled or not.
name: The name of the button.
id: The ID of the button in the DOM.
classes: The CSS classes of the button.
name (str | None, optional): The name of the button.
id (str | None, optional): The ID of the button in the DOM.
classes (str | None, optional): The CSS classes of the button.
Returns:
Button: A Button widget of the 'error' variant.

View File

@@ -15,10 +15,6 @@ from ..scrollbar import ScrollBarRender
class Checkbox(Widget, can_focus=True):
"""A checkbox widget. Represents a boolean value. Can be toggled by clicking
on it or by pressing the enter key or space bar while it has focus.
Args:
value (bool, optional): The initial value of the checkbox. Defaults to False.
animate (bool, optional): True if the checkbox should animate when toggled. Defaults to True.
"""
DEFAULT_CSS = """
@@ -66,13 +62,22 @@ class Checkbox(Widget, can_focus=True):
def __init__(
self,
value: bool = None,
value: bool = False,
*,
animate: bool = True,
name: str | None = None,
id: str | None = None,
classes: str | None = None,
):
"""Initialise the checkbox.
Args:
value (bool, optional): The initial value of the checkbox. Defaults to False.
animate (bool, optional): True if the checkbox should animate when toggled. Defaults to True.
name (str | None, optional): The name of the checkbox.
id (str | None, optional): The ID of the checkbox in the DOM.
classes (str | None, optional): The CSS classes of the checkbox.
"""
super().__init__(name=name, id=id, classes=classes)
if value:
self.slider_pos = 1.0

View File

@@ -56,7 +56,7 @@ class Column:
@property
def render_width(self) -> int:
"""Width in cells, required to render a column."""
"""int: Width in cells, required to render a column."""
# +2 is to account for space padding either side of the cell
if self.auto_width:
return self.content_width + 2
@@ -88,22 +88,38 @@ class Coord(NamedTuple):
column: int
def left(self) -> Coord:
"""Get coordinate to the left."""
"""Get coordinate to the left.
Returns:
Coord: The coordinate.
"""
row, column = self
return Coord(row, column - 1)
def right(self) -> Coord:
"""Get coordinate to the right."""
"""Get coordinate to the right.
Returns:
Coord: The coordinate.
"""
row, column = self
return Coord(row, column + 1)
def up(self) -> Coord:
"""Get coordinate above."""
"""Get coordinate above.
Returns:
Coord: The coordinate.
"""
row, column = self
return Coord(row - 1, column)
def down(self) -> Coord:
"""Get coordinate below."""
"""Get coordinate below.
Returns:
Coord: The coordinate.
"""
row, column = self
return Coord(row + 1, column)