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

Show on the map →

Called by none

Calls none

Checks

  • assert "xref_missing" not in err, err
  • assert 'href="guard.html#files-the-gate-skips"' in (html / "index.html").read_text(encoding="utf-8" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-011measured
REQ-DDB-WIKI-022measured
REQ-DDB-WIKI-025measured
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

Activity · 10 steps
lines 57–57from clew.wiki.build import _renderlines 58–58from clew.wiki.config import WikiConfiglines 60–60source, html = tmp_path / "src", tmp_path / "out" / "html"lines 61–61source.mkdir()lines 62–66(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", )lines 67–69(source / "guard.md").write_text( "# Guard\n\n## Files the gate skips\n\nText.\n", encoding="utf-8" )lines 70–70_render(source, html, WikiConfig(), tmp_path)lines 71–71err = capfd.readouterr().errlines 72–72assert "xref_missing" not in err, errlines 73–75assert 'href="guard.html#files-the-gate-skips"' in (html / "index.html").read_text( encoding="utf-8" )