shelving 1.206.1 → 1.208.0
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/extract/TypescriptExtractor.d.ts +1 -0
- package/extract/TypescriptExtractor.js +118 -39
- package/package.json +1 -1
- package/store/URLStore.d.ts +15 -0
- package/store/URLStore.js +20 -1
- package/ui/app/App.module.css +0 -55
- package/ui/docs/DirectoryCard.js +4 -1
- package/ui/docs/DirectoryCard.tsx +7 -4
- package/ui/docs/DocumentationCard.d.ts +1 -1
- package/ui/docs/DocumentationCard.js +6 -2
- package/ui/docs/DocumentationCard.tsx +14 -9
- package/ui/docs/DocumentationKind.d.ts +13 -0
- package/ui/docs/DocumentationKind.js +22 -0
- package/ui/docs/DocumentationKind.tsx +31 -0
- package/ui/docs/DocumentationPage.d.ts +3 -3
- package/ui/docs/DocumentationPage.js +6 -4
- package/ui/docs/DocumentationPage.tsx +56 -22
- package/ui/docs/FileCard.js +4 -1
- package/ui/docs/FileCard.tsx +7 -4
- package/ui/docs/index.d.ts +1 -2
- package/ui/docs/index.js +1 -2
- package/ui/docs/index.ts +1 -2
- package/ui/form/Button.d.ts +3 -2
- package/ui/form/Button.js +4 -2
- package/ui/form/Button.tsx +4 -2
- package/ui/form/Input.d.ts +6 -6
- package/ui/form/SubmitButton.js +1 -1
- package/ui/form/SubmitButton.tsx +1 -1
- package/ui/index.d.ts +1 -0
- package/ui/index.js +1 -0
- package/ui/index.ts +1 -0
- package/ui/menu/Menu.d.ts +6 -0
- package/ui/menu/Menu.js +7 -0
- package/ui/{tree/TreeMenu.module.css → menu/Menu.module.css} +18 -1
- package/ui/menu/Menu.tsx +16 -0
- package/ui/menu/MenuItem.d.ts +14 -0
- package/ui/menu/MenuItem.js +20 -0
- package/ui/menu/MenuItem.tsx +36 -0
- package/ui/menu/index.d.ts +2 -0
- package/ui/menu/index.js +2 -0
- package/ui/menu/index.ts +2 -0
- package/ui/misc/Color.d.ts +25 -0
- package/ui/misc/Color.js +7 -0
- package/ui/misc/Color.module.css +105 -0
- package/ui/misc/Color.tsx +32 -0
- package/ui/{notice → misc}/Status.d.ts +1 -1
- package/ui/{notice → misc}/Status.module.css +65 -0
- package/ui/{notice → misc}/Status.tsx +1 -1
- package/ui/{notice → misc}/StatusIcon.js +1 -1
- package/ui/{notice → misc}/StatusIcon.tsx +1 -1
- package/ui/misc/Tag.d.ts +23 -0
- package/ui/misc/Tag.js +18 -0
- package/ui/misc/Tag.module.css +29 -0
- package/ui/misc/Tag.tsx +38 -0
- package/ui/misc/index.d.ts +4 -1
- package/ui/misc/index.js +4 -1
- package/ui/misc/index.tsx +4 -1
- package/ui/notice/Message.d.ts +3 -2
- package/ui/notice/Message.js +3 -2
- package/ui/notice/Message.tsx +4 -2
- package/ui/notice/Notice.d.ts +3 -2
- package/ui/notice/Notice.js +5 -3
- package/ui/notice/Notice.tsx +6 -4
- package/ui/notice/NoticesStore.d.ts +1 -1
- package/ui/notice/NoticesStore.ts +1 -1
- package/ui/notice/index.d.ts +0 -2
- package/ui/notice/index.js +0 -2
- package/ui/notice/index.ts +0 -2
- package/ui/tree/TreeCards.d.ts +11 -4
- package/ui/tree/TreeCards.js +13 -7
- package/ui/tree/TreeCards.tsx +17 -8
- package/ui/tree/TreeMenu.d.ts +8 -6
- package/ui/tree/TreeMenu.js +5 -16
- package/ui/tree/TreeMenu.tsx +18 -19
- package/ui/tree/TreeMenuItem.d.ts +9 -0
- package/ui/tree/TreeMenuItem.js +12 -0
- package/ui/tree/TreeMenuItem.tsx +18 -0
- package/ui/tree/TreePage.d.ts +8 -5
- package/ui/tree/TreePage.js +13 -9
- package/ui/tree/TreePage.tsx +19 -9
- package/ui/tree/TreePathContext.d.ts +12 -0
- package/ui/tree/TreePathContext.js +18 -0
- package/ui/tree/TreePathContext.tsx +21 -0
- package/ui/tree/TreeRenderer.d.ts +28 -0
- package/ui/tree/TreeRenderer.js +41 -0
- package/ui/tree/TreeRenderer.tsx +73 -0
- package/ui/tree/index.d.ts +3 -0
- package/ui/tree/index.js +3 -0
- package/ui/tree/index.ts +3 -0
- package/ui/types.d.ts +15 -4
- package/ui/util/css.d.ts +5 -4
- package/ui/util/css.js +6 -4
- package/ui/util/css.ts +6 -5
- package/ui/util/notice.d.ts +1 -1
- package/ui/util/notice.ts +1 -1
- package/util/element.d.ts +35 -7
- package/util/element.js +10 -5
- package/util/string.d.ts +11 -5
- package/util/string.js +24 -12
- package/util/url.d.ts +19 -0
- package/util/url.js +23 -0
- package/util/xml.js +1 -1
- package/ui/docs/DirectoryMenuItem.d.ts +0 -4
- package/ui/docs/DirectoryMenuItem.js +0 -5
- package/ui/docs/DirectoryMenuItem.tsx +0 -7
- package/ui/docs/FileMenuItem.d.ts +0 -4
- package/ui/docs/FileMenuItem.js +0 -5
- package/ui/docs/FileMenuItem.tsx +0 -7
- package/ui/misc/Mapper.d.ts +0 -35
- package/ui/misc/Mapper.js +0 -51
- package/ui/misc/Mapper.tsx +0 -78
- /package/ui/{notice → misc}/Status.js +0 -0
- /package/ui/{notice → misc}/StatusIcon.d.ts +0 -0
- /package/ui/{notice → misc}/StatusIcon.module.css +0 -0
|
@@ -4,6 +4,7 @@ import { FileExtractor } from "./FileExtractor.js";
|
|
|
4
4
|
* File extractor that parses a TypeScript source file into a tree element.
|
|
5
5
|
* - Uses the TypeScript compiler API to parse the AST.
|
|
6
6
|
* - Extracts exported, public, non-`_`-prefixed declarations as `tree-documentation` children.
|
|
7
|
+
* - Overloaded declarations sharing a name are merged into a single `tree-documentation` with multiple `signatures`.
|
|
7
8
|
* - Top-of-file JSDoc comment becomes the file's `content`.
|
|
8
9
|
* - Does not set `title` — TS source files have no confident title source. The renderer falls back to `name`.
|
|
9
10
|
*/
|
|
@@ -5,6 +5,7 @@ import { FileExtractor } from "./FileExtractor.js";
|
|
|
5
5
|
* File extractor that parses a TypeScript source file into a tree element.
|
|
6
6
|
* - Uses the TypeScript compiler API to parse the AST.
|
|
7
7
|
* - Extracts exported, public, non-`_`-prefixed declarations as `tree-documentation` children.
|
|
8
|
+
* - Overloaded declarations sharing a name are merged into a single `tree-documentation` with multiple `signatures`.
|
|
8
9
|
* - Top-of-file JSDoc comment becomes the file's `content`.
|
|
9
10
|
* - Does not set `title` — TS source files have no confident title source. The renderer falls back to `name`.
|
|
10
11
|
*/
|
|
@@ -12,17 +13,45 @@ export class TypescriptExtractor extends FileExtractor {
|
|
|
12
13
|
extractProps(name, text) {
|
|
13
14
|
const source = ts.createSourceFile(name, text, ts.ScriptTarget.Latest, true);
|
|
14
15
|
const content = _getFileDocComment(source);
|
|
15
|
-
|
|
16
|
+
// Collect elements by key, merging overloads (same name) by appending signatures.
|
|
17
|
+
const byKey = new Map();
|
|
16
18
|
for (const statement of source.statements) {
|
|
17
19
|
const element = _extractStatement(statement, source);
|
|
18
|
-
if (element)
|
|
19
|
-
|
|
20
|
+
if (!element)
|
|
21
|
+
continue;
|
|
22
|
+
const existing = byKey.get(element.key);
|
|
23
|
+
byKey.set(element.key, existing ? _mergeOverloads(existing, element) : element);
|
|
20
24
|
}
|
|
21
25
|
// No `title` — TS source files don't have a confident title source (the filename isn't one).
|
|
22
26
|
// The renderer falls back to `name` when displaying.
|
|
23
|
-
return { name, content, children };
|
|
27
|
+
return { name, content, children: Array.from(byKey.values()) };
|
|
24
28
|
}
|
|
25
29
|
}
|
|
30
|
+
/** Merge a newly-extracted overload into the existing documentation element with the same key. */
|
|
31
|
+
function _mergeOverloads(existing, next) {
|
|
32
|
+
const a = existing.props;
|
|
33
|
+
const b = next.props;
|
|
34
|
+
const merged = {
|
|
35
|
+
...a,
|
|
36
|
+
// Keep first description encountered; fill in if `existing` had none.
|
|
37
|
+
description: a.description ?? b.description,
|
|
38
|
+
// Append signatures.
|
|
39
|
+
signatures: _concat(a.signatures, b.signatures),
|
|
40
|
+
// Append params, returns, throws, examples — never dedupe (per spec).
|
|
41
|
+
params: _concat(a.params, b.params),
|
|
42
|
+
returns: _concat(a.returns, b.returns),
|
|
43
|
+
throws: _concat(a.throws, b.throws),
|
|
44
|
+
examples: _concat(a.examples, b.examples),
|
|
45
|
+
};
|
|
46
|
+
return { ...existing, props: merged };
|
|
47
|
+
}
|
|
48
|
+
function _concat(a, b) {
|
|
49
|
+
if (!a)
|
|
50
|
+
return b;
|
|
51
|
+
if (!b)
|
|
52
|
+
return a;
|
|
53
|
+
return [...a, ...b];
|
|
54
|
+
}
|
|
26
55
|
/** Get the leading JSDoc comment of the file (before the first statement). */
|
|
27
56
|
function _getFileDocComment(source) {
|
|
28
57
|
const { statements } = source;
|
|
@@ -57,8 +86,9 @@ function _extractStatement(statement, source) {
|
|
|
57
86
|
if (!kind)
|
|
58
87
|
return;
|
|
59
88
|
const signature = _getSignature(statement, source);
|
|
60
|
-
const params = _getParams(statement, source);
|
|
61
|
-
const returns =
|
|
89
|
+
const params = _getParams(statement, source, jsDoc?.params);
|
|
90
|
+
const returns = _getReturns(statement, source, jsDoc?.returns);
|
|
91
|
+
const throws = jsDoc?.throws;
|
|
62
92
|
const examples = jsDoc?.examples;
|
|
63
93
|
const children = _getClassMembers(statement, source);
|
|
64
94
|
return {
|
|
@@ -68,9 +98,10 @@ function _extractStatement(statement, source) {
|
|
|
68
98
|
name,
|
|
69
99
|
kind,
|
|
70
100
|
description: jsDoc?.description,
|
|
71
|
-
signature,
|
|
101
|
+
signatures: signature ? [signature] : undefined,
|
|
72
102
|
params,
|
|
73
103
|
returns,
|
|
104
|
+
throws,
|
|
74
105
|
examples,
|
|
75
106
|
children,
|
|
76
107
|
},
|
|
@@ -125,11 +156,10 @@ function _getSignature(statement, source) {
|
|
|
125
156
|
return declaration.type.getText(source);
|
|
126
157
|
}
|
|
127
158
|
}
|
|
128
|
-
/** Extract parameters from a function or method declaration. */
|
|
129
|
-
function _getParams(statement, source) {
|
|
159
|
+
/** Extract parameters from a function or method declaration, enriched with JSDoc `@param` descriptions. */
|
|
160
|
+
function _getParams(statement, source, jsDocParams) {
|
|
130
161
|
if (!ts.isFunctionDeclaration(statement))
|
|
131
162
|
return;
|
|
132
|
-
const jsDocParams = _getJSDoc(statement, source)?.params;
|
|
133
163
|
const params = statement.parameters.map(p => {
|
|
134
164
|
const name = p.name.getText(source);
|
|
135
165
|
const type = p.type?.getText(source);
|
|
@@ -139,10 +169,20 @@ function _getParams(statement, source) {
|
|
|
139
169
|
});
|
|
140
170
|
return params.length ? params : undefined;
|
|
141
171
|
}
|
|
142
|
-
/**
|
|
143
|
-
function
|
|
144
|
-
if (ts.isFunctionDeclaration(statement)
|
|
145
|
-
return
|
|
172
|
+
/** Extract return entries — combines the signature return type with any `@returns` descriptions. */
|
|
173
|
+
function _getReturns(statement, source, jsDocReturns) {
|
|
174
|
+
if (!ts.isFunctionDeclaration(statement))
|
|
175
|
+
return jsDocReturns;
|
|
176
|
+
const type = statement.type?.getText(source);
|
|
177
|
+
if (jsDocReturns?.length) {
|
|
178
|
+
// Merge: first entry gets the inferred type if it doesn't already have one.
|
|
179
|
+
const [first, ...rest] = jsDocReturns;
|
|
180
|
+
if (!first)
|
|
181
|
+
return jsDocReturns;
|
|
182
|
+
return [{ type: first.type ?? type, description: first.description }, ...rest];
|
|
183
|
+
}
|
|
184
|
+
if (type && type !== "void")
|
|
185
|
+
return [{ type }];
|
|
146
186
|
}
|
|
147
187
|
/** Extract class or interface members as child elements. */
|
|
148
188
|
function _getClassMembers(statement, source) {
|
|
@@ -163,27 +203,30 @@ function _getClassMembers(statement, source) {
|
|
|
163
203
|
if (ts.isMethodDeclaration(member) || ts.isMethodSignature(member)) {
|
|
164
204
|
const params = member.parameters.map(p => p.getText(source)).join(", ");
|
|
165
205
|
const ret = member.type ? member.type.getText(source) : "void";
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
}
|
|
206
|
+
const signature = `(${params}) => ${ret}`;
|
|
207
|
+
const key = requireSlug(name);
|
|
208
|
+
const existingIndex = members.findIndex(m => m.key === key);
|
|
209
|
+
const existing = members[existingIndex];
|
|
210
|
+
if (existing) {
|
|
211
|
+
members[existingIndex] = {
|
|
212
|
+
...existing,
|
|
213
|
+
props: { ...existing.props, signatures: _concat(existing.props.signatures, [signature]) },
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
members.push({
|
|
218
|
+
type: "tree-documentation",
|
|
219
|
+
key,
|
|
220
|
+
props: { name, description, kind: "method", signatures: [signature] },
|
|
221
|
+
});
|
|
222
|
+
}
|
|
176
223
|
}
|
|
177
224
|
else if (ts.isPropertyDeclaration(member) || ts.isPropertySignature(member)) {
|
|
225
|
+
const type = member.type?.getText(source);
|
|
178
226
|
members.push({
|
|
179
227
|
type: "tree-documentation",
|
|
180
228
|
key: requireSlug(name),
|
|
181
|
-
props: {
|
|
182
|
-
name,
|
|
183
|
-
description,
|
|
184
|
-
kind: "property",
|
|
185
|
-
signature: member.type?.getText(source),
|
|
186
|
-
},
|
|
229
|
+
props: { name, description, kind: "property", signatures: type ? [type] : undefined },
|
|
187
230
|
});
|
|
188
231
|
}
|
|
189
232
|
}
|
|
@@ -204,10 +247,14 @@ function _getJSDoc(node, source) {
|
|
|
204
247
|
continue;
|
|
205
248
|
const description = _parseJSDocComment(text);
|
|
206
249
|
const params = _parseJSDocParams(text);
|
|
250
|
+
const returns = _parseJSDocReturns(text);
|
|
251
|
+
const throws = _parseJSDocThrows(text);
|
|
207
252
|
const examples = _parseJSDocExamples(text);
|
|
208
253
|
return {
|
|
209
254
|
description: description || undefined,
|
|
210
255
|
params: params.length ? params : undefined,
|
|
256
|
+
returns: returns.length ? returns : undefined,
|
|
257
|
+
throws: throws.length ? throws : undefined,
|
|
211
258
|
examples: examples.length ? examples : undefined,
|
|
212
259
|
};
|
|
213
260
|
}
|
|
@@ -229,27 +276,59 @@ function _parseJSDocComment(text) {
|
|
|
229
276
|
const result = description.join("\n").trim();
|
|
230
277
|
return result || undefined;
|
|
231
278
|
}
|
|
232
|
-
/** Parse `@param` tags from a JSDoc comment. */
|
|
279
|
+
/** Parse `@param` tags from a JSDoc comment. Duplicates are kept (overloads). */
|
|
233
280
|
function _parseJSDocParams(text) {
|
|
234
281
|
const results = [];
|
|
235
|
-
|
|
282
|
+
// `@param {Type} name description` — type is optional.
|
|
283
|
+
const regexp = /@param\s+(?:\{([^}]*)\}\s+)?(\w+)\s+(.*)/g;
|
|
284
|
+
let match;
|
|
285
|
+
while ((match = regexp.exec(text))) {
|
|
286
|
+
const type = match[1]?.trim();
|
|
287
|
+
const name = match[2];
|
|
288
|
+
const description = match[3]?.trim();
|
|
289
|
+
if (name)
|
|
290
|
+
results.push({ name, type: type || undefined, description: description || undefined });
|
|
291
|
+
}
|
|
292
|
+
return results;
|
|
293
|
+
}
|
|
294
|
+
/** Parse `@returns` / `@return` tags from a JSDoc comment. */
|
|
295
|
+
function _parseJSDocReturns(text) {
|
|
296
|
+
const results = [];
|
|
297
|
+
// `@returns {Type} description` or `@return {Type} description`.
|
|
298
|
+
const regexp = /@returns?\s+(?:\{([^}]*)\}\s*)?(.*)/g;
|
|
299
|
+
let match;
|
|
300
|
+
while ((match = regexp.exec(text))) {
|
|
301
|
+
const type = match[1]?.trim();
|
|
302
|
+
const description = match[2]?.trim();
|
|
303
|
+
if (type || description)
|
|
304
|
+
results.push({ type: type || undefined, description: description || undefined });
|
|
305
|
+
}
|
|
306
|
+
return results;
|
|
307
|
+
}
|
|
308
|
+
/** Parse `@throws` / `@throw` tags from a JSDoc comment. */
|
|
309
|
+
function _parseJSDocThrows(text) {
|
|
310
|
+
const results = [];
|
|
311
|
+
// `@throws {Type} description` or `@throw {Type} description`.
|
|
312
|
+
const regexp = /@throws?\s+(?:\{([^}]*)\}\s*)?(.*)/g;
|
|
236
313
|
let match;
|
|
237
314
|
while ((match = regexp.exec(text))) {
|
|
238
|
-
const
|
|
239
|
-
const description = match[2];
|
|
240
|
-
if (
|
|
241
|
-
results.push({
|
|
315
|
+
const type = match[1]?.trim();
|
|
316
|
+
const description = match[2]?.trim();
|
|
317
|
+
if (type || description)
|
|
318
|
+
results.push({ type: type || undefined, description: description || undefined });
|
|
242
319
|
}
|
|
243
320
|
return results;
|
|
244
321
|
}
|
|
245
322
|
/** Parse `@example` tags from a JSDoc comment. */
|
|
246
323
|
function _parseJSDocExamples(text) {
|
|
247
324
|
const results = [];
|
|
248
|
-
|
|
325
|
+
// `@example` followed by the rest of the line.
|
|
326
|
+
const regexp = /@examples?\s+(.+)/g;
|
|
249
327
|
let match;
|
|
250
328
|
while ((match = regexp.exec(text))) {
|
|
251
|
-
|
|
252
|
-
|
|
329
|
+
const description = match[1]?.trim();
|
|
330
|
+
if (description)
|
|
331
|
+
results.push({ description });
|
|
253
332
|
}
|
|
254
333
|
return results;
|
|
255
334
|
}
|
package/package.json
CHANGED
package/store/URLStore.d.ts
CHANGED
|
@@ -47,5 +47,20 @@ export declare class URLStore extends BusyStore<ImmutableURL, PossibleURL> {
|
|
|
47
47
|
omitParams(...keys: string[]): ImmutableURL;
|
|
48
48
|
/** Return the current URL with an additional param. */
|
|
49
49
|
omitParam(key: string): ImmutableURL;
|
|
50
|
+
/**
|
|
51
|
+
* Is `target` active relative to this store's URL?
|
|
52
|
+
* - Active means `target` resolves to the exact same URL as this store's current value.
|
|
53
|
+
*
|
|
54
|
+
* @param target URL (or relative path resolved against this store's `base`) to test.
|
|
55
|
+
*/
|
|
56
|
+
isActive(target: PossibleURL): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Is `target` proud relative to this store's URL?
|
|
59
|
+
* - Proud means this store's URL is `target` or a descendant of `target` — i.e. `target` sits at or above the current URL in the hierarchy.
|
|
60
|
+
* - Useful for marking a menu item as "current branch" when the user is somewhere deeper in its sub-tree.
|
|
61
|
+
*
|
|
62
|
+
* @param target URL (or relative path resolved against this store's `base`) to test.
|
|
63
|
+
*/
|
|
64
|
+
isProud(target: PossibleURL): boolean;
|
|
50
65
|
toString(): string;
|
|
51
66
|
}
|
package/store/URLStore.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getGetter, getSetter } from "../util/class.js";
|
|
2
2
|
import { clearURIParams, getURIParam, getURIParams, omitURIParams, requireURIParam, withURIParam, withURIParams, } from "../util/uri.js";
|
|
3
|
-
import { getURL, requireURL } from "../util/url.js";
|
|
3
|
+
import { getURL, isURLActive, isURLProud, requireURL } from "../util/url.js";
|
|
4
4
|
import { BusyStore } from "./BusyStore.js";
|
|
5
5
|
/** Store a URL, e.g. `https://top.com/a/b/c` */
|
|
6
6
|
export class URLStore extends BusyStore {
|
|
@@ -105,6 +105,25 @@ export class URLStore extends BusyStore {
|
|
|
105
105
|
omitParam(key) {
|
|
106
106
|
return omitURIParams(this.value, key);
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Is `target` active relative to this store's URL?
|
|
110
|
+
* - Active means `target` resolves to the exact same URL as this store's current value.
|
|
111
|
+
*
|
|
112
|
+
* @param target URL (or relative path resolved against this store's `base`) to test.
|
|
113
|
+
*/
|
|
114
|
+
isActive(target) {
|
|
115
|
+
return isURLActive(this.value, requireURL(target, this.base, this.isActive));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Is `target` proud relative to this store's URL?
|
|
119
|
+
* - Proud means this store's URL is `target` or a descendant of `target` — i.e. `target` sits at or above the current URL in the hierarchy.
|
|
120
|
+
* - Useful for marking a menu item as "current branch" when the user is somewhere deeper in its sub-tree.
|
|
121
|
+
*
|
|
122
|
+
* @param target URL (or relative path resolved against this store's `base`) to test.
|
|
123
|
+
*/
|
|
124
|
+
isProud(target) {
|
|
125
|
+
return isURLProud(this.value, requireURL(target, this.base, this.isProud));
|
|
126
|
+
}
|
|
108
127
|
toString() {
|
|
109
128
|
return this.href;
|
|
110
129
|
}
|
package/ui/app/App.module.css
CHANGED
|
@@ -102,65 +102,10 @@
|
|
|
102
102
|
--shadow-element: 0 3px 16px -8px var(--color-overlay);
|
|
103
103
|
--shadow-block: 0 4px 24px -12px var(--color-overlay);
|
|
104
104
|
|
|
105
|
-
/* Primary colors */
|
|
106
|
-
--primary-text: var(--color-blue);
|
|
107
|
-
--primary-contrast: var(--color-white);
|
|
108
|
-
--primary-surface: color-mix(in srgb, var(--primary-text) 12%, white);
|
|
109
|
-
|
|
110
|
-
/* Secondary colors */
|
|
111
|
-
--secondary-text: var(--color-purple);
|
|
112
|
-
--secondary-contrast: var(--color-white);
|
|
113
|
-
--secondary-surface: color-mix(in srgb, var(--secondary-text) 12%, white);
|
|
114
|
-
|
|
115
|
-
/* Tertiary colors */
|
|
116
|
-
--tertiary-text: var(--color-cyan);
|
|
117
|
-
--tertiary-contrast: var(--color-white);
|
|
118
|
-
--tertiary-surface: color-mix(in srgb, var(--tertiary-text) 12%, white);
|
|
119
|
-
|
|
120
|
-
/* Quiet colors */
|
|
121
|
-
--quiet-text: var(--color-quiet);
|
|
122
|
-
--quiet-contrast: var(--color-contrast);
|
|
123
|
-
--quiet-surface: var(--color-surface);
|
|
124
|
-
|
|
125
105
|
/* Focus colors */
|
|
126
106
|
--focus-text: var(--color-focus);
|
|
127
107
|
--focus-contrast: var(--color-white);
|
|
128
108
|
--focus-surface: color-mix(in srgb, var(--focus-text) 12%, white);
|
|
129
|
-
|
|
130
|
-
/* Loading colors */
|
|
131
|
-
--loading-text: var(--color-loading);
|
|
132
|
-
--loading-contrast: var(--color-contrast);
|
|
133
|
-
--loading-surface: var(--color-surface);
|
|
134
|
-
|
|
135
|
-
/* Info colors */
|
|
136
|
-
--info-text: var(--color-blue);
|
|
137
|
-
--info-contrast: var(--color-white);
|
|
138
|
-
--info-surface: color-mix(in srgb, var(--info-text) 12%, white);
|
|
139
|
-
|
|
140
|
-
/* Success colors */
|
|
141
|
-
--success-text: var(--color-green);
|
|
142
|
-
--success-contrast: var(--color-white);
|
|
143
|
-
--success-surface: color-mix(in srgb, var(--success-text) 12%, white);
|
|
144
|
-
|
|
145
|
-
/* Warning colors */
|
|
146
|
-
--warning-text: var(--color-orange);
|
|
147
|
-
--warning-contrast: var(--color-white);
|
|
148
|
-
--warning-surface: color-mix(in srgb, var(--warning-text) 12%, white);
|
|
149
|
-
|
|
150
|
-
/* Error colors */
|
|
151
|
-
--error-text: var(--color-red);
|
|
152
|
-
--error-contrast: var(--color-white);
|
|
153
|
-
--error-surface: color-mix(in srgb, var(--error-text) 12%, white);
|
|
154
|
-
|
|
155
|
-
/* Danger colors */
|
|
156
|
-
--danger-text: var(--color-red);
|
|
157
|
-
--danger-contrast: var(--color-white);
|
|
158
|
-
--danger-surface: color-mix(in srgb, var(--danger-text) 12%, white);
|
|
159
|
-
|
|
160
|
-
/* Highlight colors */
|
|
161
|
-
--highlight-text: var(--color-yellow);
|
|
162
|
-
--highlight-contrast: var(--color-black);
|
|
163
|
-
--highlight-surface: color-mix(in srgb, var(--highlight-text) 12%, white);
|
|
164
109
|
}
|
|
165
110
|
|
|
166
111
|
.app {
|
package/ui/docs/DirectoryCard.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TREE_CARD_CLASS, TREE_CARD_DESCRIPTION_CLASS, TREE_CARD_TITLE_CLASS } from "../tree/TreeCards.js";
|
|
3
|
+
import { requireTreeHref } from "../tree/TreePathContext.js";
|
|
2
4
|
/** Card renderer for a `tree-directory` element. */
|
|
3
5
|
export function DirectoryCard({ title, name, description }) {
|
|
4
|
-
|
|
6
|
+
const href = requireTreeHref();
|
|
7
|
+
return (_jsxs("a", { className: TREE_CARD_CLASS, href: href, children: [_jsx("h3", { className: TREE_CARD_TITLE_CLASS, children: title ?? name }), description && _jsx("p", { className: TREE_CARD_DESCRIPTION_CLASS, children: description })] }));
|
|
5
8
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { DirectoryElementProps } from "../../util/element.js";
|
|
3
|
+
import { TREE_CARD_CLASS, TREE_CARD_DESCRIPTION_CLASS, TREE_CARD_TITLE_CLASS } from "../tree/TreeCards.js";
|
|
4
|
+
import { requireTreeHref } from "../tree/TreePathContext.js";
|
|
3
5
|
|
|
4
6
|
/** Card renderer for a `tree-directory` element. */
|
|
5
7
|
export function DirectoryCard({ title, name, description }: DirectoryElementProps): ReactNode {
|
|
8
|
+
const href = requireTreeHref();
|
|
6
9
|
return (
|
|
7
|
-
<
|
|
8
|
-
<h3>{title ?? name}</h3>
|
|
9
|
-
{description && <p>{description}</p>}
|
|
10
|
-
</
|
|
10
|
+
<a className={TREE_CARD_CLASS} href={href}>
|
|
11
|
+
<h3 className={TREE_CARD_TITLE_CLASS}>{title ?? name}</h3>
|
|
12
|
+
{description && <p className={TREE_CARD_DESCRIPTION_CLASS}>{description}</p>}
|
|
13
|
+
</a>
|
|
11
14
|
);
|
|
12
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { DocumentationElementProps } from "../../util/element.js";
|
|
3
3
|
/** Card renderer for a `tree-documentation` element. */
|
|
4
|
-
export declare function DocumentationCard({ title, name, description,
|
|
4
|
+
export declare function DocumentationCard({ title, name, kind, description, signatures }: DocumentationElementProps): ReactNode;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TREE_CARD_CLASS, TREE_CARD_DESCRIPTION_CLASS, TREE_CARD_TITLE_CLASS } from "../index.js";
|
|
3
|
+
import { requireTreeHref } from "../tree/TreePathContext.js";
|
|
4
|
+
import { DocumentationKind } from "./DocumentationKind.js";
|
|
2
5
|
/** Card renderer for a `tree-documentation` element. */
|
|
3
|
-
export function DocumentationCard({ title, name, description,
|
|
4
|
-
|
|
6
|
+
export function DocumentationCard({ title, name, kind, description, signatures }) {
|
|
7
|
+
const href = requireTreeHref();
|
|
8
|
+
return (_jsxs("a", { className: TREE_CARD_CLASS, href: href, children: [_jsx("h3", { className: TREE_CARD_TITLE_CLASS, children: _jsx("code", { children: title ?? name }) }), kind && _jsx(DocumentationKind, { kind: kind }), signatures?.map(sig => (_jsx("pre", { children: _jsx("code", { children: sig }) }, sig))), description && _jsx("p", { className: TREE_CARD_DESCRIPTION_CLASS, children: description })] }));
|
|
5
9
|
}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { DocumentationElementProps } from "../../util/element.js";
|
|
3
|
+
import { TREE_CARD_CLASS, TREE_CARD_DESCRIPTION_CLASS, TREE_CARD_TITLE_CLASS } from "../index.js";
|
|
4
|
+
import { requireTreeHref } from "../tree/TreePathContext.js";
|
|
5
|
+
import { DocumentationKind } from "./DocumentationKind.js";
|
|
3
6
|
|
|
4
7
|
/** Card renderer for a `tree-documentation` element. */
|
|
5
|
-
export function DocumentationCard({ title, name, description,
|
|
8
|
+
export function DocumentationCard({ title, name, kind, description, signatures }: DocumentationElementProps): ReactNode {
|
|
9
|
+
const href = requireTreeHref();
|
|
6
10
|
return (
|
|
7
|
-
<
|
|
8
|
-
<h3>
|
|
11
|
+
<a className={TREE_CARD_CLASS} href={href}>
|
|
12
|
+
<h3 className={TREE_CARD_TITLE_CLASS}>
|
|
9
13
|
<code>{title ?? name}</code>
|
|
10
14
|
</h3>
|
|
11
|
-
{
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
{kind && <DocumentationKind kind={kind} />}
|
|
16
|
+
{signatures?.map(sig => (
|
|
17
|
+
<pre key={sig}>
|
|
18
|
+
<code>{sig}</code>
|
|
14
19
|
</pre>
|
|
15
|
-
)}
|
|
16
|
-
{description && <p>{description}</p>}
|
|
17
|
-
</
|
|
20
|
+
))}
|
|
21
|
+
{description && <p className={TREE_CARD_DESCRIPTION_CLASS}>{description}</p>}
|
|
22
|
+
</a>
|
|
18
23
|
);
|
|
19
24
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
/** Props for `DocumentationKind`. */
|
|
3
|
+
export interface DocumentationKindProps {
|
|
4
|
+
/** The documentation kind (e.g. `"function"`, `"class"`, `"interface"`, `"type"`, `"constant"`, `"method"`, `"property"`). */
|
|
5
|
+
readonly kind: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Colour-coded tag for a documented symbol's kind.
|
|
9
|
+
* - Thin wrapper over `<Tag>` that maps the kind string to a raw colour variant.
|
|
10
|
+
*
|
|
11
|
+
* @example <DocumentationKind kind="function" />
|
|
12
|
+
*/
|
|
13
|
+
export declare function DocumentationKind({ kind }: DocumentationKindProps): ReactElement;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tag } from "../misc/Tag.js";
|
|
3
|
+
/** Mapping from a documented symbol's `kind` to its tag colour. */
|
|
4
|
+
const KIND_COLOR = {
|
|
5
|
+
function: "blue",
|
|
6
|
+
class: "purple",
|
|
7
|
+
interface: "cyan",
|
|
8
|
+
type: "pink",
|
|
9
|
+
constant: "green",
|
|
10
|
+
method: "orange",
|
|
11
|
+
property: "yellow",
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Colour-coded tag for a documented symbol's kind.
|
|
15
|
+
* - Thin wrapper over `<Tag>` that maps the kind string to a raw colour variant.
|
|
16
|
+
*
|
|
17
|
+
* @example <DocumentationKind kind="function" />
|
|
18
|
+
*/
|
|
19
|
+
export function DocumentationKind({ kind }) {
|
|
20
|
+
const color = KIND_COLOR[kind];
|
|
21
|
+
return _jsx(Tag, { ...(color ? { [color]: true } : {}), children: kind });
|
|
22
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { Color } from "../misc/Color.js";
|
|
3
|
+
import { Tag } from "../misc/Tag.js";
|
|
4
|
+
|
|
5
|
+
/** Props for `DocumentationKind`. */
|
|
6
|
+
export interface DocumentationKindProps {
|
|
7
|
+
/** The documentation kind (e.g. `"function"`, `"class"`, `"interface"`, `"type"`, `"constant"`, `"method"`, `"property"`). */
|
|
8
|
+
readonly kind: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Mapping from a documented symbol's `kind` to its tag colour. */
|
|
12
|
+
const KIND_COLOR: { readonly [K in string]?: Color } = {
|
|
13
|
+
function: "blue",
|
|
14
|
+
class: "purple",
|
|
15
|
+
interface: "cyan",
|
|
16
|
+
type: "pink",
|
|
17
|
+
constant: "green",
|
|
18
|
+
method: "orange",
|
|
19
|
+
property: "yellow",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Colour-coded tag for a documented symbol's kind.
|
|
24
|
+
* - Thin wrapper over `<Tag>` that maps the kind string to a raw colour variant.
|
|
25
|
+
*
|
|
26
|
+
* @example <DocumentationKind kind="function" />
|
|
27
|
+
*/
|
|
28
|
+
export function DocumentationKind({ kind }: DocumentationKindProps): ReactElement {
|
|
29
|
+
const color = KIND_COLOR[kind];
|
|
30
|
+
return <Tag {...(color ? { [color]: true } : {})}>{kind}</Tag>;
|
|
31
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import type { DocumentationElementProps } from "../../util/element.js";
|
|
3
3
|
/**
|
|
4
4
|
* Page renderer for a `tree-documentation` element.
|
|
5
|
-
* - Renders title,
|
|
6
|
-
* - All
|
|
5
|
+
* - Renders title, signatures (one per overload), description, parameters, returns, throws, examples, and child symbols.
|
|
6
|
+
* - All sections are conditional — only render when their array has entries.
|
|
7
7
|
*/
|
|
8
|
-
export declare function DocumentationPage({ title, name, description,
|
|
8
|
+
export declare function DocumentationPage({ title, name, kind, description, signatures, params, returns, throws, examples, children, }: DocumentationElementProps): ReactNode;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Page } from "../page/Page.js";
|
|
3
3
|
import { TreeCards } from "../tree/TreeCards.js";
|
|
4
|
+
import { DocumentationKind } from "./DocumentationKind.js";
|
|
5
|
+
const DEFAULT_TYPE = "unknown";
|
|
4
6
|
/**
|
|
5
7
|
* Page renderer for a `tree-documentation` element.
|
|
6
|
-
* - Renders title,
|
|
7
|
-
* - All
|
|
8
|
+
* - Renders title, signatures (one per overload), description, parameters, returns, throws, examples, and child symbols.
|
|
9
|
+
* - All sections are conditional — only render when their array has entries.
|
|
8
10
|
*/
|
|
9
|
-
export function DocumentationPage({ title, name, description,
|
|
10
|
-
return (_jsxs(Page, { title: title ?? name, children: [
|
|
11
|
+
export function DocumentationPage({ title, name, kind, description, signatures, params, returns, throws, examples, children, }) {
|
|
12
|
+
return (_jsxs(Page, { title: title ?? name, children: [kind && _jsx(DocumentationKind, { kind: kind }), signatures?.map(sig => (_jsx("pre", { children: _jsx("code", { children: sig }) }, sig))), description && _jsx("p", { children: description }), params?.length && (_jsxs("section", { children: [_jsx("h2", { children: "Parameters" }), _jsx("dl", { children: params.map(({ name, type = DEFAULT_TYPE, description = "", optional }) => (_jsxs("div", { children: [_jsxs("dt", { children: [_jsx("code", { children: name }), ": ", _jsx("code", { children: type ?? DEFAULT_TYPE }), optional && _jsx(_Fragment, { children: " (optional)" })] }), description && _jsx("dd", { children: description })] }, `${name}-${type}-${description}`))) })] })), returns?.length && (_jsxs("section", { children: [_jsx("h2", { children: "Returns" }), _jsx("dl", { children: returns.map(({ type = DEFAULT_TYPE, description = "" }) => (_jsxs("div", { children: [_jsx("dt", { children: _jsx("code", { children: type }) }), description && _jsx("dd", { children: description })] }, `${type}-${description}`))) })] })), throws?.length && (_jsxs("section", { children: [_jsx("h2", { children: "Throws" }), _jsx("dl", { children: throws.map(({ type = DEFAULT_TYPE, description = "" }) => (_jsxs("div", { children: [_jsx("dt", { children: _jsx("code", { children: type }) }), description && _jsx("dd", { children: description })] }, `${type}-${description}`))) })] })), examples?.length && (_jsxs("section", { children: [_jsx("h2", { children: "Examples" }), examples.map(({ description }) => (_jsx("pre", { children: _jsx("code", { children: description }) }, description)))] })), children && _jsx(TreeCards, { children: children })] }));
|
|
11
13
|
}
|