Skip to content

Resolve ApiLink targets from generated registry#64

Open
viktorkombov wants to merge 2 commits into
masterfrom
vkombov/resolve-api-docs-urls
Open

Resolve ApiLink targets from generated registry#64
viktorkombov wants to merge 2 commits into
masterfrom
vkombov/resolve-api-docs-urls

Conversation

@viktorkombov
Copy link
Copy Markdown
Collaborator

@viktorkombov viktorkombov commented May 29, 2026

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

  • Added registry-based ApiLink resolution through platformContext.apiLinkIndex.
  • Uses generated symbol data for package, kind, URL, and member anchors.
  • Keeps pkg as an optional filter for ambiguous symbol names.
  • Removed remote registry fetching and endpoint-root configuration.
  • Updated ApiLink README with the local registry contract and compact field meanings.

Testing

  • Ran focused TypeScript checks for ApiLink registry code and shared types.
  • Verified Web Components chart symbols resolve from registry data.

@viktorkombov viktorkombov changed the title Resolve ApiLink URLs from api-docs symbol index Resolve ApiLink targets from generated registry Jun 2, 2026

const upperFirst = (value: string) => value ? value.charAt(0).toUpperCase() + value.slice(1) : value;

function addUnique(values: string[], value?: string): void {
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.

Isnt it better to use Set intead of the addUnique function

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

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.astro to use index resolution first (when available) and keep legacy URL generation as a fallback path.
  • Document the local registry contract/fields in the ApiLink README and extend PlatformContext with apiLinkIndex.

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

❌ status: awaiting-test PRs awaiting manual verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants