refactor(doclinks): unify link handlers and validate all file links#1348
Open
refactor(doclinks): unify link handlers and validate all file links#1348
Conversation
Add Pattern 3 to doclinks that validates existing .md links in docs: - Resolves relative .md paths to absolute links - Validates absolute .md links exist on disk - Falls back to doc_index search for broken links with disambiguation - Handles index.md files by searching parent dir name - Scores candidates by directory overlap + filename match Delete duplicate docs/usage/transports.md (identical to transports/index.md). Fixes 5 broken links across docs/ (agents/docs/index.md, capabilities/ navigation/readme.md, usage/lcm.md).
Contributor
Greptile SummaryThis PR consolidates 3 separate regex patterns and handlers in Key improvements:
The refactor is backward-compatible and all existing behaviors are preserved. The 9 new tests provide comprehensive coverage of the disambiguation logic, link validation, and edge cases. Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[process_markdown] --> B{Split by ignore regions}
B --> C[Process each region]
C --> D{Apply code_pattern}
D --> E[replace_code_match]
E --> F{File has extension or /?}
F -->|No| G[Skip]
F -->|Yes| H[file_index lookup]
H --> I[resolve_candidates]
I --> J{Candidates count}
J -->|0| K[Error: not found]
J -->|1| L[Use single match]
J -->|Multiple| M[pick_best_candidate]
M --> N{score_path_similarity}
N -->|Unique max| O[Use best match]
N -->|Tie| P[Error: ambiguous]
C --> Q{Apply link_pattern}
Q --> R[replace_link_match]
R --> S{Link type?}
S -->|.md placeholder| T[doc_index lookup]
S -->|Absolute path| U{File exists?}
S -->|Relative path| V{File exists?}
S -->|URL/anchor| W[Skip]
T --> I
U -->|No| X[_search_fallback]
V -->|No| X
X --> Y{Has extension?}
Y -->|.md| Z[doc_index search]
Y -->|Other| AA[file_index search]
Z --> I
AA --> I
Last reviewed commit: 4a6848b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Doclinks validates all links and tries to intelligently re-link if stuff is moved, insists on absolute links everywhere, shares more code between .md link resolution and .py etc resolution.
updates existing docs/ links
Doclinks is vibed
we don't care about the code here, just speed & correct behaviour, review by looking at docs/ changes
How to Test
Contributor License Agreement