Validate markdown anchors in docs smoke#873
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds heading-anchor extraction and uses it to validate local Markdown fragment links: new regexes and helpers compute normalized anchors (ignoring fenced code and suffixing duplicates), and ChangesMarkdown heading anchor validation
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: b969b667-c8ce-412e-b902-d089e5938fc5
📒 Files selected for processing (2)
scripts/docs_smoke.pytests/test_docs_public_urls.py
caozhengming
left a comment
There was a problem hiding this comment.
Thanks for the focused docs-smoke improvement. I reviewed current head a98caed4a8ff54428f1dff381a63cbb8c1da1d45 and the basic validation passes, but I think this needs one more round before merge.
Blocker: the new Markdown anchor validator does not match GitHub-style heading anchors in two common cases:
- repeated headings lose the generated suffix because
_markdown_anchors()stores anchors in aset, so# Samefollowed by## Sameonly producessameand a valid GitHub fragment like#same-1is reported missing; - headings inside fenced code blocks are counted as real anchors because
HEADING_REscans the whole Markdown file, so a fragment targeting a pseudo-heading inside a code block is incorrectly accepted.
Repro on this head:
anchors= ['fake', 'real', 'same']
duplicate_same_1= False
fenced_fake= True
real= True
The repro used a temp Markdown file containing:
# Same
## Same
```md
# Fake
```
# RealExpected behavior for GitHub-compatible docs smoke is the opposite for the first two checks: docs.md#same-1 should be valid, while docs.md#fake should be invalid because it is inside a fenced block. Please add duplicate-heading suffix handling and ignore fenced code blocks before extracting heading anchors, with regression tests for both boundaries.
Validation I ran:
uv run --extra dev python -m pytest tests/test_docs_public_urls.py -q-> 37 passed, with only the existing pytest temp cleanup PermissionError after success on Windows.uv run --extra dev python scripts/docs_smoke.py-> docs smoke ok.uv run --extra dev python -m ruff check scripts/docs_smoke.py tests/test_docs_public_urls.py-> passed.uv run --extra dev python -m ruff format --check scripts/docs_smoke.py tests/test_docs_public_urls.py-> 2 files already formatted.git diff --check origin/main...HEAD-> clean.git merge-tree --write-tree origin/main HEAD-> clean tree39c126843f6e5935f646adc1714e18990f0fb6ce.
Scope checked: docs-smoke validation only. I did not touch ledger, wallet, treasury, payout, admin-token, exchange, bridge, off-ramp, MRWK price, private data, or secrets.
|
Maintenance update for @caozhengming review:
Validation run locally:
Scope remains docs-smoke validation only; no ledger, wallet, treasury, payout, admin-token, exchange, bridge, off-ramp, MRWK price, private data, or secrets touched. @caozhengming could you re-review when convenient? |
xiefuzheng713-alt
left a comment
There was a problem hiding this comment.
Approved current head d05a7ac45203a346c5ccbe15a969926e8f97e520.
Evidence checked:
- inspected
scripts/docs_smoke.pyandtests/test_docs_public_urls.pyon the current head; - confirmed the follow-up commit addresses the earlier duplicate-anchor blocker by counting repeated generated slugs and accepting the GitHub-style
-1suffix; - confirmed fenced Markdown/code blocks are skipped before heading extraction, so pseudo-headings inside triple-backtick and tilde fences are not accepted as real anchors;
- confirmed
_local_target_exists()keeps the existing file-existence behavior while only applying fragment checks to Markdown targets; - rechecked GitHub state before review:
mergeStateStatus=CLEAN, hosted Quality/readiness/docs/image check is successful, and CodeRabbit is successful.
Validation on this exact head:
uv run --extra dev python -m pytest tests/test_docs_public_urls.py -q-> 39 passed.uv run --extra dev python scripts/docs_smoke.py-> docs smoke ok.uv run --extra dev ruff check scripts/docs_smoke.py tests/test_docs_public_urls.py-> passed.uv run --extra dev ruff format --check scripts/docs_smoke.py tests/test_docs_public_urls.py-> 2 files already formatted.uv run --extra dev mypy scripts/docs_smoke.py-> success.git diff --check origin/main...HEAD-> clean.git merge-tree --write-tree origin/main HEAD-> clean treedaf4215635eaadc757cc868712be348883a700ca.
No blocker found on the current head. Scope remains limited to docs-smoke Markdown anchor validation and focused tests; no ledger, wallet, treasury, payout, proposal execution, admin-token, exchange, bridge, cash-out, MRWK price, private data, or secrets behavior is changed.
Summary
Refs #846.
scripts/docs_smoke.pyso local Markdown links with#headingfragments verify the target heading exists;Validation
uv run --extra dev python -m pytest tests/test_docs_public_urls.py -q-> 37 passeduv run --extra dev python scripts/docs_smoke.py-> docs smoke okuv run --extra dev python -m ruff check scripts/docs_smoke.py tests/test_docs_public_urls.py-> passedgit diff --check-> passedScope
Docs-smoke maintainability only. No ledger, wallet, treasury, payout, admin-token, exchange, bridge, off-ramp, price, liquidity, or production data behavior is changed.
Summary by CodeRabbit
Chores
Tests