Skip to content

Commit d2610d6

Browse files
Add code for adding images for catalog games in the future
1 parent 3475cfb commit d2610d6

2 files changed

Lines changed: 38 additions & 14 deletions

File tree

src/pygambit/catalog.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ def _game() -> gbt.Game:
3838
"""
3939
raise NotImplementedError("Subclasses must implement _game() method")
4040

41-
@classmethod
42-
def _img_docstring(cls) -> str:
43-
"""Return the image docstring for the game."""
44-
# file = f"/_static/catalog_drawn/{cls.__name__}.png"
45-
file = "/_static/gambit.png"
46-
docstring = f"""
47-
.. figure:: {file}
48-
:align: center
49-
:width: 400px
50-
51-
{cls.__name__} game diagram
52-
"""
53-
return docstring
41+
# TODO: Add images for catalog games
42+
# @classmethod
43+
# def _img_docstring(cls) -> str:
44+
# """Return the image docstring for the game."""
45+
# file = f"/_static/catalog_drawn/{cls.__name__}.png"
46+
# docstring = f"""
47+
# .. figure:: {file}
48+
# :align: center
49+
# :width: 400px
50+
51+
# {cls.__name__} game diagram
52+
# """
53+
# return docstring
5454

5555
@classmethod
5656
def _extract_description(cls, game: gbt.Game) -> None:
@@ -63,7 +63,10 @@ def _extract_description(cls, game: gbt.Game) -> None:
6363
cleaned_docstring = game.description
6464
if len(cleaned_docstring) > 0:
6565
cleaned_docstring += "\n"
66-
cleaned_docstring += cls._img_docstring()
66+
67+
# TODO: Add images for catalog games
68+
# cleaned_docstring += cls._img_docstring()
69+
6770
# If the class has a _game function, concatenate its docstring to the class docstring
6871
game_docstring = inspect.getdoc(cls._game)
6972
if game_docstring:

src/pygambit/catalog_update.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,23 @@ def update_makefile():
125125
print(f"Updated {_MAKEFILE_AM}")
126126

127127

128+
# TODO: Add images for catalog games
129+
# def generate_draw_tree_images():
130+
# """Generate tree images for all extensive-form games in the catalog."""
131+
# from draw_tree import generate_png
132+
# for class_name in gbt.catalog.games():
133+
# cls = getattr(gbt.catalog, class_name)
134+
# g = cls()
135+
# if g.is_tree:
136+
# image_path = (
137+
# Path(__file__).parent.parent.parent
138+
# / "doc/_static/catalog_drawn/"
139+
# / f"{class_name}.png"
140+
# )
141+
# generate_png(g, output_png=image_path)
142+
# print(f"Generated tree image for {class_name} at {image_path}")
143+
144+
128145
if __name__ == "__main__":
129146
# Use ruamel.yaml to preserve comments
130147
yaml = YAML()
@@ -179,4 +196,8 @@ def update_makefile():
179196
# Update the Makefile.am with all game files
180197
update_makefile()
181198

199+
# TODO: Add images for catalog games
200+
# Generate EFG game images and add to _static/catalog_drawn/
201+
# generate_draw_tree_images()
202+
182203
print("Done.")

0 commit comments

Comments
 (0)