Skip to content

feat: add anchor validation to internal link checker#748

Merged
RiskeyL merged 3 commits into
mainfrom
feat/check-anchors
Apr 16, 2026
Merged

feat: add anchor validation to internal link checker#748
RiskeyL merged 3 commits into
mainfrom
feat/check-anchors

Conversation

@RiskeyL
Copy link
Copy Markdown
Contributor

@RiskeyL RiskeyL commented Apr 16, 2026

Summary

Extend tools/check-links.py to validate the #anchor portion of internal links, not just the file portion. Previously the checker stripped anchors before resolving, so a link like /foo/bar#stale would pass as long as /foo/bar existed.

The checker now extracts anchors from:

  • Markdown headings (with GFM duplicate-suffixing for repeats)
  • Custom {#id} and <a id="..."> syntax
  • Mintlify <Tab title="..."> and <Accordion title="...">, which generate per-tab anchors from the title attribute

Same-page #anchor links are validated against the source file. API reference paths (/api-reference/...) are skipped because their anchors come from OpenAPI specs rather than MDX content; supporting those would require resolving and parsing the spec referenced in docs.json.

Anchors fixed as a side effect

The new check surfaced 29 broken anchors across en/zh/ja, fixed in the second commit. They fall into three groups:

  • Stale anchor slugs after heading renames or typos in en sources (e.g., #variable#variables, URL-encoded colon in a Weaviate migration anchor).
  • English anchors carried into zh/ja translations where the headings had been translated (e.g., #model-provider#モデルプロバイダー / #模型提供商).
  • Section-numbered references in datasource-plugin.mdx pointing to a "Hello World Guide" structure that no longer matches the current tool-plugin.mdx. Both link text and anchors updated.

Copilot AI review requested due to automatic review settings April 16, 2026 12:47
@mintlify
Copy link
Copy Markdown
Contributor

mintlify Bot commented Apr 16, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
dify-core-product 🟢 Ready View Preview Apr 16, 2026, 12:51 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Apr 16, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Extend the docs link-checking tool to validate internal link fragments (#anchors) by extracting valid anchors from MDX/Markdown content, and fix newly-detected broken anchors across EN/JA/ZH docs.

Changes:

  • Add per-file anchor extraction + validation to tools/check-links.py (headings, custom IDs, <a id="">, and Mintlify Tab/Accordion titles).
  • Skip anchor validation for /api-reference/... links where anchors are not derived from page MDX.
  • Update multiple documentation pages to use the correct (translated/updated) anchor slugs.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tools/check-links.py Adds anchor extraction, caching, and validation for internal links with fragments.
en/use-dify/knowledge/test-retrieval.mdx Fixes internal anchor to match updated heading slug in the indexing/retrieval settings page.
en/self-host/troubleshooting/weaviate-v4-migration.mdx Fixes a percent-encoded anchor to the canonical slug form.
en/develop-plugin/features-and-specs/plugin-types/tool.mdx Updates card links to correct anchors (variables, custom-output-variables).
en/develop-plugin/dev-guides-and-walkthroughs/datasource-plugin.mdx Updates links to tool-plugin sections with current heading slugs.
ja/use-dify/nodes/user-input.mdx Updates same-page anchor to match Japanese heading slug.
ja/use-dify/knowledge/test-retrieval.mdx Fixes anchor/link text to match current Japanese section heading.
ja/self-host/troubleshooting/weaviate-v4-migration.mdx Updates troubleshooting anchor to Japanese heading slug.
ja/develop-plugin/features-and-specs/plugin-types/tool.mdx Updates card links to match Japanese section anchors.
ja/develop-plugin/features-and-specs/plugin-types/model-schema.mdx Updates card links to match Japanese section anchors.
ja/develop-plugin/dev-guides-and-walkthroughs/datasource-plugin.mdx Updates links to tool-plugin sections with current Japanese heading slugs.
zh/use-dify/nodes/user-input.mdx Updates same-page anchor to match Chinese heading slug.
zh/self-host/troubleshooting/weaviate-v4-migration.mdx Updates troubleshooting anchor to Chinese heading slug.
zh/develop-plugin/features-and-specs/plugin-types/tool.mdx Updates card links to match Chinese section anchors.
zh/develop-plugin/features-and-specs/plugin-types/model-schema.mdx Updates card links to match Chinese section anchors.
zh/develop-plugin/dev-guides-and-walkthroughs/datasource-plugin.mdx Updates links to tool-plugin sections with current Chinese heading slugs.

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

Comment thread tools/check-links.py
Comment thread tools/check-links.py Outdated
@RiskeyL RiskeyL merged commit 8c5ca8f into main Apr 16, 2026
3 checks passed
@RiskeyL RiskeyL deleted the feat/check-anchors branch April 16, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants