From ce6ed54f3738fd581cb255dd35ed62d5d03f41e8 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Tue, 25 Oct 2022 08:54:50 +0100 Subject: [PATCH 1/2] Tidy up various class properties documentation Rather than use the Sphinx-influenced '#:' style of comment, switch to the more docstring-a-like approach used in the Google style. --- examples/five_by_five.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/five_by_five.py b/examples/five_by_five.py index 84a50d639..7bd2f200c 100644 --- a/examples/five_by_five.py +++ b/examples/five_by_five.py @@ -24,8 +24,8 @@ from rich.markdown import Markdown class Help(Screen): """The help screen for the application.""" - #: Bindings for the help screen. BINDINGS = [("escape,space,q,question_mark", "pop_screen", "Close")] + """Bindings for the help screen.""" def compose(self) -> ComposeResult: """Compose the game's help. @@ -39,8 +39,8 @@ class Help(Screen): class WinnerMessage(Static): """Widget to tell the user they have won.""" - #: The minimum number of moves you can solve the puzzle in. MIN_MOVES: Final = 14 + """int: The minimum number of moves you can solve the puzzle in.""" @staticmethod def _plural(value: int) -> str: @@ -78,11 +78,11 @@ class GameHeader(Widget): and the count of how many cells are turned on (``#progress``). """ - #: Keep track of how many moves the player has made. moves = reactive(0) + """int: Keep track of how many moves the player has made.""" - #: Keep track of how many cells are filled. filled = reactive(0) + """int: Keep track of how many cells are filled.""" def compose(self) -> ComposeResult: """Compose the game header. @@ -159,10 +159,9 @@ class GameGrid(Widget): class Game(Screen): """Main 5x5 game grid screen.""" - #: The size of the game grid. Clue's in the name really. SIZE = 5 + """The size of the game grid. Clue's in the name really.""" - #: The bindings for the main game grid. BINDINGS = [ Binding("n", "new_game", "New Game"), Binding("question_mark", "push_screen('help')", "Help", key_display="?"), @@ -173,6 +172,7 @@ class Game(Screen): Binding("right,d,l", "navigate(0,1)", "Move Right", False), Binding("space", "move", "Toggle", False), ] + """The bindings for the main game grid.""" @property def filled_cells(self) -> DOMQuery[GameCell]: @@ -308,17 +308,17 @@ class Game(Screen): class FiveByFive(App[None]): """Main 5x5 application class.""" - #: The name of the stylesheet for the app. CSS_PATH = "five_by_five.css" + """The name of the stylesheet for the app.""" - #: The pre-loaded screens for the application. SCREENS = {"help": Help()} + """The pre-loaded screens for the application.""" - #: App-level bindings. BINDINGS = [("ctrl+d", "toggle_dark", "Toggle Dark Mode")] + """App-level bindings.""" - # Set the title TITLE = "5x5 -- A little annoying puzzle" + """The title of the application.""" def on_mount(self) -> None: """Set up the application on startup.""" From 7ebfb1e7140c24b9ebeea45137784f3d182cffb1 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Tue, 25 Oct 2022 08:57:00 +0100 Subject: [PATCH 2/2] Make the game size Final I mean... the clue is in the name of the game, right? --- examples/five_by_five.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/five_by_five.py b/examples/five_by_five.py index 7bd2f200c..20bbea80f 100644 --- a/examples/five_by_five.py +++ b/examples/five_by_five.py @@ -159,7 +159,7 @@ class GameGrid(Widget): class Game(Screen): """Main 5x5 game grid screen.""" - SIZE = 5 + SIZE: Final = 5 """The size of the game grid. Clue's in the name really.""" BINDINGS = [