Don't render broken links to symbols excluded from documentation (#4448) - #4536
Draft
vmishenev wants to merge 2 commits into
Draft
Don't render broken links to symbols excluded from documentation (#4448)#4536vmishenev wants to merge 2 commits into
vmishenev wants to merge 2 commits into
Conversation
vmishenev
marked this pull request as draft
June 18, 2026 10:56
When a KDoc/signature link references a symbol that is not part of the rendered documentation (suppressed via `perPackageOption`/`suppress`, hidden by `skipDeprecated`, `internal`, a private constructor, or an undocumented external symbol), the link resolves to a valid DRI during analysis but the target page is never generated. Dokka silently produced a link to a non-existent page and emitted no warning. `DefaultExternalModuleLinkResolver.resolve()` resolved links purely from a module's package-list, and only verified the target page existed when several modules shared a package name (the #3368 hack). It now always verifies the page exists (dropping the `#anchor` first so member links are not falsely rejected); a missing page yields an unresolved span instead of a dead `<a href>`. In addition, both the multi-module assembly (`ResolveLinkCommandHandler`) and single-module rendering (`HtmlRenderer.buildDRILink`) now warn when a documentation link cannot be resolved to a page. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
vmishenev
force-pushed
the
vmishenev/4448-fix-broken-links-to-excluded-classes
branch
from
June 18, 2026 12:41
a76b0ec to
3d5f762
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4448.
When a KDoc/signature link references a symbol that is not part of the rendered documentation (suppressed via
perPackageOption/suppress, hidden byskipDeprecated,internal, a private constructor, or an undocumented external symbol), the link resolves to a validDRIduring analysis but the target page is never generated. Dokka silently produced a link to a non-existent page and emitted no warning.Changes
DefaultExternalModuleLinkResolver.resolve()resolved links purely from a module'spackage-list, and only verified the target page existed when several local modules shared a package name (the Generating external link should depend on the module it refers to #3368 hack). It now always verifies the page exists — dropping the#anchorfirst so member links (index.html#anchor) aren't falsely rejected. A missing page yields an unresolved span instead of a dead<a href>.ResolveLinkCommandHandler) and single-module rendering (HtmlRenderer.buildDRILink) now log a warning when a documentation link cannot be resolved to a page. Assembly-phase warnings are log-only (so multi-module builds aren't broken by unavoidable external links); single-module warnings flow through each module's ownfailOnWarning.Tests
LinkToExcludedSymbolTest(plugin-base): a public symbol linking to aninternalone renders an unresolved span (not<a>), logs a warning, and throws underfailOnWarning. Passes on K1 and K2.ResolveLinkCommandResolutionTest(+ a negative test where the package resolves but the page is absent) andResolveLinkGfmCommandResolutionTestfor the new existence check.IoGradleIntegrationTest: re-enabledassertNoHrefToMissingLocalFileOrDirectory— now passes (kotlinx-io's broken<init>link became a span, and the new "Couldn't resolve link" warnings appear for its external Apple/stdlib links).Note for reviewers
AbstractIntegrationTest.assertNoUnresolvedLinksis left as-is. Its regexdata-unresolved-link="\[expects a leading[, but realDRI.toString()values (e.g.platform.Foundation/NSData///…) have none, so it currently matches nothing. Fixing it would fail on kotlinx-io's legitimate external-only spans (Appleplatform.Foundation.*,kotlin.Throwablemembers), so it needs a separate decision (allowlist external packages, or drop the assertion).🤖 Generated with Claude Code