Skip to content

docs: escape the stray pipes that split contract-table rows, and check their shape - #3424

Closed
bobcatchris wants to merge 1 commit into
ItsNotRexed:mainfrom
bobcatchris:docs/escape-table-pipes
Closed

bobcatchris wants to merge 1 commit into
ItsNotRexed:mainfrom
bobcatchris:docs/escape-table-pipes

Conversation

@bobcatchris

Copy link
Copy Markdown
Contributor

What and why

Eighteen rows of the translator contract table in docs/design.md carry four to thirteen cells against a three-cell header, because a rule that writes a literal pipe leaves it unescaped:

  • the Floating-point class compare row lists the modifier forms as `v`, `-v`, `|v|`, `-|v|`;
  • VOP3 FP modifiers on constants is the worst: 13 separators, from several a | b alternatives;
  • the others are the same shape in smaller doses (5 in Global atomics, 4 in Sub-dword MUBUF loads, and 16 more).

GitHub reads every one of those as a cell separator. A row with more cells than its header renders into columns the header does not have, and the tail of the rule is dropped — so the contract table loses text silently instead of failing, which is the worst way for the page that records every translator rule to break.

The fix is the escape GFM asks for, inside code spans too:

-| … modifier forms (`v`, `-v`, `|v|`, `-|v|`) × 10 class bits …
+| … modifier forms (`v`, `-v`, `\|v\|`, `-\|v\|`) × 10 class bits …

Nothing but backslashes moved: I compared every changed line against main and each one differs only by inserted \ characters (18 lines changed, same file length, same number of lines). No rule text, number or link was touched.

The check, so it stays fixed

tests/test_docs_design_rows.py already runs on the three table pages (design.md, README.md, testing.md) for a different defect — a topic named twice in one table. It now also rejects a row whose cell count differs from its header's:

  • unescaped_pipes(line) counts separators, skipping \ and the character after it, so an escaped pipe does not count;
  • mis_shaped_rows(lines) returns (line, cells, header cells) per bad row, skipping fenced blocks and using the |---| rule as the header shape;
  • test_checker_finds_a_stray_pipe_but_not_an_escaped_one pins the checker itself on a fixture that has one of each, plus a fenced table, so a checker that flags everything fails;
  • test_each_page_has_rows_its_header_can_hold asserts the real pages.

README.md and testing.md are clean today (0 rows); docs/design.md had the 18.

Tested

Overlay on origin/main f847748c, Windows, Python 3.12.0:

  • python -IB tests/test_docs_design_rows.py → 4 tests, OK (2 before).
  • Control: with docs/design.md restored to main and the new test kept → 1 failure, test_each_page_has_rows_its_header_can_hold (page='design.md') — the 18 rows are exactly what it reports.
  • The file still compiles under -W error::SyntaxWarning (a docstring that mentions \| has to spell it \|, which it does), and compileall is clean.

Overlap

One of the 18 rows, `ds_mskor_b32`, `ds_mskor_rtn_b32` (line 321), is also edited by my own #2812. Whichever lands first, the other rebases — the content does not conflict, only the line does.

Checklist

  • No game data, keys or decryption, including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No new rule; this makes the existing rows readable.)

@eyyun

eyyun commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 5109c6b8 on Windows 11 (Python 3.14, CPU only, no game data): pass.

  • python -I tests/test_docs_design_rows.py -> 4/4 OK (verifies both docs/design.md contract-table pipe escaping and the cell-count check)
  • python -m compileall -q make_game.py tools tests -> exit 0

AI-assisted.

…k their shape

A rule that writes a literal pipe (`|v|`, `-|v|`, `(tmp & ~DATA) | DATA2`) has
to write it `\|`, or GitHub reads it as a separator, renders the row into
columns the header does not have and drops the tail of the rule. Twenty rows of
the translator contract table had that shape (four to thirteen cells against a
two-cell header), each losing the end of the row in the rendered page.

Escape them, and pin the shape in tests/test_docs_design_rows.py: a row whose
separators are not all honoured cannot match its header, so the next one fails
the test instead of dropping text from the page silently.

Re-derived on top of today's main, which rewrote most of these rows: every
changed line differs from main only by escapes (verified line by line), and
`test_each_page_has_rows_its_header_can_hold` fails against main's design.md
and passes here.
@bobcatchris

Copy link
Copy Markdown
Contributor Author

Closing as superseded: main's tests/test_docs_design_rows.py now has both guards this PR introduced (unescaped_pipes() and mis_shaped_rows()), and the escaped rows are on main: python -I tests/test_docs_design_rows.py is 4 tests OK on current main (7b7d73f8).

Nothing here is needed. AI-assisted.

@memorypressure

Copy link
Copy Markdown

Verified on Linux: merges cleanly into current main; the extended checker passes on all three pages (4 tests) and test_design_contract_rows (4) and test_shader_meta (19) are unaffected. The 18 escaped rows are cell-exact — the ds_mskor DATA2 cell and the VOP3 modifier lists now survive GitHub's table parser — and the checker distinguishes escaped from raw pipes and ignores fenced tables. Merged alongside #3422, which also adds a design.md row, the shape check still passes. 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.

3 participants