Skip to content

Commit 678d26e

Browse files
committed
fix: improve link checking in documentation by excluding code blocks
- Enhance the `check_relative_links` function in `check_docs.py` to remove code blocks from markdown files before checking for relative links. This change prevents false positives from links within code examples, improving the accuracy of link validation. These updates aim to enhance the reliability of documentation checks and ensure that only relevant links are evaluated.
1 parent 8e5d2f8 commit 678d26e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scripts/check_docs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ def check_relative_links(markdown_files: list[Path]) -> list[str]:
3131

3232
for md in markdown_files:
3333
text = md.read_text(encoding="utf-8")
34-
for raw_target in LINK_RE.findall(text):
34+
35+
# Remove code blocks to avoid false positives from code examples
36+
code_block_pattern = re.compile(r"```[\s\S]*?```", re.MULTILINE)
37+
text_without_code = code_block_pattern.sub("", text)
38+
39+
for raw_target in LINK_RE.findall(text_without_code):
3540
target = raw_target.strip()
3641
if not target or target.startswith("#"):
3742
continue

0 commit comments

Comments
 (0)