Skip to content

Add auto-fix capability to fix-links.py for broken internal links#349

Draft
Copilot wants to merge 7 commits into4.6.xfrom
copilot/optimize-fix-links-script
Draft

Add auto-fix capability to fix-links.py for broken internal links#349
Copilot wants to merge 7 commits into4.6.xfrom
copilot/optimize-fix-links-script

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

Enhances fix-links.py to automatically repair broken internal documentation links using fuzzy file matching.

Changes

  • --fix flag: Enables automatic link correction with .bak backups
  • File cache: Builds repository-wide file index (4750+ files) on startup for O(1) lookups during fuzzy matching
  • Fuzzy matching: Uses difflib.get_close_matches() with 60-70% similarity threshold to find target files when exact paths don't exist
  • Path resolution: Calculates correct relative paths from source to target, preserving anchors and query parameters
  • Suggested fixes: Shows "💡 Suggested fix" for all broken internal links, even without --fix flag

Usage

# Preview suggested fixes
./bin/quality/check-links.sh --skip-external

# Apply fixes (creates .bak backups)
./bin/quality/check-links.sh --skip-external --fix

Example Output

🔧 Applying fixes to 3 file(s)...
   ✓ Fixed: ../devdocs/test-guide.md → ../docs-dev/copilot/test-guide.md
   ✓ Fixed: TESTING.md → ../TESTING.md
   📝 Updated: docs/test-strategy.md

✅ Fixed 2 broken link(s)!

Handles

  • Wrong directory names (devdocsdocs-dev)
  • Missing path prefixes (/pulsar-core/...)
  • Incorrect relative paths between files
  • Files moved to different module directories

Does Not Fix

  • External URLs (HTTP/HTTPS)
  • Links where no similar file exists (fuzzy match fails)
  • Special URI schemes (mailto:, javascript:, etc.)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 6 commits February 13, 2026 13:39
Co-authored-by: galaxyeye <1701451+galaxyeye@users.noreply.github.com>
Co-authored-by: galaxyeye <1701451+galaxyeye@users.noreply.github.com>
Co-authored-by: galaxyeye <1701451+galaxyeye@users.noreply.github.com>
Co-authored-by: galaxyeye <1701451+galaxyeye@users.noreply.github.com>
Co-authored-by: galaxyeye <1701451+galaxyeye@users.noreply.github.com>
Co-authored-by: galaxyeye <1701451+galaxyeye@users.noreply.github.com>
Copilot AI changed the title [WIP] Optimize fix-links.py for local document link correction Add auto-fix capability to fix-links.py for broken internal links Feb 13, 2026
Copilot AI requested a review from galaxyeye February 13, 2026 13:47
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