test_wiki_prose_copy.py¶
tests/test_wiki_prose_copy.py
Prose is copied so Sphinx can link it and resolve what it links (P6 findings, 2.0.0).
test_a_github_style_heading_anchor_resolves
None test_wiki_prose_copy.test_a_github_style_heading_anchor_resolves(Path tmp_path, capfd)
Same-page and cross-document heading anchors resolve.
tests/test_wiki_prose_copy.py:49
Checks
assert "xref_missing" not in err, errassert 'href="guard.html#files-the-gate-skips"' in (html / "index.html").read_text(encoding="utf-8" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-011 | measured | |
| REQ-DDB-WIKI-022 | measured | |
| REQ-DDB-WIKI-025 | measured |
Source · 27 lines
def test_a_github_style_heading_anchor_resolves(tmp_path: Path, capfd) -> None:
"""P6: OVERVIEW's `[Programmatic use](#programmatic-use)` and `GUARD.md#files-the-gate-skips`
work on GitHub but MyST reported "target not found" / "local id not found" (and 7 more on
sassafras-class): MyST makes heading anchors only when told to. A real render, judged by the
warning MyST emits and by the cross-document link landing on the section.
@brief Same-page and cross-document heading anchors resolve.
"""
from clew.wiki.build import _render
from clew.wiki.config import WikiConfig
source, html = tmp_path / "src", tmp_path / "out" / "html"
source.mkdir()
(source / "index.md").write_text(
"# Top\n\n```{toctree}\nguard\n```\n\nSee [use](#programmatic-use) and "
"[skips](guard.md#files-the-gate-skips).\n\n## Programmatic use\n\nText.\n",
encoding="utf-8",
)
(source / "guard.md").write_text(
"# Guard\n\n## Files the gate skips\n\nText.\n", encoding="utf-8"
)
_render(source, html, WikiConfig(), tmp_path)
err = capfd.readouterr().err
assert "xref_missing" not in err, err
assert 'href="guard.html#files-the-gate-skips"' in (html / "index.html").read_text(
encoding="utf-8"
)1 more lines, not shown