Resolve ApiLink targets from generated registry#64
Open
viktorkombov wants to merge 2 commits into
Open
Conversation
dobromirts
reviewed
Jun 4, 2026
|
|
||
| const upperFirst = (value: string) => value ? value.charAt(0).toUpperCase() + value.slice(1) : value; | ||
|
|
||
| function addUnique(values: string[], value?: string): void { |
Contributor
There was a problem hiding this comment.
Isnt it better to use Set intead of the addUnique function
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the ApiLink MDX component to resolve TypeDoc API documentation URLs via a build-time, platform-provided registry (platformContext.apiLinkIndex) instead of hard-coded platform/package URL rules in MDX, while keeping a legacy URL-generation fallback.
Changes:
- Add registry-based TypeDoc symbol resolution (including member anchors) via
platformContext.apiLinkIndex. - Refactor
ApiLink.astroto use index resolution first (when available) and keep legacy URL generation as a fallback path. - Document the local registry contract/fields in the
ApiLinkREADME and extendPlatformContextwithapiLinkIndex.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/lib/types.ts |
Extends PlatformContext with optional apiLinkIndex and updates classSuffix docs to reflect registry-driven behavior. |
src/components/mdx/ApiLink/README.md |
Updates docs to describe registry-based resolution, preferred authoring style, and the compact index schema. |
src/components/mdx/ApiLink/ApiLink.astro |
Implements index-first resolution with legacy fallback and updates prop handling for registry lookup. |
src/components/mdx/ApiLink/api-link-index.ts |
Adds the index lookup/resolution utilities (candidate-name generation, member-anchor mapping, URL absolutization). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+71
to
+75
| const candidates: string[] = []; | ||
| addUnique(candidates, member); | ||
| if (pkgConfig.pascalCaseMembers) addUnique(candidates, upperFirst(member)); | ||
| addUnique(candidates, upperFirst(member)); | ||
| addUnique(candidates, member.toLowerCase()); |
Comment on lines
+137
to
+139
| if (Object.keys(index.symbols).length === 0) { | ||
| return { status: 'missing' }; | ||
| } |
Comment on lines
+155
to
+161
| if (indexed.status === 'resolved') { | ||
| url = indexed.url; | ||
| const indexedDisplay = getIndexedDisplayName(indexed.symbolName, baseType, type, pkgConfig.classSuffix); | ||
| displayLabel = label ?? (member ? `${indexedDisplay}.${member}` : indexedDisplay); | ||
| } else if (indexed.status === 'missing') { | ||
| isExcluded = true; | ||
| } |
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
Updates ApiLink to resolve API documentation links from a generated local registry instead of encoding platform-specific package/kind/suffix rules in MDX.
Changes
platformContext.apiLinkIndex.pkgas an optional filter for ambiguous symbol names.Testing