Skip to content

Commit 02740ee

Browse files
Get game description docstring from catalog.yml
1 parent 88e1346 commit 02740ee

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/pygambit/catalog/catalog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ def _generate_contrib_game_classes(catalog: dict[str, dict]) -> None:
204204
class_attrs = {
205205
"game_file": game_file,
206206
"__module__": __name__,
207+
"__doc__": entry.get("description", None),
207208
}
208209

209210
# Add metadata fields as class attributes

src/pygambit/catalog/catalog.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ Pbride:
334334
metadata:
335335
PrisonersDilemma:
336336
file: pd.nfg
337+
description: "A simple implementation of a two person Prisoner's Dilemma game."
337338
metadata:
338339
test_suite: true
339340
Perfect1:

tests/test_catalog.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ def test_catalog_yml_game_instantiation(self):
5959
"""Custom CatalogGame subclasses reading from catalog.yml should return Game instances."""
6060
assert isinstance(PrisonersDilemma(), Game)
6161

62+
def test_catalog_yml_game_description(self):
63+
"""Custom CatalogGame subclasses reading from catalog.yml should return Game instances."""
64+
assert (
65+
PrisonersDilemma.description
66+
== "A simple implementation of a two person Prisoner's Dilemma game."
67+
)
68+
6269

6370
class TestGamesFunction:
6471
"""Tests for the games() query function."""

0 commit comments

Comments
 (0)