Skip to content

Docs link checker: decode cross-file heading fragments - #7695

Open
Barbital11111 wants to merge 1 commit into
ItsNotRexed:mainfrom
Barbital11111:fix/docs-link-fragment-decoding
Open

Barbital11111 wants to merge 1 commit into
ItsNotRexed:mainfrom
Barbital11111:fix/docs-link-fragment-decoding

Conversation

@Barbital11111

Copy link
Copy Markdown
Contributor

DOCS-LINK-FRAGMENT (claim)

Decode a cross-file fragment before comparing it with the destination's heading slugs, matching same-page fragment handling. The new regression uses a percent-encoded non-ASCII heading and confirms that a genuinely missing anchor is still reported.

Verification

AI-assisted (Codex).

@CourtyardGames

Copy link
Copy Markdown

Verified how 32159ec interacts with #7645 (4479bb3) on Windows with CPython 3.12.13 and 3.14. I three-way merged the checker file and ran its broken_links function against a synthetic guide containing two headings named Café. Two reference definitions targeted the encoded filename and fragments: guide%20notes.md#caf%C3%A9-1 (second heading) and guide%20notes.md#caf%C3%A9-2 (absent third heading).

With both patches, the checker accepted the second-heading link and reported exactly the absent third heading. With #7645 alone it flagged both; with #7695 alone it skipped both reference definitions. Both Python versions gave the same results.

AI-assisted independent integration check.

@azterixx

Copy link
Copy Markdown

checked: #7695 | with: python -I -m unittest discover -s tests -p test_docs_links.py | on: macOS 27.2.1, Apple M1 Pro, CPython 3.15.2, head 32159ec, CPU only | result: the 7 new/changed fragment tests pass; test_every_relative_link_resolves fails, identically on main@dde82f27e, so not from this PR:

  • docs/dev-tools.md: ../runtime/README.md#a-600-frame-headless-guest-scene (anchor not found)
  • docs/gpu_test_results.md: gpu-test-results/RX9070GRE.txt (missing file)

@ray3242

ray3242 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Reproduced two defects at head 32159ec4 (also after merging this head with current main):

  1. python -I tests/test_docs_links.py → test_every_relative_link_resolves fails with docs/gpu_test_results.md: gpu-test-results/RX9070GRE.txt (missing file). The file this PR adds is at the repo root (gpu-test-results/RX9070GRE.txt), but the link is resolved relative to docs/, so it points at docs/gpu-test-results/RX9070GRE.txt, which does not exist. Steps: check out the head, run the test, and compare git ls-files | Select-String RX9070GRE with the link target.

  2. Same test: docs/dev-tools.md: ../runtime/README.md#a-600-frame-headless-guest-scene (anchor not found). The heading ### A 600-frame headless guest scene is present at runtime/README.md:521, but strip_fences() uses FENCE = re.compile(r"```.*?```", re.S); with 1003 backtick markers in that file it mis-pairs them (853 remain in the stripped text) and drops the heading from anchors(). Steps: python -I -c "import sys; sys.path.insert(0,'tests'); import test_docs_links as t; print(t.anchors('runtime/README.md'))" — the anchor is absent from the set.

Base 849d3709 passes 7/7, so both failures are exposed by the links this PR adds. The PR needs to correct the relative path and either make strip_fences line-based or point at an anchor the checker can see.

Windows 11 / CPython 3.12.10, CPU only, no game data. AI-assisted (OpenCode).

@sds-228 sds-228 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at the current head. Cross-file heading fragments are decoded before slug comparison, matching same-page links.

CPU-only verification: the focused encoded-fragment test passes here and fails on the parent; a genuinely missing anchor is still reported. One repository-wide link check is red in my partial checkout on the parent too. No game data.

AI-assisted (OpenCode).

@memorypressure

Copy link
Copy Markdown

Tested 32159ec on main dde82f2, merges clean (tree 1add775a4): test_docs_links Ran 8, 1 failure — test_every_relative_link_resolves, which fails IDENTICALLY on clean main (docs/dev-tools.md → runtime/README.md#a-600-frame-headless-guest-scene): #6691 added that link today and strip_fences' pairing swallows the README heading (odd fence count in runtime/README.md) — main-side, not yours, needs its own fix. Your fix is right and narrow: main already unquotes same-page anchors and file targets but compared cross-file fragments raw; injected into main's file the new test fails (valid #café percent-encoded flagged), merged it passes. Pairwise clean with #7645. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants