Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions build_support/catalog/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,3 +821,27 @@ def test_empty_catalog_produces_valid_am(self, tmp_path):
update.update_makefile(catalog_dir=tmp_path, am_path=am)
content = am.read_text()
assert content.startswith("CATALOG_FILES =")


@pytest.mark.catalog_update
class TestWarnMissingDescriptions:
"""Tests for ``_warn_missing_descriptions(df)``.

The function prints to stderr for each game in a supported format that has
an empty description. Tests use ``capsys`` to capture stderr output.
"""

def test_game_without_description_warns(self, capsys):
"""A game with an empty description produces a WARNING on stderr."""
df = _make_df(_efg_row("journals/nobody2025/fig1", description=""))
update._warn_missing_descriptions(df)
err = capsys.readouterr().err
assert "WARNING" in err
assert "journals/nobody2025/fig1" in err

def test_game_with_description_does_not_warn(self, capsys):
"""A game with a non-empty description produces no output."""
df = _make_df(_efg_row("journals/nobody2025/fig1"))
update._warn_missing_descriptions(df)
err = capsys.readouterr().err
assert err == ""
19 changes: 19 additions & 0 deletions build_support/catalog/update.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import shutil
import sys
from pathlib import Path

import pandas as pd
Expand Down Expand Up @@ -93,6 +94,23 @@ def _node_label(prefix: str, labels: dict[str, str]) -> str:
return Path(prefix).name.replace("_", " ").title()


def _warn_missing_descriptions(df: pd.DataFrame) -> None:
"""Print a warning to stderr for each game that lacks a description.

Games without descriptions are silently excluded from the catalog page by
``_build_slug_tree``. This function makes that visible so contributors
know to add a description before the game will appear.
"""
for _, row in df.iterrows():
if str(row.get("Description", "")).strip():
continue
print(
f"WARNING: '{row['Game']}' has no description and will not appear in the catalog.\n"
f"Add a description to the game file to include it.",
file=sys.stderr,
)


def _build_slug_tree(df: pd.DataFrame) -> dict:
"""Build a nested dict tree from the slugs in *df*.

Expand Down Expand Up @@ -392,6 +410,7 @@ def update_makefile(

# Create RST list-table used by doc/catalog.rst
df = gbt.catalog.games(include_descriptions=True)
_warn_missing_descriptions(df)
generate_rst_table(df, CATALOG_RST_TABLE, regenerate_images=args.regenerate_images)
print(f"Generated {CATALOG_RST_TABLE} for use in local docs build. DO NOT COMMIT.")
if args.build:
Expand Down
Loading