okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-clean-3 (321794636): docs and history (cleanup step 3, items 3.0-3.10); release manifest and capability table with checks, history/ with pointers, link check, tools/ split, bench index; owner OK'd the wording 11-082b36e8a02

main
2.0 KiB38 linesraw
1"""The local link check (tools/check_links.py) and the pointer files left where material moved to history/."""
2import os
3import sys
4import unittest
5
6sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
7import check_links as cl  # noqa: E402
8import doc_pages  # noqa: E402
9
10
11class LinkCheck(unittest.TestCase):
12    def test_current_pages_have_no_broken_local_links(self):
13        problems = []
14        for page in doc_pages.current_pages():
15            problems += cl.check_page(page, want_anchors=True)
16        self.assertEqual(problems, [], "\n".join("%s:%d %s (%s)" % (p, n, t, w) for p, n, t, w in problems))
17
18    def test_links_in_code_and_comments_are_not_checked(self):
19        text = "[a](real.md) `[b](code.md)`\n```\n[c](fence.md)\n```\n<!-- [d](comment.md) -->\n[e](https://example.com/x.md) [f](#top) [g](other.md#h)\n"
20        self.assertEqual([t for _, t in cl.targets(text)], ["real.md", "https://example.com/x.md", "#top", "other.md#h"])
21
22    def test_a_missing_target_is_reported_and_urls_are_not_local(self):
23        self.assertIsNone(cl.resolve("docs/README.md", "https://github.com/Niko1221/Strata"))
24        self.assertIsNone(cl.resolve("docs/README.md", "mailto:a@b.c"))
25        self.assertTrue(cl.resolve("docs/README.md", "INSTALL.md").endswith(os.path.join("docs", "INSTALL.md")))
26        self.assertTrue(cl.resolve("docs/README.md", "/LICENSE").endswith("LICENSE"))
27
28    def test_every_pointer_resolves_into_history(self):
29        pointers = ["apps/host/audit-fixes/README.md", "docs/work/README.md", "packaging/acceptance_matrix.md",
30                    "apps/host/docs/persona-review-2026-10-05/README.md", "apps/host/docs/plans/README.md", "apps/host/docs/README.md"]
31        for page in pointers:
32            self.assertEqual(cl.check_page(page, want_anchors=True), [], page)
33            text = open(os.path.join(doc_pages.ROOT, page), encoding="utf-8").read()
34            self.assertIn("history", text, page)
35
36
37if __name__ == "__main__":
38    unittest.main()