From 92791ff73be75aa94bfc8cee1678bb72efd79c1e Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Tue, 27 Oct 2026 22:52:01 -0600 Subject: [PATCH] Name broken-link docs by repo-relative path, not basename Co-Authored-By: Claude Opus 5.5 --- scripts/check_docs.py | 2 +- tests/test_check_docs.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/check_docs.py b/scripts/check_docs.py index 70896cb..aa79ac9 100755 --- a/scripts/check_docs.py +++ b/scripts/check_docs.py @@ -109,7 +109,7 @@ def check_local_links() -> None: continue resolved = (doc.parent / path_part).resolve() if not resolved.exists(): - errors.append(f"{doc.name}: broken relative link -> {target}") + errors.append(f"{doc.relative_to(REPO_ROOT).as_posix()}: broken relative link -> {target}") def main() -> int: diff --git a/tests/test_check_docs.py b/tests/test_check_docs.py index b13acc7..a75ca25 100644 --- a/tests/test_check_docs.py +++ b/tests/test_check_docs.py @@ -277,7 +277,18 @@ def test_link_resolves_relative_to_containing_doc(self): (root / "docs" / "SAME.md").write_text("[link](TARGET.md)") check_docs.REPO_ROOT = root check_docs.check_local_links() - self.assertEqual(check_docs.errors, ["SAME.md: broken relative link -> TARGET.md"]) + self.assertEqual(check_docs.errors, ["docs/SAME.md: broken relative link -> TARGET.md"]) + + def test_same_named_docs_are_told_apart_by_path(self): + import tempfile + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) + (root / "scripts").mkdir() + (root / "README.md").write_text("no links here") + (root / "scripts" / "README.md").write_text("[link](MISSING.md)") + check_docs.REPO_ROOT = root + check_docs.check_local_links() + self.assertEqual(check_docs.errors, ["scripts/README.md: broken relative link -> MISSING.md"]) def test_docs_under_dot_git_are_skipped(self): import tempfile