File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ def _extract_metadata_from_game(cls, game: Game) -> None:
4343 if cls .__doc__ :
4444 cls .description = inspect .cleandoc (cls .__doc__ )
4545 else :
46- cls .description = game .comment
46+ cls .description = game .description
4747
4848 def __init_subclass__ (cls , ** kwargs ):
4949 """Extract metadata when subclass is defined (if not a file-based game)."""
Original file line number Diff line number Diff line change @@ -661,16 +661,16 @@ class Game:
661661 self.game.deref().SetTitle(value.encode("ascii"))
662662
663663 @property
664- def comment (self ) -> str:
665- """Get or set the comment of the game.
664+ def description (self ) -> str:
665+ """Get or set the description of the game.
666666
667- A game's comment is an arbitrary string , and may be more discursive
667+ A game's description/ comment is an arbitrary string , and may be more discursive
668668 than a title.
669669 """
670670 return self.game.deref().GetComment().decode("ascii")
671671
672- @comment .setter
673- def comment (self , value: str ) -> None:
672+ @description .setter
673+ def description (self , value: str ) -> None:
674674 self.game.deref().SetComment(value.encode("ascii"))
675675
676676 @property
Original file line number Diff line number Diff line change 55
66
77class ExampleGame (CatalogGame ):
8- """
9- Test game description.
10- """
118
129 game_type = "efg"
1310
1411 @staticmethod
1512 def _game (some_param : bool = False ):
1613 if some_param :
17- return Game .new_tree (
14+ g = Game .new_tree (
1815 players = ["A" , "B" ], title = "Test game T"
1916 )
20- return Game .new_tree (
21- players = ["A" , "B" ], title = "Test game F"
22- )
17+ else :
18+ g = Game .new_tree (
19+ players = ["A" , "B" ], title = "Test game F"
20+ )
21+ g .description = "Test game description."
22+ return g
23+
24+
25+ class ExampleGameWithDocstring (ExampleGame ):
26+ """
27+ Alternative test game description.
28+ """
2329
2430
2531class TestCatalogGame :
@@ -37,6 +43,10 @@ def test_custom_game_subclass_extracts_metadata(self):
3743 assert ExampleGame .title == "Test game F"
3844 assert ExampleGame .description == "Test game description."
3945
46+ def test_can_get_game_description_from_docstring (self ):
47+ """CatalogGame should get description from docstring over game description."""
48+ assert ExampleGameWithDocstring .description == "Alternative test game description."
49+
4050 def test_catalog_py_game_with_parameters (self ):
4151 """
4252 Custom CatalogGame subclass should return Game
You can’t perform that action at this time.
0 commit comments