Inherit hardcore template metadata
This commit is contained in:
@@ -250,6 +250,19 @@ def _template_axis_errors(path: str, node: dict[str, Any]) -> list[tuple[str, st
|
||||
return errors
|
||||
|
||||
|
||||
def _container_template_metadata_errors(path: str, node: dict[str, Any]) -> list[tuple[str, str]]:
|
||||
if "item_template_metadata" not in node:
|
||||
return []
|
||||
metadata = node.get("item_template_metadata")
|
||||
if not isinstance(metadata, dict):
|
||||
return [(f"{path}.item_template_metadata", "item_template_metadata must be an object")]
|
||||
normalized = template_metadata_policy.template_metadata(metadata)
|
||||
return [
|
||||
(f"{path}.item_template_metadata", issue)
|
||||
for issue in template_metadata_policy.template_metadata_errors(normalized)
|
||||
]
|
||||
|
||||
|
||||
def _walk_json_references(
|
||||
value: Any,
|
||||
*,
|
||||
@@ -261,6 +274,10 @@ def _walk_json_references(
|
||||
) -> None:
|
||||
if isinstance(value, dict):
|
||||
errors.extend((file_name, item_path, issue) for item_path, issue in _template_axis_errors(path, value))
|
||||
errors.extend(
|
||||
(file_name, item_path, issue)
|
||||
for item_path, issue in _container_template_metadata_errors(path, value)
|
||||
)
|
||||
for key, child in value.items():
|
||||
if at_root and key in POOL_DEFINITION_KEYS and isinstance(child, dict):
|
||||
for pool_name, pool_values in child.items():
|
||||
@@ -318,6 +335,30 @@ def _json_reference_errors(paths: list[Path]) -> list[tuple[str, str, str]]:
|
||||
return errors
|
||||
|
||||
|
||||
def _hardcore_template_metadata_errors(paths: list[Path]) -> list[tuple[str, str, str]]:
|
||||
errors: list[tuple[str, str, str]] = []
|
||||
for path in paths:
|
||||
data = _load_category_json(path)
|
||||
for category in data.get("categories") or []:
|
||||
if str(category.get("slug") or "") != "hardcore_sexual_poses":
|
||||
continue
|
||||
for subcategory in category.get("subcategories") or []:
|
||||
templates = subcategory.get("item_templates")
|
||||
if not isinstance(templates, list) or not templates:
|
||||
continue
|
||||
sub_path = f"categories.{category.get('slug')}.subcategories.{subcategory.get('slug')}"
|
||||
metadata = subcategory.get("item_template_metadata")
|
||||
if not isinstance(metadata, dict):
|
||||
errors.append((path.name, sub_path, "missing item_template_metadata default block"))
|
||||
continue
|
||||
normalized = template_metadata_policy.template_metadata(metadata)
|
||||
if not template_metadata_policy.template_action_family(normalized):
|
||||
errors.append((path.name, f"{sub_path}.item_template_metadata", "missing normalized action_family"))
|
||||
if not template_metadata_policy.template_position_family(normalized):
|
||||
errors.append((path.name, f"{sub_path}.item_template_metadata", "missing normalized position_family"))
|
||||
return errors
|
||||
|
||||
|
||||
def _smoke_case_names(path: Path) -> set[str]:
|
||||
if not path.exists():
|
||||
return set()
|
||||
@@ -445,6 +486,13 @@ def main() -> int:
|
||||
return 1
|
||||
print("OK: all JSON pool references and item template axes resolve.")
|
||||
|
||||
print("\n# Hardcore Template Metadata Validation")
|
||||
hardcore_metadata_errors = _hardcore_template_metadata_errors(category_paths)
|
||||
if hardcore_metadata_errors:
|
||||
print_table(("File", "Path", "Issue"), hardcore_metadata_errors)
|
||||
return 1
|
||||
print("OK: hardcore template subcategories define explicit route metadata defaults.")
|
||||
|
||||
print("\n# Routing Documentation Validation")
|
||||
routing_doc_errors = _routing_doc_errors()
|
||||
if routing_doc_errors:
|
||||
|
||||
Reference in New Issue
Block a user