Skip to content

Conversation

@ebembi-crdb
Copy link
Contributor

Summary

This PR adds a linter that prevents cross-version links in documentation PRs. The linter ensures that documentation for each version only links to pages within the same version, preventing broken links when older versions are archived.

Motivation

  • Addresses EDUENG-350 cross-version linking issue
  • Prevents broken links when versions are archived
  • Recent archival PRs have shown multiple instances of cross-version links that broke documentation

What this PR does

  • Adds Python linter script that detects cross-version links in markdown files
  • Adds GitHub Actions workflow that runs on every PR modifying documentation
  • Blocks PR merge if cross-version links are detected
  • Provides clear error messages with suggested fixes

Cross-version link patterns detected

  • Hard-coded Liquid links: {% link v21.2/backup.md %}
  • Include statements: {% include_cached v22.1/provision.md %}
  • Image references: {{ 'images/v22.2/diagram.png' | relative_url }}
  • Relative markdown links: [text](../v20.1/page.md)
  • Absolute markdown links: [text](/docs/v19.1/page.md)
  • HTML anchor tags: <a href="v18.2/page.html">

Testing

  • 16 comprehensive unit tests covering all link patterns
  • Tests verify both detection of violations and proper handling of valid links
  • Linter correctly ignores dynamic version variables like {{ page.version.version }}

Notes

  • Only checks files modified in the PR (not the entire codebase)
  • Existing cross-version links in the codebase are not affected
  • Strict enforcement: no cross-version links allowed

- Add Python script to detect cross-version links in markdown files
- Add GitHub Actions workflow to run on PRs
- Add comprehensive unit tests
- Block PR merge if cross-version links are detected
- Provide clear error messages with suggested fixes
@ebembi-crdb ebembi-crdb requested a review from a team as a code owner December 30, 2025 17:00
@github-actions
Copy link

Files changed:

  • .github/scripts/cross_version_link_linter.py
  • .github/scripts/test_cross_version_linter.py
  • .github/workflows/cross-version-links.yml

@netlify
Copy link

netlify bot commented Dec 30, 2025

Deploy Preview for cockroachdb-interactivetutorials-docs canceled.

Name Link
🔨 Latest commit 11705cb
🔍 Latest deploy log https://app.netlify.com/projects/cockroachdb-interactivetutorials-docs/deploys/695e555f9800bc00092784d1

@netlify
Copy link

netlify bot commented Dec 30, 2025

Deploy Preview for cockroachdb-api-docs canceled.

Name Link
🔨 Latest commit 11705cb
🔍 Latest deploy log https://app.netlify.com/projects/cockroachdb-api-docs/deploys/695e555f29c066000857bdd9

@netlify
Copy link

netlify bot commented Dec 30, 2025

Netlify Preview

Name Link
🔨 Latest commit 11705cb
🔍 Latest deploy log https://app.netlify.com/projects/cockroachdb-docs/deploys/695e555f5a44ef0008f5159f
😎 Deploy Preview https://deploy-preview-21923--cockroachdb-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@mohini-crl mohini-crl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

- Fix markdown_relative regex to detect multiple ../ levels (e.g., ../../v23.1/)
- Broaden ALLOWED_PATTERNS to match site.versions["stable"] bracket notation
- Make image_ref fix more robust by targeting images/vX.X/ pattern
- Improve markdown link fix to preserve full nested paths instead of just filename
- Add 9 new unit tests covering multi-level paths, bracket notation, and complex filenames
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