Skip to content

Commit f05a44a

Browse files
test(docs): require bilingual archive counterparts
1 parent f34d646 commit f05a44a

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

dev/validation/check_docs_contracts.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,24 @@ def validate_links(path: Path, text: str) -> list[str]:
127127
return errors
128128

129129

130+
def validate_archive_counterpart(path: Path) -> list[str]:
131+
"""Require every maintained EN/CN archive to have its bilingual peer."""
132+
if path.suffix.lower() != ".markdown":
133+
return []
134+
rel = path.relative_to(ROOT)
135+
parts = rel.parts
136+
if len(parts) < 3 or parts[0] != "docs" or parts[1] not in {"en", "cn"}:
137+
return []
138+
other_language = "cn" if parts[1] == "en" else "en"
139+
counterpart = ROOT / "docs" / other_language / Path(*parts[2:])
140+
if counterpart.is_file():
141+
return []
142+
return [
143+
f"{rel.as_posix()}: missing bilingual archive counterpart "
144+
f"{counterpart.relative_to(ROOT).as_posix()}"
145+
]
146+
147+
130148
def is_historical(rel: str) -> bool:
131149
normalized = f"/{rel.lower()}"
132150
return any(part in normalized for part in HISTORICAL_PARTS)
@@ -181,6 +199,7 @@ def main() -> int:
181199
for path in files:
182200
text = path.read_text(encoding="utf-8")
183201
errors.extend(validate_links(path, text))
202+
errors.extend(validate_archive_counterpart(path))
184203
errors.extend(validate_content(path, text))
185204
errors.extend(validate_python_fences(path, text))
186205

0 commit comments

Comments
 (0)