tests: handle inline external URLs and CommonMark fences in doc validators #2421

Merged
Andretuta merged 1 commit from upstream-pr/2421 into main 2026-11-28 10:58:06 +00:00
Andretuta commented 2026-11-27 03:17:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-27T03:17:12Z.


Claimed in the coordination issue as: DOC-VALIDATOR-FENCES-AND-URLS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7208856827)

What and why

  • tests/test_docs_repo_paths.py: previously skipped any entire line containing ://, creating a false negative whenever a broken local repo path appeared on the same line as an external link. Mask only inline external Markdown links ([...](scheme://...)) instead.
  • tests/test_docs_repo_paths.py and tests/test_docs_table_ids.py: track CommonMark opening/closing fences (```, ````, ~~~) by marker character and length instead of toggling only on triple backticks, preventing false failures on tilde-fenced or longer-backtick-fenced examples.
  • Add targeted regression tests to both validators.

Tested

  • Verified 6 edge cases fail on unpatched main d1dff7949 and pass with this change.
  • python -I tests/test_docs_repo_paths.py and python -I tests/test_docs_table_ids.py: OK.
  • Full docs validation suite (all tests/test_docs_*.py + tests/test_text_write_line_endings.py + compileall): OK.
  • python -I scripts/check_no_game_data.py: exit 0.

GPUs tested: n/a

AI-assisted: yes (Antigravity gemini-4-neon)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), 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. (n/a — not a translator rule)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5520570915 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2421). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-27T03:17:12Z. --- Claimed in the coordination issue as: DOC-VALIDATOR-FENCES-AND-URLS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7208856827) ### What and why - `tests/test_docs_repo_paths.py`: previously skipped any entire line containing `://`, creating a false negative whenever a broken local repo path appeared on the same line as an external link. Mask only inline external Markdown links (`[...](scheme://...)`) instead. - `tests/test_docs_repo_paths.py` and `tests/test_docs_table_ids.py`: track CommonMark opening/closing fences (` ``` `, ` ```` `, `~~~`) by marker character and length instead of toggling only on triple backticks, preventing false failures on tilde-fenced or longer-backtick-fenced examples. - Add targeted regression tests to both validators. ### Tested - Verified 6 edge cases fail on unpatched `main` `d1dff7949` and pass with this change. - `python -I tests/test_docs_repo_paths.py` and `python -I tests/test_docs_table_ids.py`: OK. - Full docs validation suite (all `tests/test_docs_*.py` + `tests/test_text_write_line_endings.py` + `compileall`): OK. - `python -I scripts/check_no_game_data.py`: exit 0. GPUs tested: n/a AI-assisted: yes (Antigravity gemini-4-neon) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), 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. *(n/a — not a translator rule)*
tiguan26 commented 2026-11-27 05:49:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T05:49:16Z.

Review: APPROVED


Approving. Checked on 43128a9c1, which merges cleanly onto main.

tests/test_docs_repo_paths.py and tests/test_docs_table_ids.py: 8 passed, including the whole-docs checks. That matters here, because the change makes the path check stricter (a URL elsewhere on a line no longer hides the repo paths next to it), and every current page still passes.

Read the diff. The fence tracking follows CommonMark where it matters: a backtick opener's info string may not contain a backtick (so ```inline``` on one line is not a fence), the closer must be the same character, at least as long and followed only by whitespace, and tilde fences and longer backtick fences nest the way the tests show. EXTERNAL_LINK strips only the inline link (angle-bracketed destinations and the three title forms included), so a bare URL in prose no longer hides anything.

Two small things, not blockers. _update_fence and FENCE_OPEN are now copied in both files, so a shared helper module in tests/ would stop them drifting. And lstrip(" \t") accepts a fence at any indentation, while CommonMark makes 4+ spaces an indented code block. That only matters for a fence line inside an indented code block, which the docs don't seem to have.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6084015126 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2421#pullrequestreview-6084015126). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-27T05:49:16Z. **Review:** APPROVED --- Approving. Checked on 43128a9c1, which merges cleanly onto main. `tests/test_docs_repo_paths.py` and `tests/test_docs_table_ids.py`: 8 passed, including the whole-docs checks. That matters here, because the change makes the path check stricter (a URL elsewhere on a line no longer hides the repo paths next to it), and every current page still passes. Read the diff. The fence tracking follows CommonMark where it matters: a backtick opener's info string may not contain a backtick (so ```` ```inline``` ```` on one line is not a fence), the closer must be the same character, at least as long and followed only by whitespace, and tilde fences and longer backtick fences nest the way the tests show. `EXTERNAL_LINK` strips only the inline link (angle-bracketed destinations and the three title forms included), so a bare URL in prose no longer hides anything. Two small things, not blockers. `_update_fence` and `FENCE_OPEN` are now copied in both files, so a shared helper module in `tests/` would stop them drifting. And `lstrip(" \t")` accepts a fence at any indentation, while CommonMark makes 4+ spaces an indented code block. That only matters for a fence line inside an indented code block, which the docs don't seem to have.
zmasi commented 2026-11-28 10:03:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T10:03:37Z.


#2421 | head 43128a9c1b (merged cleanly with main 33db04a70) | python -I tests/test_docs_table_ids.py && python -I tests/test_docs_repo_paths.py -k "not test_docs_name_existing_paths" | red on main: missing_paths skips whole lines containing :// ([] != [('docs/u.md:1', 'tools/gone.py')]) and repeated_ids toggles on inner backticks inside ~~~ fences ([(2, 3, '**M3**')] != []) | green on PR+main: 3 tests OK and 4 tests OK | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited _update_fence and EXTERNAL_LINK in tests/test_docs_repo_paths.py and tests/test_docs_table_ids.py. On PR + main (33db04a70), test_docs_name_existing_paths reports the exact same 14 pre-existing missing-path entries (docs/port_plan.md, docs/port_status.md, docs/ultrawide.md, docs/victory_gap_*.md) as plain main and introduces zero new doc-path failures; note an adjacent hunk overlap in tests/test_docs_repo_paths.py if combined with open #2552. Also passed tests/test_docs_links.py (17 OK), tests/test_text_write_line_endings.py (3 OK), tests/test_runner_calls_all_tests.py (3 OK), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237643826 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2421#issuecomment-7237643826). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T10:03:37Z. --- #2421 | head 43128a9c1b772934fa592c679e7fb369619d7cf6 (merged cleanly with main 33db04a70) | `python -I tests/test_docs_table_ids.py && python -I tests/test_docs_repo_paths.py -k "not test_docs_name_existing_paths"` | red on main: `missing_paths` skips whole lines containing `://` (`[] != [('docs/u.md:1', 'tools/gone.py')]`) and `repeated_ids` toggles on inner backticks inside `~~~` fences (`[(2, 3, '**M3**')] != []`) | green on PR+main: `3 tests OK` and `4 tests OK` | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `_update_fence` and `EXTERNAL_LINK` in `tests/test_docs_repo_paths.py` and `tests/test_docs_table_ids.py`. On `PR + main` (`33db04a70`), `test_docs_name_existing_paths` reports the exact same 14 pre-existing missing-path entries (`docs/port_plan.md`, `docs/port_status.md`, `docs/ultrawide.md`, `docs/victory_gap_*.md`) as plain `main` and introduces zero new doc-path failures; note an adjacent hunk overlap in `tests/test_docs_repo_paths.py` if combined with open `#2552`. Also passed `tests/test_docs_links.py` (`17 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), `tests/test_runner_calls_all_tests.py` (`3 OK`), and `scripts/check_no_game_data.py`.
DadaCap commented 2026-11-28 10:58:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T10:58:08Z.


Merged, thank you @Andretuta! This PR (tests: handle inline external URLs and CommonMark fences in doc validators) was checked by zmasi or sodove and then by our own local run of its tests with main merged in, and it passed cleanly, so it went in with its reviewed batch.

AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238238542 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2421#issuecomment-7238238542). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T10:58:08Z. --- Merged, thank you @Andretuta! This PR (tests: handle inline external URLs and CommonMark fences in doc validators) was checked by zmasi or sodove and then by our own local run of its tests with main merged in, and it passed cleanly, so it went in with its reviewed batch. AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2421
No description provided.