Skip to content

test_docs_cli_flags: pair a fence by its length so a four-backtick block keeps its commands - #8127

Open
evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/2-docscli-fence
Open

evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/2-docscli-fence

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

tests/test_docs_cli_flags.py decides where a fenced block starts and ends by toggling on every line that begins with three backticks. A page that quotes a fenced example therefore has to use four backticks, and the inner ``` closes the outer block: the lines after it are treated as prose and the flag check silently stops. Markdown pairs a fence by its length instead (a closing fence is the same character repeated at least as many times, with nothing after it), and fenced_commands() now follows that rule.

Why: this file is a gate. A region it skips is worse than a red result, because nothing reports it. The same toggle is also why a page with one lost fence is counted as 95 "commands" today: it treats prose as code and stops treating real blocks as code. No page uses four-backtick fences yet, so this is a latent skip, not a live one.

Test (Windows 11, CPython 3.12.10, no GPU, no game files):

Same inputs through the checker at main dde82f27e and in the branch (git show HEAD:tests/test_docs_cli_flags.py loaded beside the working-tree module), page = a four-backtick block quoting python -I tools/x.py --old:

  • before: commands: [] mismatches: [] - the command inside the block is neither returned nor checked
  • after: commands: ['```', 'python -I tools/x.py --old', '```'] mismatches: [('docs/a.md:3', 'tools/x.py', '--old')]
python -I tests/test_docs_cli_flags.py
  • with HEAD~2's test file (before this branch): Ran 4 tests / FAILED (failures=1)
  • on this branch: Ran 5 tests / FAILED (failures=1) - the new test_a_longer_fence_keeps_the_commands_it_quotes passes, and the one failure is unchanged: test_docs_name_existing_flags reporting the spirv-opt pass flags cited in docs/embedded_shaders.md (that is test_docs_cli_flags: allow spirv-opt pass flags cited in docs/embedded_shaders.md #7476's, present before and after).

Whole-docs comparison of fenced_commands() over every tracked page, before and after: 1698 -> 1652 fenced "commands", and the tool_flag_mismatches() list is identical ([]). All of the difference is runtime/README.md, whose lost fence (#7217) makes the toggle count prose as code; with that fence restored, both pairings return the same 48 commands, so no real command is lost.

Notes

EGEN-DOCSCLI-FENCE-LENGTH

AI-assisted.

…ps its commands

fenced_commands() toggled on every line starting with three backticks, so a four-backtick block that quotes a `example` closed at the inner fence: the rest of the block fell outside the check and a command with a wrong flag passed. Markdown closes a fence only with the same character repeated at least as many times and nothing else; pair it that way.
Without the length rule the block yields no command at all, so the test fails with empty lists; it also pins a bare fence, a longer closer than its opener, and an unclosed fence, so a later pairing change cannot quietly start skipping commands again.
@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested b46434fb on Windows 11 (Python 3.14.7, CPU-only, no game files): pass.

Test Suite Execution

Negative Control

  • Tested synthetic 4-backtick block quoting an inner 3-backtick command (page = "````\n```\npython -I tools/x.py --old\n```\n````\n"):
    • On origin/main (dde82f27e): fenced_commands(page) evaluates to [] because naive boolean toggling on line.lstrip().startswith("```") prematurely treats the inner block as an exit fence, dropping the command and its flag check.
    • On this branch (b46434fb): fenced_commands(page) pairs fences by backtick length (ticks >= fence and not content[ticks:].strip()), returning ['```', 'python -I tools/x.py --old', '```'] and catching the --old mismatch as expected.

Hygiene

  • python -m compileall -q tests/test_docs_cli_flags.py: clean.
  • python -I scripts/check_no_game_data.py tests/test_docs_cli_flags.py: clean.
  • git diff --check origin/main: clean.
  • Line endings: strict LF preserved.

AI-assisted review.

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.

2 participants