igniteui-astro-components 0.0.19 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "igniteui-astro-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "Reusable Astro components, layouts, and integrations for Infragistics / Ignite UI documentation sites. Replaces the Starlight defaults with project-specific implementations.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -2,213 +2,154 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Inline API documentation link.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* <!-- core package — class (default kind) -->
|
|
11
|
-
* <ApiLink type="Toast" />
|
|
12
|
-
* → <a href="…/classes/igniteui-react.igrtoast.html"><code>IgrToast</code></a>
|
|
13
|
-
*
|
|
14
|
-
* <!-- class member -->
|
|
15
|
-
* <ApiLink type="Toast" member="show" label="Show" />
|
|
16
|
-
* → <a href="…/classes/igniteui-react.igrtoast.html#show"><code>Show</code></a>
|
|
17
|
-
*
|
|
18
|
-
* <!-- sub-package class -->
|
|
19
|
-
* <ApiLink pkg="charts" type="CategoryChart" />
|
|
20
|
-
*
|
|
21
|
-
* <!-- function (no platform prefix) -->
|
|
22
|
-
* <ApiLink kind="function" type="configureTheme" prefixed={false} />
|
|
23
|
-
* → <a href="…/functions/igniteui-react.configureTheme.html"><code>configureTheme</code></a>
|
|
24
|
-
*
|
|
25
|
-
* <!-- variable (fully-qualified) -->
|
|
26
|
-
* <ApiLink kind="variable" type="IgrCalendarResourceStringEN" prefixed={false} />
|
|
27
|
-
* → <a href="…/variables/igniteui-react.IgrCalendarResourceStringEN.html">…</a>
|
|
28
|
-
*
|
|
29
|
-
* <!-- type alias -->
|
|
30
|
-
* <ApiLink kind="type" type="AbsolutePosition" prefixed={false} />
|
|
31
|
-
* → <a href="…/types/igniteui-react.AbsolutePosition.html"><code>AbsolutePosition</code></a>
|
|
32
|
-
*
|
|
33
|
-
* <!-- interface -->
|
|
34
|
-
* <ApiLink kind="interface" type="ComboTemplateProps" prefixed={false} />
|
|
35
|
-
* → <a href="…/interfaces/igniteui-react.ComboTemplateProps.html">…</a>
|
|
36
|
-
*
|
|
37
|
-
* <!-- enum -->
|
|
38
|
-
* <ApiLink kind="enum" type="CalendarSelection" />
|
|
39
|
-
* → <a href="…/enums/igniteui-react.igrcalendarselection.html">…</a>
|
|
5
|
+
* TypeDoc links resolve against the compact api-docs ApiLink index. If the
|
|
6
|
+
* index does not contain the requested symbol/member, it renders code text
|
|
7
|
+
* instead of guessing a URL.
|
|
40
8
|
*/
|
|
41
9
|
import type { PlatformContext } from '../../../lib/types.ts';
|
|
10
|
+
import {
|
|
11
|
+
resolveApiLinkFromIndex,
|
|
12
|
+
type TypeDocKind,
|
|
13
|
+
} from './api-link-index';
|
|
42
14
|
import './ApiLink.scss';
|
|
43
15
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/** Props for SASS API documentation links (`kind="sass"`). */
|
|
16
|
+
/** Props for Sass API documentation links (`kind="sass"`). */
|
|
47
17
|
type SassProps = {
|
|
18
|
+
/** Selects Sass API link mode. */
|
|
48
19
|
kind: 'sass';
|
|
49
|
-
/**
|
|
20
|
+
/** Anchor fragment without `#`, e.g. `mixin-slide-in-left`. */
|
|
50
21
|
type?: string;
|
|
51
|
-
/**
|
|
22
|
+
/** Sass module path segment, e.g. `animations` or `themes`. */
|
|
52
23
|
module?: string;
|
|
53
|
-
/**
|
|
54
|
-
* When true, wraps the label in <code>.
|
|
55
|
-
* @default true — matches TypeDoc ApiLink code-formatting behaviour.
|
|
56
|
-
* Set to false for descriptive/prose labels.
|
|
57
|
-
*/
|
|
24
|
+
/** Wrap the rendered label in `<code>`. Defaults to `true`. */
|
|
58
25
|
code?: boolean;
|
|
59
|
-
/** Override the
|
|
26
|
+
/** Override the rendered label. */
|
|
60
27
|
label?: string;
|
|
61
28
|
};
|
|
62
29
|
|
|
63
|
-
/** Props for TypeDoc API documentation links
|
|
30
|
+
/** Props for TypeDoc API documentation links. */
|
|
64
31
|
type TypeDocProps = {
|
|
65
32
|
/**
|
|
66
|
-
* TypeDoc symbol kind.
|
|
67
|
-
*
|
|
33
|
+
* TypeDoc symbol kind. Narrows registry lookup when the same symbol exists
|
|
34
|
+
* as multiple TypeDoc kinds.
|
|
68
35
|
*/
|
|
69
|
-
kind?:
|
|
36
|
+
kind?: TypeDocKind;
|
|
70
37
|
/**
|
|
71
38
|
* Short type/symbol name without platform prefix, e.g. "Toast".
|
|
72
39
|
* Required for all TypeDoc kinds.
|
|
73
40
|
*/
|
|
74
41
|
type: string;
|
|
75
|
-
/** Optional member
|
|
42
|
+
/** Optional class/interface member, property, method, or enum value anchor. */
|
|
76
43
|
member?: string;
|
|
77
|
-
/**
|
|
78
|
-
* Package key as defined in platform-context apiPackages.
|
|
79
|
-
* Defaults to "core" (the main component package).
|
|
80
|
-
* Use "charts", "grids", "gauges", "maps", "inputs", "layouts",
|
|
81
|
-
* "excel", "spreadsheet", "datasources" for sub-packages.
|
|
82
|
-
*/
|
|
44
|
+
/** Package key used only to filter ambiguous registry matches. */
|
|
83
45
|
pkg?: string;
|
|
84
|
-
/**
|
|
85
|
-
* Override the display text. Defaults to the (prefixed) name,
|
|
86
|
-
* optionally suffixed with ".member".
|
|
87
|
-
*/
|
|
46
|
+
/** Override the rendered label. */
|
|
88
47
|
label?: string;
|
|
89
48
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* fully-qualified name or a non-prefixed symbol like a function name.
|
|
49
|
+
* Whether to prepend the platform prefix before registry lookup.
|
|
50
|
+
* @default true
|
|
93
51
|
*/
|
|
94
52
|
prefixed?: boolean;
|
|
95
53
|
/**
|
|
96
|
-
*
|
|
97
|
-
* is appended to the class name. Set to false for utility/non-component classes
|
|
98
|
-
* that do not carry the platform class suffix (e.g. FilteringOperand, SortingStrategy).
|
|
54
|
+
* Whether to try the platform class suffix before the unsuffixed symbol.
|
|
99
55
|
* @default true
|
|
100
56
|
*/
|
|
101
57
|
suffix?: boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Comma-separated list of platforms (e.g. "React" or "React,Blazor") for
|
|
104
|
-
* which the API link does NOT exist on the documentation site. When the
|
|
105
|
-
* current platform matches any entry the component renders the type name
|
|
106
|
-
* as plain inline code (no link), preserving the symbol reference for the
|
|
107
|
-
* reader without producing a broken URL.
|
|
108
|
-
*
|
|
109
|
-
* Use this instead of wrapping a single <ApiLink> in a <PlatformBlock>
|
|
110
|
-
* just to hide it from a specific platform.
|
|
111
|
-
*/
|
|
112
|
-
exclude?: string;
|
|
113
|
-
/**
|
|
114
|
-
* Comma-separated list of platforms for which the package classSuffix
|
|
115
|
-
* (e.g. "Component") should NOT be appended, overriding the package default.
|
|
116
|
-
* Useful when the same type is a plain class on some platforms but carries
|
|
117
|
-
* a framework suffix on others (e.g. "Angular,WebComponents").
|
|
118
|
-
*
|
|
119
|
-
* Does not suppress the link — combine with `exclude` to suppress entirely.
|
|
120
|
-
*/
|
|
121
|
-
excludeSuffixFor?: string;
|
|
122
|
-
/**
|
|
123
|
-
* Comma-separated list of platforms for which the platform prefix
|
|
124
|
-
* (Igr/Igx/Igc/Igb) should NOT be prepended, overriding the package default.
|
|
125
|
-
* Useful when a symbol has no prefix on certain platforms.
|
|
126
|
-
*
|
|
127
|
-
* Does not suppress the link — combine with `exclude` to suppress entirely.
|
|
128
|
-
*/
|
|
129
|
-
excludePrefixFor?: string;
|
|
130
|
-
|
|
131
58
|
};
|
|
132
59
|
|
|
133
60
|
type Props = SassProps | TypeDocProps;
|
|
134
61
|
|
|
135
|
-
const KIND_SEGMENT: Record<Exclude<ApiKind, 'sass'>, string> = {
|
|
136
|
-
class: 'classes',
|
|
137
|
-
interface: 'interfaces',
|
|
138
|
-
enum: 'enums',
|
|
139
|
-
type: 'types',
|
|
140
|
-
variable: 'variables',
|
|
141
|
-
function: 'functions',
|
|
142
|
-
};
|
|
143
|
-
|
|
144
62
|
const ctx = Astro.locals.platformContext as PlatformContext;
|
|
145
|
-
const {
|
|
63
|
+
const { prefix, apiPackages } = ctx;
|
|
146
64
|
const label = Astro.props.label;
|
|
147
65
|
|
|
148
|
-
|
|
66
|
+
function getIndexedDisplayName(resolvedName: string, displayBaseName: string, type: string, classSuffix?: string) {
|
|
67
|
+
if (resolvedName === type) return type;
|
|
68
|
+
if (classSuffix && resolvedName === `${type}${classSuffix}`) return type;
|
|
69
|
+
if (classSuffix && resolvedName === `${displayBaseName}${classSuffix}`) return type;
|
|
70
|
+
return displayBaseName;
|
|
71
|
+
}
|
|
149
72
|
|
|
150
73
|
let url: string;
|
|
151
74
|
let displayLabel: string;
|
|
152
75
|
let renderCode: boolean;
|
|
153
|
-
let
|
|
76
|
+
let renderLink = false;
|
|
154
77
|
|
|
155
78
|
if (Astro.props.kind === 'sass') {
|
|
156
79
|
const { type, module, code = true } = Astro.props;
|
|
157
|
-
if (!module) console.warn('[ApiLink] kind="sass" requires a `module` prop
|
|
80
|
+
if (!module) console.warn('[ApiLink] kind="sass" requires a `module` prop - link may be malformed.');
|
|
158
81
|
const base = ctx.sassApiUrl?.trim().replace(/\/+$/, '');
|
|
159
82
|
const anchor = type ? `#${type}` : '';
|
|
160
83
|
if (!base) {
|
|
161
|
-
console.warn('[ApiLink] kind="sass" requires `platformContext.sassApiUrl` to be configured
|
|
84
|
+
console.warn('[ApiLink] kind="sass" requires `platformContext.sassApiUrl` to be configured - falling back to "#".');
|
|
162
85
|
url = '#';
|
|
163
86
|
} else {
|
|
164
87
|
url = `${base}/${module ?? ''}${anchor}`;
|
|
165
88
|
}
|
|
166
89
|
displayLabel = label ?? type ?? module ?? '';
|
|
167
90
|
renderCode = code;
|
|
91
|
+
renderLink = true;
|
|
168
92
|
} else {
|
|
169
93
|
const {
|
|
170
|
-
type,
|
|
171
|
-
|
|
172
|
-
|
|
94
|
+
type,
|
|
95
|
+
member,
|
|
96
|
+
pkg = 'core',
|
|
97
|
+
prefixed = true,
|
|
98
|
+
suffix = true,
|
|
173
99
|
} = Astro.props;
|
|
174
|
-
|
|
175
|
-
const isSuffixExcluded = splitList(excludeSuffixFor).includes(platformName);
|
|
176
|
-
const isPrefixExcluded = splitList(excludePrefixFor).includes(platformName);
|
|
177
|
-
const effectivePrefixed = prefixed && !isPrefixExcluded;
|
|
178
|
-
const effectiveSuffix = suffix && !isSuffixExcluded;
|
|
100
|
+
const explicitKind = 'kind' in Astro.props ? Astro.props.kind : undefined;
|
|
179
101
|
|
|
180
|
-
const
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
? `#${pkgConfig.pascalCaseMembers ? member.charAt(0).toUpperCase() + member.slice(1) : member}`
|
|
191
|
-
: '';
|
|
192
|
-
url = `${pkgConfig.docRoot}/classes/${classSlug}${memberAnchor}`;
|
|
193
|
-
} else {
|
|
194
|
-
const slug = pkgConfig.noPackagePrefix
|
|
195
|
-
? baseType
|
|
196
|
-
: `${pkgConfig.packageId}.${baseType}`;
|
|
197
|
-
const memberAnchorNonClass = member
|
|
198
|
-
? `#${
|
|
199
|
-
kind === 'enum'
|
|
200
|
-
? member
|
|
201
|
-
: pkgConfig.pascalCaseMembers
|
|
202
|
-
? member.charAt(0).toUpperCase() + member.slice(1)
|
|
203
|
-
: member.toLowerCase()
|
|
204
|
-
}`
|
|
205
|
-
: '';
|
|
206
|
-
url = `${pkgConfig.docRoot}/${segment}/${slug}${memberAnchorNonClass}`;
|
|
207
|
-
}
|
|
102
|
+
const effectivePrefixed = prefixed;
|
|
103
|
+
const effectiveSuffix = suffix;
|
|
104
|
+
|
|
105
|
+
// pkg is an ambiguity override. Without an explicit pkg prop, search the
|
|
106
|
+
// combined api-docs index so symbols can resolve from any package.
|
|
107
|
+
const explicitPkg = typeof Astro.props.pkg === 'string' && Astro.props.pkg.length > 0;
|
|
108
|
+
const pkgConfig = apiPackages[explicitPkg ? pkg : 'core'] ?? apiPackages.core;
|
|
109
|
+
const baseType = effectivePrefixed ? `${prefix}${type}` : type;
|
|
110
|
+
|
|
111
|
+
url = '';
|
|
208
112
|
displayLabel = label ?? (member ? `${baseType}.${member}` : baseType);
|
|
209
113
|
renderCode = true;
|
|
114
|
+
|
|
115
|
+
const indexed = resolveApiLinkFromIndex({
|
|
116
|
+
ctx,
|
|
117
|
+
pkgConfig,
|
|
118
|
+
explicitPkg,
|
|
119
|
+
type,
|
|
120
|
+
member,
|
|
121
|
+
explicitKind,
|
|
122
|
+
prefix,
|
|
123
|
+
prefixed: effectivePrefixed,
|
|
124
|
+
suffix: effectiveSuffix,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
if (indexed.status === 'resolved') {
|
|
128
|
+
url = indexed.url;
|
|
129
|
+
renderLink = true;
|
|
130
|
+
const indexedDisplay = getIndexedDisplayName(indexed.symbolName, baseType, type, pkgConfig.classSuffix);
|
|
131
|
+
displayLabel = label ?? (indexed.memberName ? `${indexedDisplay}.${indexed.memberName}` : indexedDisplay);
|
|
132
|
+
} else if (indexed.status === 'ambiguous') {
|
|
133
|
+
const symbol = member ? `${type}.${member}` : type;
|
|
134
|
+
throw new Error(`[ApiLink] Ambiguous API symbol "${symbol}" matched registry candidate "${indexed.candidate}". Add pkg= or kind= to disambiguate.`);
|
|
135
|
+
} else if (indexed.status === 'member-missing') {
|
|
136
|
+
renderLink = false;
|
|
137
|
+
if (import.meta.env.DEV) {
|
|
138
|
+
console.warn(`[ApiLink] Registry symbol "${indexed.candidate}" exists, but member "${member}" was not found. Rendering code text instead of a guessed URL.`);
|
|
139
|
+
}
|
|
140
|
+
} else if (indexed.status === 'missing') {
|
|
141
|
+
renderLink = false;
|
|
142
|
+
if (import.meta.env.DEV) {
|
|
143
|
+
console.warn(`[ApiLink] Registry miss for ${type}${member ? `.${member}` : ''}. Rendering code text instead of a guessed URL.`);
|
|
144
|
+
}
|
|
145
|
+
} else if (indexed.status === 'unavailable') {
|
|
146
|
+
renderLink = false;
|
|
147
|
+
if (import.meta.env.DEV) {
|
|
148
|
+
console.warn(`[ApiLink] ApiLink registry is unavailable for ${type}${member ? `.${member}` : ''}. Rendering code text.`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
210
151
|
}
|
|
211
152
|
---
|
|
212
|
-
{
|
|
213
|
-
? <code>{displayLabel}</code>
|
|
214
|
-
:
|
|
153
|
+
{renderLink
|
|
154
|
+
? <a href={url}>{renderCode ? <code>{displayLabel}</code> : displayLabel}</a>
|
|
155
|
+
: renderCode ? <code>{displayLabel}</code> : displayLabel}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
# ApiLink
|
|
2
2
|
|
|
3
|
-
Renders an inline API link with platform-aware
|
|
3
|
+
Renders an inline API documentation link with platform-aware resolution.
|
|
4
4
|
|
|
5
|
-
For TypeDoc symbols,
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
For TypeDoc symbols, `ApiLink` first queries the generated api-docs link index.
|
|
6
|
+
That index contains the real symbol names, packages, URL segments, and member
|
|
7
|
+
anchors produced by api-docs. If the index is unavailable, or if a symbol is
|
|
8
|
+
missing from it, `ApiLink` renders plain code text instead of generating a
|
|
9
|
+
guessed URL.
|
|
10
|
+
|
|
11
|
+
Sass links are separate and still use `kind="sass"`.
|
|
8
12
|
|
|
9
13
|
## Import
|
|
10
14
|
|
|
@@ -12,101 +16,99 @@ links when `kind="sass"`.
|
|
|
12
16
|
import ApiLink from 'igniteui-astro-components/components/mdx/ApiLink.astro';
|
|
13
17
|
```
|
|
14
18
|
|
|
15
|
-
##
|
|
19
|
+
## Preferred Usage
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
| `prefixed` | `boolean` | `true` | When `true`, prepends the platform prefix (`Igr`/`Igx`/`Igc`/`Igb`) to `type`. Set `false` for already-qualified names or non-prefixed symbols like function names. |
|
|
25
|
-
| `suffix` | `boolean` | `true` | When `true`, appends the platform class suffix (e.g. `Component` for Angular). Set `false` for utility classes that do not carry a suffix. |
|
|
26
|
-
| `exclude` | `string` | — | Comma-separated platform names where the link should not render. Matching platforms render the label as plain inline `<code>`. |
|
|
27
|
-
| `excludeSuffixFor` | `string` | — | Comma-separated platform names where `classSuffix` should not be appended, even when `suffix` is `true`. |
|
|
28
|
-
| `excludePrefixFor` | `string` | — | Comma-separated platform names where the platform prefix should not be prepended, even when `prefixed` is `true`. |
|
|
21
|
+
Author MDX with the unprefixed API name:
|
|
22
|
+
|
|
23
|
+
```mdx
|
|
24
|
+
<ApiLink type="Grid" />
|
|
25
|
+
<ApiLink type="Grid" member="rowSelection" />
|
|
26
|
+
<ApiLink type="CategoryChart" />
|
|
27
|
+
```
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
The resolver handles platform prefix/suffix candidates, package lookup, kind
|
|
30
|
+
lookup, URL segment lookup, and member anchor lookup.
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
Omitting `pkg` relies on `platformContext.apiLinkIndex` being available. When
|
|
33
|
+
the index is unavailable, `ApiLink` renders code text and does not guess a URL.
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
from `platformContext.sassApiUrl`.
|
|
35
|
+
## TypeDoc Props
|
|
37
36
|
|
|
38
37
|
| Prop | Type | Default | Description |
|
|
39
38
|
|------|------|---------|-------------|
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
39
|
+
| `type` | `string` | *(required)* | Short symbol name without platform prefix, e.g. `"Grid"` instead of `"IgrGrid"`. |
|
|
40
|
+
| `member` | `string` | — | Optional member name. Resolved through the generated member map when available. |
|
|
41
|
+
| `label` | `string` | auto | Override the display text. |
|
|
42
|
+
| `pkg` | `string` | — | Ambiguity override only. Use when the same symbol exists in multiple packages and the combined index cannot choose safely. |
|
|
43
|
+
| `kind` | `'class' \| 'interface' \| 'enum' \| 'type' \| 'variable' \| 'function'` | auto | Optional narrowing. Usually unnecessary when the index is available. |
|
|
44
|
+
| `prefixed` | `boolean` | `true` | Candidate-name override for symbols that are never platform-prefixed. Avoid for new docs when the index can resolve the symbol. |
|
|
45
|
+
| `suffix` | `boolean` | `true` | Candidate-name override for symbols that never use the platform class suffix. Avoid for new docs when the index can resolve the symbol. |
|
|
46
|
+
|
|
47
|
+
Platform names use `PlatformContext.name`: `Angular`, `React`,
|
|
48
|
+
`WebComponents`, or `Blazor`.
|
|
45
49
|
|
|
46
50
|
## Examples
|
|
47
51
|
|
|
48
52
|
```mdx
|
|
49
|
-
{/*
|
|
50
|
-
<ApiLink type="
|
|
51
|
-
{/* → <a href="…/classes/igniteui-react.igrtoast.html"><code>IgrToast</code></a> */}
|
|
53
|
+
{/* Let the generated index find package, kind, and exact symbol name. */}
|
|
54
|
+
<ApiLink type="Grid" />
|
|
52
55
|
|
|
53
|
-
{/*
|
|
54
|
-
<ApiLink type="
|
|
56
|
+
{/* Member anchors are resolved from the generated member map. */}
|
|
57
|
+
<ApiLink type="Grid" member="rowSelection" />
|
|
55
58
|
|
|
56
|
-
{/*
|
|
57
|
-
<ApiLink
|
|
59
|
+
{/* Use pkg only when the symbol name is ambiguous across packages. */}
|
|
60
|
+
<ApiLink type="Workbook" pkg="excel" />
|
|
61
|
+
```
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
<ApiLink kind="function" type="configureTheme" prefixed={false} />
|
|
63
|
+
## ApiLink Index
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
`ApiLink` resolves TypeDoc symbols from `platformContext.apiLinkIndex`, a compact
|
|
66
|
+
registry generated from api-docs TypeDoc data and stored by the docs host. The
|
|
67
|
+
component does not fetch api-docs during the documentation build.
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
<ApiLink kind="interface" type="ComboTemplateProps" prefixed={false} />
|
|
69
|
+
The docs host loads one latest registry per platform, for example:
|
|
67
70
|
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
```txt
|
|
72
|
+
src/data/api-link-index/angular/staging-latest.json
|
|
73
|
+
src/data/api-link-index/webcomponents/staging-latest.json
|
|
74
|
+
```
|
|
70
75
|
|
|
71
|
-
|
|
72
|
-
<ApiLink type="SortingStrategy" suffix={false} />
|
|
76
|
+
Registry symbol fields are intentionally short because the files are large:
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
| Field | Meaning |
|
|
79
|
+
|-------|---------|
|
|
80
|
+
| `p` | Package id that owns the symbol. |
|
|
81
|
+
| `u` | Root-relative API URL path for the symbol page. |
|
|
82
|
+
| `k` | Symbol kind, e.g. `class`, `interface`, `enum`, `type`. |
|
|
83
|
+
| `m` | Member name to anchor map. |
|
|
76
84
|
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
When `pkg` is present, `ApiLink` uses it only as a package filter for ambiguous
|
|
86
|
+
symbol names; package URLs and kinds still come from the registry.
|
|
87
|
+
When a symbol is ambiguous, omitting `pkg` or `kind` causes `ApiLink` to throw
|
|
88
|
+
during rendering instead of guessing a URL.
|
|
89
|
+
When a symbol is not found, `ApiLink` renders code text instead of generating a
|
|
90
|
+
guessed URL.
|
|
91
|
+
When a registry symbol exists but the requested member does not, `ApiLink`
|
|
92
|
+
renders code text instead of generating a guessed member URL.
|
|
79
93
|
|
|
80
|
-
|
|
81
|
-
|
|
94
|
+
## Sass Props
|
|
95
|
+
Use `kind="sass"` for Sass API reference links. Sass links do not use the
|
|
96
|
+
api-docs link index; they read their base URL from `platformContext.sassApiUrl`.
|
|
82
97
|
|
|
83
|
-
|
|
84
|
-
|
|
98
|
+
| Prop | Type | Default | Description |
|
|
99
|
+
|------|------|---------|-------------|
|
|
100
|
+
| `kind` | `'sass'` | *(required)* | Enables Sass API link mode. |
|
|
101
|
+
| `module` | `string` | — | Sass module path segment, e.g. `"animations"` or `"themes"`. |
|
|
102
|
+
| `type` | `string` | — | Anchor fragment without `#`, e.g. `"mixin-slide-in-left"`. Omit it to link to the module page. |
|
|
103
|
+
| `label` | `string` | auto | Override the display text. Defaults to `type`, then `module`, then an empty string. |
|
|
104
|
+
| `code` | `boolean` | `true` | Wrap the label in `<code>`. Set `false` for prose labels. |
|
|
85
105
|
|
|
86
|
-
|
|
106
|
+
```mdx
|
|
107
|
+
<ApiLink kind="sass" module="animations" label="animations Sass module" code={false} />
|
|
87
108
|
<ApiLink kind="sass" module="animations" type="mixin-slide-in-left" label="slide-in-left" />
|
|
88
109
|
```
|
|
89
110
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
The current platform is read from the `PLATFORM` environment variable (set at build time). Use `siteMetaIntegration({ platform })` or `createDocsSite({ platform })` in `astro.config.ts`:
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
createDocsSite({ platform: 'react' });
|
|
96
|
-
// prefix → 'Igr', docRoot → 'https://www.infragistics.com/products/ignite-ui-react/docs/typescript/latest'
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Supported platforms and their prefixes:
|
|
100
|
-
|
|
101
|
-
| Platform | Prefix | Class suffix |
|
|
102
|
-
|----------|--------|--------------|
|
|
103
|
-
| `Angular` | `Igx` | `Component` (DV pkgs only) |
|
|
104
|
-
| `React` | `Igr` | — |
|
|
105
|
-
| `WebComponents` | `Igc` | — |
|
|
106
|
-
| `Blazor` | `Igb` | — |
|
|
107
|
-
|
|
108
|
-
For Sass links, make sure `platformContext.sassApiUrl` is configured. The URL is
|
|
109
|
-
assembled as:
|
|
111
|
+
Sass URL shape:
|
|
110
112
|
|
|
111
113
|
```txt
|
|
112
114
|
{sassApiUrl}/{module}#{type}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import type { ApiPackageConfig, PlatformContext } from '../../../lib/types';
|
|
2
|
+
|
|
3
|
+
export type ApiKind = 'class' | 'interface' | 'enum' | 'type' | 'variable' | 'function' | 'sass';
|
|
4
|
+
export type TypeDocKind = Exclude<ApiKind, 'sass'>;
|
|
5
|
+
|
|
6
|
+
export const KIND_SEGMENT: Record<TypeDocKind, string> = {
|
|
7
|
+
class: 'classes',
|
|
8
|
+
interface: 'interfaces',
|
|
9
|
+
enum: 'enums',
|
|
10
|
+
type: 'types',
|
|
11
|
+
variable: 'variables',
|
|
12
|
+
function: 'functions',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type ApiLinkIndexSymbol = {
|
|
16
|
+
/** Package id. */
|
|
17
|
+
p?: string;
|
|
18
|
+
/** URL. */
|
|
19
|
+
u: string;
|
|
20
|
+
/** Kind. */
|
|
21
|
+
k?: TypeDocKind;
|
|
22
|
+
/** Member name to anchor map. */
|
|
23
|
+
m?: Record<string, string>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type ApiLinkIndexFile = {
|
|
27
|
+
symbols?: Record<string, ApiLinkIndexSymbol | ApiLinkIndexSymbol[]>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type ApiLinkIndexResolution =
|
|
31
|
+
| { status: 'resolved'; url: string; symbolName: string; memberName: string; memberAnchor: string }
|
|
32
|
+
| { status: 'ambiguous'; candidate: string }
|
|
33
|
+
| { status: 'member-missing'; candidate: string }
|
|
34
|
+
| { status: 'missing' }
|
|
35
|
+
| { status: 'unavailable' };
|
|
36
|
+
|
|
37
|
+
const upperFirst = (value: string) => value ? value.charAt(0).toUpperCase() + value.slice(1) : value;
|
|
38
|
+
|
|
39
|
+
function buildCandidateNames(options: {
|
|
40
|
+
type: string;
|
|
41
|
+
explicitKind?: TypeDocKind;
|
|
42
|
+
prefix: string;
|
|
43
|
+
prefixed: boolean;
|
|
44
|
+
suffix: boolean;
|
|
45
|
+
classSuffix?: string;
|
|
46
|
+
}): string[] {
|
|
47
|
+
const candidates = new Set<string>();
|
|
48
|
+
const baseNames = new Set<string>();
|
|
49
|
+
|
|
50
|
+
if (options.prefixed) baseNames.add(`${options.prefix}${options.type}`);
|
|
51
|
+
baseNames.add(options.type);
|
|
52
|
+
|
|
53
|
+
for (const baseName of baseNames) {
|
|
54
|
+
if ((!options.explicitKind || options.explicitKind === 'class') && options.suffix && options.classSuffix) {
|
|
55
|
+
candidates.add(`${baseName}${options.classSuffix}`);
|
|
56
|
+
}
|
|
57
|
+
candidates.add(baseName);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return [...candidates];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function resolveIndexedMember(symbol: ApiLinkIndexSymbol, member: string | undefined): { memberName: string; memberAnchor: string } | null {
|
|
64
|
+
if (!member) return { memberName: '', memberAnchor: '' };
|
|
65
|
+
|
|
66
|
+
const members = symbol.m ?? {};
|
|
67
|
+
const candidates = new Set([member, upperFirst(member), member.toLowerCase()]);
|
|
68
|
+
|
|
69
|
+
for (const candidate of candidates) {
|
|
70
|
+
if (Object.hasOwn(members, candidate)) {
|
|
71
|
+
return { memberName: candidate, memberAnchor: members[candidate] };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const normalized = member.toLowerCase();
|
|
76
|
+
for (const [registryMember, memberAnchor] of Object.entries(members)) {
|
|
77
|
+
if (registryMember.toLowerCase() === normalized) {
|
|
78
|
+
return { memberName: registryMember, memberAnchor };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function findIndexedSymbol(options: {
|
|
86
|
+
index: ApiLinkIndexFile;
|
|
87
|
+
candidates: string[];
|
|
88
|
+
packageId?: string;
|
|
89
|
+
explicitKind?: TypeDocKind;
|
|
90
|
+
member?: string;
|
|
91
|
+
}): { name: string; symbol: ApiLinkIndexSymbol; memberName: string; memberAnchor: string } | { ambiguous: true; candidate: string } | { memberMissing: true; candidate: string } | null {
|
|
92
|
+
const symbols = options.index.symbols ?? {};
|
|
93
|
+
let ambiguity: { ambiguous: true; candidate: string } | null = null;
|
|
94
|
+
let memberMissing: { memberMissing: true; candidate: string } | null = null;
|
|
95
|
+
|
|
96
|
+
for (const name of options.candidates) {
|
|
97
|
+
const value = symbols[name];
|
|
98
|
+
if (!value) continue;
|
|
99
|
+
|
|
100
|
+
const symbolList = Array.isArray(value) ? value : [value];
|
|
101
|
+
const matches = new Map<string, {
|
|
102
|
+
name: string;
|
|
103
|
+
symbol: ApiLinkIndexSymbol;
|
|
104
|
+
memberName: string;
|
|
105
|
+
memberAnchor: string;
|
|
106
|
+
}>();
|
|
107
|
+
let matchedSymbol = false;
|
|
108
|
+
|
|
109
|
+
for (const symbol of symbolList) {
|
|
110
|
+
if (options.packageId && symbol.p !== options.packageId) continue;
|
|
111
|
+
if (options.explicitKind && symbol.k !== options.explicitKind) continue;
|
|
112
|
+
matchedSymbol = true;
|
|
113
|
+
const memberMatch = resolveIndexedMember(symbol, options.member);
|
|
114
|
+
if (memberMatch === null) continue;
|
|
115
|
+
|
|
116
|
+
const key = `${symbol.u}#${memberMatch.memberAnchor}`;
|
|
117
|
+
matches.set(key, {
|
|
118
|
+
name,
|
|
119
|
+
symbol,
|
|
120
|
+
memberName: memberMatch.memberName,
|
|
121
|
+
memberAnchor: memberMatch.memberAnchor,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (matches.size === 1) {
|
|
126
|
+
return matches.values().next().value!;
|
|
127
|
+
}
|
|
128
|
+
if (matches.size > 1 && !ambiguity) {
|
|
129
|
+
ambiguity = { ambiguous: true, candidate: name };
|
|
130
|
+
}
|
|
131
|
+
if (matches.size === 0 && matchedSymbol && options.member && !memberMissing) {
|
|
132
|
+
memberMissing = { memberMissing: true, candidate: name };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return ambiguity ?? memberMissing;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function absolutizeIndexUrl(indexedPath: string, docRoot: string): string {
|
|
140
|
+
if (!indexedPath.startsWith('/')) return indexedPath;
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
return `${new URL(docRoot).origin}${indexedPath}`;
|
|
144
|
+
} catch {
|
|
145
|
+
return indexedPath;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function getCandidateClassSuffixes(options: {
|
|
150
|
+
ctx: PlatformContext;
|
|
151
|
+
explicitPkg: boolean;
|
|
152
|
+
pkgConfig: ApiPackageConfig;
|
|
153
|
+
}): Array<string | undefined> {
|
|
154
|
+
if (options.explicitPkg) {
|
|
155
|
+
return [options.pkgConfig.classSuffix];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const suffixes = new Set<string | undefined>();
|
|
159
|
+
for (const pkg of Object.values(options.ctx.apiPackages)) {
|
|
160
|
+
suffixes.add(pkg.classSuffix);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Put undefined (no suffix) last so suffixed names are tried first.
|
|
164
|
+
return [...suffixes].sort((a, b) => (a === undefined ? 1 : b === undefined ? -1 : 0));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function resolveApiLinkFromIndex(options: {
|
|
168
|
+
ctx: PlatformContext;
|
|
169
|
+
pkgConfig: ApiPackageConfig;
|
|
170
|
+
explicitPkg: boolean;
|
|
171
|
+
type: string;
|
|
172
|
+
member?: string;
|
|
173
|
+
explicitKind?: TypeDocKind;
|
|
174
|
+
prefix: string;
|
|
175
|
+
prefixed: boolean;
|
|
176
|
+
suffix: boolean;
|
|
177
|
+
}): ApiLinkIndexResolution {
|
|
178
|
+
const index = options.ctx.apiLinkIndex as ApiLinkIndexFile | undefined;
|
|
179
|
+
if (!index?.symbols) {
|
|
180
|
+
return { status: 'unavailable' };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const candidates = new Set<string>();
|
|
184
|
+
for (const classSuffix of getCandidateClassSuffixes(options)) {
|
|
185
|
+
for (const candidate of buildCandidateNames({
|
|
186
|
+
type: options.type,
|
|
187
|
+
explicitKind: options.explicitKind,
|
|
188
|
+
prefix: options.prefix,
|
|
189
|
+
prefixed: options.prefixed,
|
|
190
|
+
suffix: options.suffix,
|
|
191
|
+
classSuffix,
|
|
192
|
+
})) {
|
|
193
|
+
candidates.add(candidate);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const indexed = findIndexedSymbol({
|
|
198
|
+
index,
|
|
199
|
+
candidates: [...candidates],
|
|
200
|
+
packageId: options.explicitPkg ? options.pkgConfig.packageId : undefined,
|
|
201
|
+
explicitKind: options.explicitKind,
|
|
202
|
+
member: options.member,
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
if (!indexed) return { status: 'missing' };
|
|
206
|
+
if ('ambiguous' in indexed) return { status: 'ambiguous', candidate: indexed.candidate };
|
|
207
|
+
if ('memberMissing' in indexed) return { status: 'member-missing', candidate: indexed.candidate };
|
|
208
|
+
|
|
209
|
+
// Use the resolved symbol's package docRoot when available, so cross-package
|
|
210
|
+
// symbols resolve against the correct origin rather than always core.
|
|
211
|
+
const resolvedDocRoot = (indexed.symbol.p
|
|
212
|
+
? Object.values(options.ctx.apiPackages).find(pkg => pkg.packageId === indexed.symbol.p)?.docRoot
|
|
213
|
+
: undefined) ?? options.pkgConfig.docRoot;
|
|
214
|
+
|
|
215
|
+
const path = `${indexed.symbol.u}${indexed.memberAnchor ? `#${indexed.memberAnchor}` : ''}`;
|
|
216
|
+
return {
|
|
217
|
+
status: 'resolved',
|
|
218
|
+
url: absolutizeIndexUrl(path, resolvedDocRoot),
|
|
219
|
+
symbolName: indexed.name,
|
|
220
|
+
memberName: indexed.memberName,
|
|
221
|
+
memberAnchor: indexed.memberAnchor,
|
|
222
|
+
};
|
|
223
|
+
}
|
package/src/lib/types.ts
CHANGED
|
@@ -4,9 +4,8 @@ export interface ApiPackageConfig {
|
|
|
4
4
|
/** TypeDoc documentation root URL (no trailing slash). */
|
|
5
5
|
docRoot: string;
|
|
6
6
|
/**
|
|
7
|
-
* Package identifier as it appears in the
|
|
8
|
-
*
|
|
9
|
-
* sub-packages use underscores ("igniteui_react_charts").
|
|
7
|
+
* Package identifier as it appears in the API docs registry and route,
|
|
8
|
+
* e.g. "igniteui-react" or "igniteui-react-charts".
|
|
10
9
|
*/
|
|
11
10
|
packageId: string;
|
|
12
11
|
/**
|
|
@@ -20,10 +19,9 @@ export interface ApiPackageConfig {
|
|
|
20
19
|
*/
|
|
21
20
|
preserveCase?: boolean;
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* Only applied when `prefixed={true}`.
|
|
22
|
+
* Preferred class-name suffix used by ApiLink. The generated registry tries
|
|
23
|
+
* both the suffixed and unsuffixed names, so this does not mean every API
|
|
24
|
+
* symbol is expected to have the suffix.
|
|
27
25
|
*/
|
|
28
26
|
classSuffix?: string;
|
|
29
27
|
/**
|
|
@@ -33,8 +31,24 @@ export interface ApiPackageConfig {
|
|
|
33
31
|
pascalCaseMembers?: boolean;
|
|
34
32
|
}
|
|
35
33
|
|
|
34
|
+
/** Compact ApiLink symbol entry as stored in the generated registry JSON. */
|
|
35
|
+
type ApiLinkIndexEntry = {
|
|
36
|
+
/** Package id that owns this symbol. */
|
|
37
|
+
p?: string;
|
|
38
|
+
/** Root-relative URL to the symbol page, e.g. "/api/react/igniteui-react/19.5/classes/IgrGrid". */
|
|
39
|
+
u: string;
|
|
40
|
+
/** Symbol kind, e.g. "class", "interface", "enum". */
|
|
41
|
+
k?: string;
|
|
42
|
+
/** Member name to anchor map, e.g. { rowSelection: "rowSelection" }. */
|
|
43
|
+
m?: Record<string, string>;
|
|
44
|
+
};
|
|
45
|
+
|
|
36
46
|
export interface PlatformContext {
|
|
37
47
|
name: PlatformName;
|
|
48
|
+
/** Optional compact ApiLink symbol index loaded by the docs host at build time. */
|
|
49
|
+
apiLinkIndex?: {
|
|
50
|
+
symbols?: Record<string, ApiLinkIndexEntry | ApiLinkIndexEntry[]>;
|
|
51
|
+
};
|
|
38
52
|
/** Lower-case slug used in URLs, e.g. "angular" */
|
|
39
53
|
lower: string;
|
|
40
54
|
/** Component class prefix, e.g. "Igx" / "Igr" / "Igc" / "Igb" */
|