Skip to content

ci: enforce relative internal doc links + pre-commit hint#2550

Open
ElliotFriend wants to merge 4 commits into
stellar:mainfrom
ElliotFriend:chore/enforce-relative-links-2547
Open

ci: enforce relative internal doc links + pre-commit hint#2550
ElliotFriend wants to merge 4 commits into
stellar:mainfrom
ElliotFriend:chore/enforce-relative-links-2547

Conversation

@ElliotFriend

Copy link
Copy Markdown
Contributor

Sub-task 2 (final piece) of #2547. Adds automation so absolute /docs/... internal links can't regress after the manual fixes in #2548 and #2549.

Two layers

1. CI gate — the guarantee. A step in the mdx-format job of main.yml greps docs/ for ](/docs and fails the PR if any are found. Unbypassable and setup-independent, so it catches links regardless of contributor tooling or GitHub web edits.

2. Pre-commit hint — the ergonomics. A staged-files-only grep appended to .husky/pre-commit, giving fast local feedback before the (minutes-long) CI round-trip. Scoped to staged files so pre-existing links in untouched files never block unrelated commits — CI is the repo-wide backstop.

Why two layers: the hook is bypassable (--no-verify) and only runs for contributors with the repo set up, so it can't be the guarantee — but it saves the 90% who do have it set up a slow failed-CI cycle. See the discussion in #2547.

Both exclude CONTRIBUTING.md: it's excluded from the docs build (docusaurus.config.ts line 143) and its /docs link is a deliberate illustrative example.

Why the naive check isn't enough on its own

The existing PR checks don't catch this class: ci:mdx is prettier (ignores link style), and pnpm build with onBrokenLinks: "throw" only fails on dead routes — an absolute link to a page that exists passes. This grep closes that gap.

⚠️ Merge order

This branch is stacked on #2548 and #2549 so its own CI passes on a clean tree. Merge those two first. Once they land, this PR's diff reduces to just the two infra files (main.yml, .husky/pre-commit). If merged before them, the repo-wide gate will (correctly) fail on the not-yet-converted links.

Verification (all run locally)

  • CI grep: passes on clean tree; catches a synthetic ](/docs; ignores CONTRIBUTING.md
  • Pre-commit hook, end-to-end: blocks a staged docs file with a /docs link; passes a clean docs file; passes a staged CONTRIBUTING.md with a /docs link
  • Verified the hook is set -e-safe (husky runs sh -e): the staged-file substitution is guarded with || true, and the empty-stage path (no docs staged) skips cleanly

Closes #2547

🤖 Generated with Claude Code

ElliotFriend and others added 4 commits July 2, 2026 13:09
Replace absolute /docs/... links with relative ../path/file.mdx links
per Docusaurus convention (docs/platforms/anchor-platform/CONTRIBUTING.md).
Relative links with the file extension are validated at build time by
onBrokenMarkdownLinks, unlike absolute route links.

Fixes stellar#2546

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sweeps the remaining absolute /docs/... links (7 occurrences across 5
files) to relative ../path/file.mdx links per the repo convention.
Relative links with the file extension are validated at build time by
onBrokenMarkdownLinks; absolute route links are not.

Tier 1 Orgs page is handled separately in stellar#2546. CONTRIBUTING.md is
left untouched: it is excluded from the docs build and its /docs link
is an intentional illustrative example.

Part of stellar#2547

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…s-sweep-2547' into chore/enforce-relative-links-2547
Sub-task 2 of stellar#2547. Adds two layers preventing absolute /docs/... links
from regressing:

- CI gate (main.yml): repo-wide grep in the mdx-format job, fails the PR
  if any docs/ .md/.mdx file contains a `](/docs` link. Unbypassable,
  setup-independent — the real guarantee.
- Pre-commit hint (.husky/pre-commit): staged-files-only grep for fast
  local feedback. Scoped to staged files so pre-existing links in
  untouched files never block unrelated commits.

Both exclude CONTRIBUTING.md, which is not part of the docs build and
whose /docs link is an intentional illustrative example.

Part of stellar#2547

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 2, 2026 18:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR advances the repo-wide convention of using relative .mdx internal doc links (instead of absolute /docs/... routes) by adding an enforcement check in CI and a fast-feedback check in the pre-commit hook, alongside the stacked link-conversion edits in docs.

Changes:

  • Convert remaining /docs/... internal links to relative ./ / ../ .mdx links in several docs pages (stacked on earlier PRs).
  • Add a CI gate in mdx-format to fail PRs if any ](/docs links exist under docs/ (excluding CONTRIBUTING.md).
  • Add a staged-files-only pre-commit check to warn early about absolute /docs links in edited docs files.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
docs/validators/tier-1-orgs.mdx Replaces absolute /docs/... links with relative .mdx links for validator docs.
docs/validators/README.mdx Updates Tier 1 Organizations link to a relative .mdx target.
docs/validators/admin-guide/publishing-history-archives.mdx Updates Tier 1 Organizations link to relative .mdx.
docs/validators/admin-guide/prerequisites.mdx Updates Tier 1 + reserve requirements + history-archives links to relative .mdx.
docs/validators/admin-guide/configuring.mdx Updates Tier 1 + publishing-history-archives links to relative .mdx.
docs/tools/lab/transaction-dashboard.mdx Updates Indexers and Block Explorers links to relative .mdx targets.
.husky/pre-commit Adds a staged-docs-only grep to catch ](/docs links locally before CI.
.github/workflows/main.yml Adds CI step to fail when absolute internal /docs links are present in docs/.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .husky/pre-commit
# Fast local check: no absolute internal /docs links in staged docs.
# Scoped to staged files so pre-existing links in untouched files don't block
# unrelated commits. CI enforces this repo-wide. CONTRIBUTING.md is excluded.
staged_docs=$(git diff --cached --name-only --diff-filter=ACM | grep -E '^docs/.*\.mdx?$' | grep -v 'CONTRIBUTING\.md$' || true)
@stellar-jenkins-ci

Copy link
Copy Markdown

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.

Enforce relative internal links repo-wide (follow-up to #2546)

2 participants