@openpkg-ts/sdk 0.49.0 → 0.50.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/dist/browser.d.ts +2 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +104 -40
- package/package.json +2 -2
package/dist/browser.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ interface HTMLOptions {
|
|
|
60
60
|
/** Exports to render (multi-mode) - overridden by `export` if both provided */
|
|
61
61
|
exports?: string[];
|
|
62
62
|
}
|
|
63
|
-
import { SpecExportKind } from "@openpkg-ts/spec";
|
|
63
|
+
import { SpecExportKind, SpecInlineTag } from "@openpkg-ts/spec";
|
|
64
64
|
interface JSONOptions {
|
|
65
65
|
/** Include raw spec data alongside simplified data */
|
|
66
66
|
includeRaw?: boolean;
|
|
@@ -115,6 +115,7 @@ interface SimplifiedExport {
|
|
|
115
115
|
tags: Array<{
|
|
116
116
|
name: string;
|
|
117
117
|
text: string;
|
|
118
|
+
inlineTags?: SpecInlineTag[];
|
|
118
119
|
}>;
|
|
119
120
|
parameters?: SimplifiedParameter[];
|
|
120
121
|
returns?: SimplifiedReturn;
|
package/dist/index.d.ts
CHANGED
|
@@ -276,7 +276,7 @@ interface HTMLOptions {
|
|
|
276
276
|
* ```
|
|
277
277
|
*/
|
|
278
278
|
declare function toHTML2(spec: OpenPkg3, options?: HTMLOptions): string;
|
|
279
|
-
import { OpenPkg as OpenPkg4, SpecExportKind } from "@openpkg-ts/spec";
|
|
279
|
+
import { OpenPkg as OpenPkg4, SpecExportKind, SpecInlineTag } from "@openpkg-ts/spec";
|
|
280
280
|
interface JSONOptions {
|
|
281
281
|
/** Include raw spec data alongside simplified data */
|
|
282
282
|
includeRaw?: boolean;
|
|
@@ -331,6 +331,7 @@ interface SimplifiedExport {
|
|
|
331
331
|
tags: Array<{
|
|
332
332
|
name: string;
|
|
333
333
|
text: string;
|
|
334
|
+
inlineTags?: SpecInlineTag[];
|
|
334
335
|
}>;
|
|
335
336
|
parameters?: SimplifiedParameter[];
|
|
336
337
|
returns?: SimplifiedReturn;
|
|
@@ -1271,12 +1272,13 @@ declare function resolveExportTarget(symbol: ts3.Symbol, checker: ts3.TypeChecke
|
|
|
1271
1272
|
targetSymbol: ts3.Symbol;
|
|
1272
1273
|
isTypeOnly: boolean;
|
|
1273
1274
|
};
|
|
1274
|
-
import { SpecExample, SpecExportKind as SpecExportKind8, SpecSource, SpecTag, SpecTypeParameter as SpecTypeParameter2 } from "@openpkg-ts/spec";
|
|
1275
|
+
import { SpecExample, SpecExportKind as SpecExportKind8, SpecInlineTag as SpecInlineTag2, SpecSource, SpecTag, SpecTypeParameter as SpecTypeParameter2 } from "@openpkg-ts/spec";
|
|
1275
1276
|
import ts4 from "typescript";
|
|
1276
1277
|
declare function getJSDocComment(node: ts4.Node, symbol?: ts4.Symbol, checker?: ts4.TypeChecker): {
|
|
1277
1278
|
description?: string;
|
|
1278
1279
|
tags: SpecTag[];
|
|
1279
1280
|
examples: SpecExample[];
|
|
1281
|
+
inlineTags?: SpecInlineTag2[];
|
|
1280
1282
|
};
|
|
1281
1283
|
declare function getSourceLocation(node: ts4.Node, sourceFile: ts4.SourceFile): SpecSource;
|
|
1282
1284
|
/**
|
package/dist/index.js
CHANGED
|
@@ -480,7 +480,11 @@ function simplifyExport(exp) {
|
|
|
480
480
|
signature: buildSignatureString(exp),
|
|
481
481
|
description: exp.description,
|
|
482
482
|
deprecated: exp.deprecated === true,
|
|
483
|
-
tags: (exp.tags || []).map((t) => ({
|
|
483
|
+
tags: (exp.tags || []).map((t) => ({
|
|
484
|
+
name: t.name,
|
|
485
|
+
text: t.text,
|
|
486
|
+
...t.inlineTags ? { inlineTags: t.inlineTags } : {}
|
|
487
|
+
})),
|
|
484
488
|
extends: exp.extends,
|
|
485
489
|
implements: exp.implements,
|
|
486
490
|
sourceFile: exp.source?.file,
|
|
@@ -1305,6 +1309,26 @@ import ts12 from "typescript";
|
|
|
1305
1309
|
// src/ast/utils.ts
|
|
1306
1310
|
import * as path2 from "node:path";
|
|
1307
1311
|
import ts from "typescript";
|
|
1312
|
+
var INLINE_TAG_RE = /(^|[^\\])\{@([a-zA-Z][a-zA-Z0-9]*)((?:[^}\\]|\\.)*)\}/g;
|
|
1313
|
+
function parseInlineTags(...texts) {
|
|
1314
|
+
const inlineTags = [];
|
|
1315
|
+
for (const text of texts) {
|
|
1316
|
+
if (!text || !text.includes("{@"))
|
|
1317
|
+
continue;
|
|
1318
|
+
INLINE_TAG_RE.lastIndex = 0;
|
|
1319
|
+
let match = INLINE_TAG_RE.exec(text);
|
|
1320
|
+
while (match) {
|
|
1321
|
+
inlineTags.push({ name: match[2], text: match[3].trim() });
|
|
1322
|
+
INLINE_TAG_RE.lastIndex -= 1;
|
|
1323
|
+
match = INLINE_TAG_RE.exec(text);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
return inlineTags.length > 0 ? inlineTags : undefined;
|
|
1327
|
+
}
|
|
1328
|
+
function withInlineTags(node, ...texts) {
|
|
1329
|
+
const inlineTags = parseInlineTags(...texts);
|
|
1330
|
+
return inlineTags ? { ...node, inlineTags } : node;
|
|
1331
|
+
}
|
|
1308
1332
|
function parseExamplesFromTags(tags) {
|
|
1309
1333
|
const examples = [];
|
|
1310
1334
|
for (const tag of tags) {
|
|
@@ -1319,9 +1343,9 @@ function parseExamplesFromTags(tags) {
|
|
|
1319
1343
|
if (lang && ["ts", "js", "tsx", "jsx", "shell", "json"].includes(lang)) {
|
|
1320
1344
|
example.language = lang;
|
|
1321
1345
|
}
|
|
1322
|
-
examples.push(example);
|
|
1346
|
+
examples.push(withInlineTags(example, example.code));
|
|
1323
1347
|
} else if (text) {
|
|
1324
|
-
examples.push({ code: text });
|
|
1348
|
+
examples.push(withInlineTags({ code: text }, text));
|
|
1325
1349
|
}
|
|
1326
1350
|
}
|
|
1327
1351
|
return examples;
|
|
@@ -1416,17 +1440,17 @@ function getJSDocComment(node, symbol, checker) {
|
|
|
1416
1440
|
param.description = description2;
|
|
1417
1441
|
if (paramTag.isBracketed)
|
|
1418
1442
|
param.optional = true;
|
|
1419
|
-
return { name: tag.tagName.text, text, param };
|
|
1443
|
+
return withInlineTags({ name: tag.tagName.text, text, param }, text);
|
|
1420
1444
|
}
|
|
1421
1445
|
if (tag.tagName.text === "typeParam") {
|
|
1422
1446
|
const text = stripTypeParamSeparator(rawText) ?? "";
|
|
1423
|
-
return { name: tag.tagName.text, text };
|
|
1447
|
+
return withInlineTags({ name: tag.tagName.text, text }, text);
|
|
1424
1448
|
}
|
|
1425
1449
|
if (tag.tagName.text === "see") {
|
|
1426
1450
|
const text = extractSeeTagText(tag);
|
|
1427
|
-
return { name: tag.tagName.text, text };
|
|
1451
|
+
return withInlineTags({ name: tag.tagName.text, text }, text);
|
|
1428
1452
|
}
|
|
1429
|
-
return { name: tag.tagName.text, text: rawText };
|
|
1453
|
+
return withInlineTags({ name: tag.tagName.text, text: rawText }, rawText);
|
|
1430
1454
|
});
|
|
1431
1455
|
const jsDocComments = ts.getJSDocCommentsAndTags(node).filter(ts.isJSDoc);
|
|
1432
1456
|
let description;
|
|
@@ -1444,7 +1468,7 @@ function getJSDocComment(node, symbol, checker) {
|
|
|
1444
1468
|
}
|
|
1445
1469
|
}
|
|
1446
1470
|
const examples = parseExamplesFromTags(tags);
|
|
1447
|
-
return { description, tags, examples };
|
|
1471
|
+
return { description, tags, examples, inlineTags: parseInlineTags(description) };
|
|
1448
1472
|
}
|
|
1449
1473
|
function getSourceLocation(node, sourceFile) {
|
|
1450
1474
|
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
@@ -2914,6 +2938,9 @@ function extractParameters(signature, ctx) {
|
|
|
2914
2938
|
};
|
|
2915
2939
|
if (description) {
|
|
2916
2940
|
paramResult.description = description;
|
|
2941
|
+
const inlineTags = parseInlineTags(description);
|
|
2942
|
+
if (inlineTags)
|
|
2943
|
+
paramResult.inlineTags = inlineTags;
|
|
2917
2944
|
}
|
|
2918
2945
|
if (decl.initializer) {
|
|
2919
2946
|
applyDefault(paramResult, decl.initializer);
|
|
@@ -2948,6 +2975,9 @@ function expandBindingPattern(paramDecl, paramType, jsdocTags, ctx) {
|
|
|
2948
2975
|
};
|
|
2949
2976
|
if (description) {
|
|
2950
2977
|
param.description = description;
|
|
2978
|
+
const inlineTags = parseInlineTags(description);
|
|
2979
|
+
if (inlineTags)
|
|
2980
|
+
param.inlineTags = inlineTags;
|
|
2951
2981
|
}
|
|
2952
2982
|
if (element.initializer) {
|
|
2953
2983
|
applyDefault(param, element.initializer);
|
|
@@ -3534,7 +3564,7 @@ function serializeInheritedMember(symbol, inheritedFrom, ctx, isStatic) {
|
|
|
3534
3564
|
}
|
|
3535
3565
|
if (visibility === "private")
|
|
3536
3566
|
return null;
|
|
3537
|
-
const { description, tags } = getJSDocComment(decl);
|
|
3567
|
+
const { description, tags, inlineTags } = getJSDocComment(decl);
|
|
3538
3568
|
let kind = "property";
|
|
3539
3569
|
const callSigs = type.getCallSignatures();
|
|
3540
3570
|
if (callSigs.length > 0) {
|
|
@@ -3567,6 +3597,7 @@ function serializeInheritedMember(symbol, inheritedFrom, ctx, isStatic) {
|
|
|
3567
3597
|
},
|
|
3568
3598
|
...sigDoc.description ? { description: sigDoc.description } : {},
|
|
3569
3599
|
...sigDoc.tags.length > 0 ? { tags: sigDoc.tags } : {},
|
|
3600
|
+
...sigDoc.inlineTags ? { inlineTags: sigDoc.inlineTags } : {},
|
|
3570
3601
|
...callSigs.length > 1 ? { overloadIndex: index } : {}
|
|
3571
3602
|
};
|
|
3572
3603
|
});
|
|
@@ -3580,16 +3611,17 @@ function serializeInheritedMember(symbol, inheritedFrom, ctx, isStatic) {
|
|
|
3580
3611
|
visibility,
|
|
3581
3612
|
schema: kind !== "method" ? buildSchema(type, checker, ctx) : decoratePropertySchema({ "x-ts-function": true }, symbol, type, checker),
|
|
3582
3613
|
signatures,
|
|
3583
|
-
flags: Object.keys(flags).length > 0 ? flags : undefined
|
|
3614
|
+
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
3615
|
+
...inlineTags ? { inlineTags } : {}
|
|
3584
3616
|
};
|
|
3585
3617
|
}
|
|
3586
3618
|
|
|
3587
3619
|
// src/serializers/shared.ts
|
|
3588
3620
|
function extractExportMetadata(node, symbol, checker, jsdocNode) {
|
|
3589
3621
|
const { deprecated, reason: deprecationReason } = isSymbolDeprecated(symbol);
|
|
3590
|
-
const { description, tags, examples } = getJSDocComment(jsdocNode ?? node, symbol, checker);
|
|
3622
|
+
const { description, tags, examples, inlineTags } = getJSDocComment(jsdocNode ?? node, symbol, checker);
|
|
3591
3623
|
const source = getSourceLocation(node, node.getSourceFile());
|
|
3592
|
-
return { description, tags, examples, source, deprecated, deprecationReason };
|
|
3624
|
+
return { description, tags, examples, source, deprecated, deprecationReason, inlineTags };
|
|
3593
3625
|
}
|
|
3594
3626
|
function buildSignatures(callSignatures, checker, ctx) {
|
|
3595
3627
|
return callSignatures.map((sig, index) => {
|
|
@@ -3604,6 +3636,7 @@ function buildSignatures(callSignatures, checker, ctx) {
|
|
|
3604
3636
|
...sigDoc.description ? { description: sigDoc.description } : {},
|
|
3605
3637
|
...sigDoc.tags.length > 0 ? { tags: sigDoc.tags } : {},
|
|
3606
3638
|
...sigDoc.examples.length > 0 ? { examples: sigDoc.examples } : {},
|
|
3639
|
+
...sigDoc.inlineTags ? { inlineTags: sigDoc.inlineTags } : {},
|
|
3607
3640
|
...sigTypeParams ? { typeParameters: sigTypeParams } : {},
|
|
3608
3641
|
...callSignatures.length > 1 ? { overloadIndex: index } : {}
|
|
3609
3642
|
};
|
|
@@ -3617,7 +3650,7 @@ function serializeClass(node, ctx) {
|
|
|
3617
3650
|
const name = symbol?.getName() ?? node.name?.getText();
|
|
3618
3651
|
if (!name)
|
|
3619
3652
|
return null;
|
|
3620
|
-
const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, checker);
|
|
3653
|
+
const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, checker);
|
|
3621
3654
|
const typeParameters = extractTypeParameters(node, checker);
|
|
3622
3655
|
const members = [];
|
|
3623
3656
|
const signatures = [];
|
|
@@ -3693,6 +3726,7 @@ function serializeClass(node, ctx) {
|
|
|
3693
3726
|
implements: implementsClause?.length ? implementsClause : undefined,
|
|
3694
3727
|
...deprecated ? { deprecated: true, deprecationReason } : {},
|
|
3695
3728
|
...examples.length > 0 ? { examples } : {},
|
|
3729
|
+
...inlineTags ? { inlineTags } : {},
|
|
3696
3730
|
...Object.keys(classFlags).length > 0 ? { flags: classFlags } : {}
|
|
3697
3731
|
};
|
|
3698
3732
|
}
|
|
@@ -3734,7 +3768,7 @@ function serializeProperty(node, ctx) {
|
|
|
3734
3768
|
const name = getMemberName(node);
|
|
3735
3769
|
if (!name)
|
|
3736
3770
|
return null;
|
|
3737
|
-
const { description, tags } = getJSDocComment(node);
|
|
3771
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
3738
3772
|
const visibility = getVisibility(node);
|
|
3739
3773
|
if (!ctx.includePrivate && (visibility === "private" || visibility === "protected")) {
|
|
3740
3774
|
return null;
|
|
@@ -3763,6 +3797,7 @@ function serializeProperty(node, ctx) {
|
|
|
3763
3797
|
visibility,
|
|
3764
3798
|
schema,
|
|
3765
3799
|
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
3800
|
+
...inlineTags ? { inlineTags } : {},
|
|
3766
3801
|
...deprecated ? { deprecated: true, deprecationReason } : {}
|
|
3767
3802
|
};
|
|
3768
3803
|
}
|
|
@@ -3771,7 +3806,7 @@ function serializeMethod(node, ctx) {
|
|
|
3771
3806
|
const name = getMemberName(node);
|
|
3772
3807
|
if (!name)
|
|
3773
3808
|
return null;
|
|
3774
|
-
const { description, tags } = getJSDocComment(node);
|
|
3809
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
3775
3810
|
const visibility = getVisibility(node);
|
|
3776
3811
|
if (!ctx.includePrivate && (visibility === "private" || visibility === "protected")) {
|
|
3777
3812
|
return null;
|
|
@@ -3804,6 +3839,7 @@ function serializeMethod(node, ctx) {
|
|
|
3804
3839
|
schema,
|
|
3805
3840
|
signatures: signatures.length > 0 ? signatures : undefined,
|
|
3806
3841
|
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
3842
|
+
...inlineTags ? { inlineTags } : {},
|
|
3807
3843
|
...deprecated ? { deprecated: true, deprecationReason } : {}
|
|
3808
3844
|
};
|
|
3809
3845
|
}
|
|
@@ -3815,13 +3851,14 @@ function serializeConstructor(node, ctx) {
|
|
|
3815
3851
|
return serializeConstructorSignature(node, sig, ctx);
|
|
3816
3852
|
}
|
|
3817
3853
|
function serializeConstructorSignature(node, sig, ctx) {
|
|
3818
|
-
const { description, tags, examples } = getJSDocComment(node);
|
|
3854
|
+
const { description, tags, examples, inlineTags } = getJSDocComment(node);
|
|
3819
3855
|
const params = extractParameters(sig, ctx);
|
|
3820
3856
|
return {
|
|
3821
3857
|
description,
|
|
3822
3858
|
parameters: params.length > 0 ? params : undefined,
|
|
3823
3859
|
...tags.length > 0 ? { tags } : {},
|
|
3824
|
-
...examples.length > 0 ? { examples } : {}
|
|
3860
|
+
...examples.length > 0 ? { examples } : {},
|
|
3861
|
+
...inlineTags ? { inlineTags } : {}
|
|
3825
3862
|
};
|
|
3826
3863
|
}
|
|
3827
3864
|
function serializeInheritedConstructors(node, ctx) {
|
|
@@ -3852,7 +3889,7 @@ function serializeAccessor(node, ctx) {
|
|
|
3852
3889
|
const name = getMemberName(node);
|
|
3853
3890
|
if (!name)
|
|
3854
3891
|
return null;
|
|
3855
|
-
const { description, tags } = getJSDocComment(node);
|
|
3892
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
3856
3893
|
const visibility = getVisibility(node);
|
|
3857
3894
|
if (!ctx.includePrivate && (visibility === "private" || visibility === "protected")) {
|
|
3858
3895
|
return null;
|
|
@@ -3890,7 +3927,8 @@ function serializeAccessor(node, ctx) {
|
|
|
3890
3927
|
visibility,
|
|
3891
3928
|
schema,
|
|
3892
3929
|
signatures,
|
|
3893
|
-
flags: Object.keys(flags).length > 0 ? flags : undefined
|
|
3930
|
+
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
3931
|
+
...inlineTags ? { inlineTags } : {}
|
|
3894
3932
|
};
|
|
3895
3933
|
}
|
|
3896
3934
|
function getExtendsClause(node, checker) {
|
|
@@ -3930,7 +3968,7 @@ function serializeEnum(node, ctx) {
|
|
|
3930
3968
|
const name = symbol?.getName() ?? node.name?.getText();
|
|
3931
3969
|
if (!name)
|
|
3932
3970
|
return null;
|
|
3933
|
-
const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, checker);
|
|
3971
|
+
const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, checker);
|
|
3934
3972
|
const members = node.members.map((member) => {
|
|
3935
3973
|
const memberSymbol = checker.getSymbolAtLocation(member.name);
|
|
3936
3974
|
const memberName = memberSymbol?.getName() ?? member.name.getText();
|
|
@@ -3943,7 +3981,11 @@ function serializeEnum(node, ctx) {
|
|
|
3943
3981
|
} else if (member.initializer) {
|
|
3944
3982
|
schema = { type: member.initializer.getText() };
|
|
3945
3983
|
}
|
|
3946
|
-
const {
|
|
3984
|
+
const {
|
|
3985
|
+
description: memberDesc,
|
|
3986
|
+
tags: memberTags,
|
|
3987
|
+
inlineTags: memberInlineTags
|
|
3988
|
+
} = getJSDocComment(member);
|
|
3947
3989
|
const { deprecated: deprecated2, reason: deprecationReason2 } = isSymbolDeprecated(memberSymbol);
|
|
3948
3990
|
return {
|
|
3949
3991
|
id: memberName,
|
|
@@ -3952,6 +3994,7 @@ function serializeEnum(node, ctx) {
|
|
|
3952
3994
|
...schema ? { schema } : {},
|
|
3953
3995
|
...memberDesc ? { description: memberDesc } : {},
|
|
3954
3996
|
...memberTags.length > 0 ? { tags: memberTags } : {},
|
|
3997
|
+
...memberInlineTags ? { inlineTags: memberInlineTags } : {},
|
|
3955
3998
|
...deprecated2 ? { deprecated: true, deprecationReason: deprecationReason2 } : {}
|
|
3956
3999
|
};
|
|
3957
4000
|
});
|
|
@@ -3964,7 +4007,8 @@ function serializeEnum(node, ctx) {
|
|
|
3964
4007
|
source,
|
|
3965
4008
|
members,
|
|
3966
4009
|
...deprecated ? { deprecated: true, deprecationReason } : {},
|
|
3967
|
-
...examples.length > 0 ? { examples } : {}
|
|
4010
|
+
...examples.length > 0 ? { examples } : {},
|
|
4011
|
+
...inlineTags ? { inlineTags } : {}
|
|
3968
4012
|
};
|
|
3969
4013
|
}
|
|
3970
4014
|
|
|
@@ -4003,7 +4047,7 @@ function serializeFunctionExport(node, ctx, nameOverride) {
|
|
|
4003
4047
|
const name = nameOverride ?? symbol?.getName() ?? node.name?.getText();
|
|
4004
4048
|
if (!name)
|
|
4005
4049
|
return null;
|
|
4006
|
-
const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, ctx.typeChecker);
|
|
4050
|
+
const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, ctx.typeChecker);
|
|
4007
4051
|
const typeParameters = extractTypeParameters(node, ctx.typeChecker);
|
|
4008
4052
|
const type = ctx.typeChecker.getTypeAtLocation(node);
|
|
4009
4053
|
const callSignatures = type.getCallSignatures();
|
|
@@ -4040,7 +4084,8 @@ function serializeFunctionExport(node, ctx, nameOverride) {
|
|
|
4040
4084
|
signatures,
|
|
4041
4085
|
...Object.keys(flags).length > 0 ? { flags } : {},
|
|
4042
4086
|
...deprecated ? { deprecated: true, deprecationReason } : {},
|
|
4043
|
-
...examples.length > 0 ? { examples } : {}
|
|
4087
|
+
...examples.length > 0 ? { examples } : {},
|
|
4088
|
+
...inlineTags ? { inlineTags } : {}
|
|
4044
4089
|
};
|
|
4045
4090
|
}
|
|
4046
4091
|
|
|
@@ -4052,7 +4097,7 @@ function serializeInterface(node, ctx) {
|
|
|
4052
4097
|
const name = symbol?.getName() ?? node.name?.getText();
|
|
4053
4098
|
if (!name)
|
|
4054
4099
|
return null;
|
|
4055
|
-
const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, checker);
|
|
4100
|
+
const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, checker);
|
|
4056
4101
|
const typeParameters = extractTypeParameters(node, checker);
|
|
4057
4102
|
const members = [];
|
|
4058
4103
|
const methodsByName = new Map;
|
|
@@ -4130,13 +4175,14 @@ function serializeInterface(node, ctx) {
|
|
|
4130
4175
|
signatures: exportSignatures,
|
|
4131
4176
|
extends: extendsClause,
|
|
4132
4177
|
...deprecated ? { deprecated: true, deprecationReason } : {},
|
|
4133
|
-
...examples.length > 0 ? { examples } : {}
|
|
4178
|
+
...examples.length > 0 ? { examples } : {},
|
|
4179
|
+
...inlineTags ? { inlineTags } : {}
|
|
4134
4180
|
};
|
|
4135
4181
|
}
|
|
4136
4182
|
function serializePropertySignature(node, ctx) {
|
|
4137
4183
|
const { typeChecker: checker } = ctx;
|
|
4138
4184
|
const name = node.name.getText();
|
|
4139
|
-
const { description, tags } = getJSDocComment(node);
|
|
4185
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
4140
4186
|
const rawType = checker.getTypeAtLocation(node);
|
|
4141
4187
|
const type = node.questionToken ? stripUndefinedFromType(rawType, checker) : rawType;
|
|
4142
4188
|
let schema = buildSchema(type, checker, ctx);
|
|
@@ -4159,13 +4205,14 @@ function serializePropertySignature(node, ctx) {
|
|
|
4159
4205
|
tags: tags.length > 0 ? tags : undefined,
|
|
4160
4206
|
schema,
|
|
4161
4207
|
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
4208
|
+
...inlineTags ? { inlineTags } : {},
|
|
4162
4209
|
...deprecated ? { deprecated: true, deprecationReason } : {}
|
|
4163
4210
|
};
|
|
4164
4211
|
}
|
|
4165
4212
|
function serializeMethodSignature(node, ctx) {
|
|
4166
4213
|
const { typeChecker: checker } = ctx;
|
|
4167
4214
|
const name = node.name.getText();
|
|
4168
|
-
const { description, tags } = getJSDocComment(node);
|
|
4215
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
4169
4216
|
const type = checker.getTypeAtLocation(node);
|
|
4170
4217
|
const callSignatures = type.getCallSignatures();
|
|
4171
4218
|
const signatures = buildSignatures(callSignatures, checker, ctx);
|
|
@@ -4184,12 +4231,13 @@ function serializeMethodSignature(node, ctx) {
|
|
|
4184
4231
|
schema,
|
|
4185
4232
|
signatures: signatures.length > 0 ? signatures : undefined,
|
|
4186
4233
|
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
4234
|
+
...inlineTags ? { inlineTags } : {},
|
|
4187
4235
|
...deprecated ? { deprecated: true, deprecationReason } : {}
|
|
4188
4236
|
};
|
|
4189
4237
|
}
|
|
4190
4238
|
function serializeCallSignature(node, ctx) {
|
|
4191
4239
|
const { typeChecker: checker } = ctx;
|
|
4192
|
-
const { description, tags } = getJSDocComment(node);
|
|
4240
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
4193
4241
|
const sig = checker.getSignatureFromDeclaration(node);
|
|
4194
4242
|
if (!sig)
|
|
4195
4243
|
return null;
|
|
@@ -4201,6 +4249,7 @@ function serializeCallSignature(node, ctx) {
|
|
|
4201
4249
|
kind: "call-signature",
|
|
4202
4250
|
description,
|
|
4203
4251
|
tags: tags.length > 0 ? tags : undefined,
|
|
4252
|
+
...inlineTags ? { inlineTags } : {},
|
|
4204
4253
|
signatures: [
|
|
4205
4254
|
{
|
|
4206
4255
|
parameters: params.length > 0 ? params : undefined,
|
|
@@ -4213,7 +4262,7 @@ function serializeCallSignature(node, ctx) {
|
|
|
4213
4262
|
}
|
|
4214
4263
|
function serializeIndexSignature(node, ctx) {
|
|
4215
4264
|
const { typeChecker: checker } = ctx;
|
|
4216
|
-
const { description, tags } = getJSDocComment(node);
|
|
4265
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
4217
4266
|
const valueType = node.type ? checker.getTypeAtLocation(node.type) : checker.getAnyType();
|
|
4218
4267
|
const valueSchema = buildSchema(valueType, checker, ctx);
|
|
4219
4268
|
registerReferencedTypes(valueType, ctx);
|
|
@@ -4225,7 +4274,8 @@ function serializeIndexSignature(node, ctx) {
|
|
|
4225
4274
|
kind: "index-signature",
|
|
4226
4275
|
description,
|
|
4227
4276
|
tags: tags.length > 0 ? tags : undefined,
|
|
4228
|
-
schema: valueSchema
|
|
4277
|
+
schema: valueSchema,
|
|
4278
|
+
...inlineTags ? { inlineTags } : {}
|
|
4229
4279
|
};
|
|
4230
4280
|
}
|
|
4231
4281
|
function getInterfaceExtends(node, checker) {
|
|
@@ -4266,7 +4316,7 @@ function serializeTypeAlias(node, ctx) {
|
|
|
4266
4316
|
const name = symbol?.getName() ?? node.name?.getText();
|
|
4267
4317
|
if (!name)
|
|
4268
4318
|
return null;
|
|
4269
|
-
const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, ctx.typeChecker);
|
|
4319
|
+
const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, ctx.typeChecker);
|
|
4270
4320
|
const typeParameters = extractTypeParameters(node, ctx.typeChecker);
|
|
4271
4321
|
const type = ctx.typeChecker.getTypeAtLocation(node);
|
|
4272
4322
|
registerReferencedTypes(type, ctx);
|
|
@@ -4312,7 +4362,8 @@ function serializeTypeAlias(node, ctx) {
|
|
|
4312
4362
|
schema,
|
|
4313
4363
|
...members && members.length > 0 ? { members } : {},
|
|
4314
4364
|
...deprecated ? { deprecated: true, deprecationReason } : {},
|
|
4315
|
-
...examples.length > 0 ? { examples } : {}
|
|
4365
|
+
...examples.length > 0 ? { examples } : {},
|
|
4366
|
+
...inlineTags ? { inlineTags } : {}
|
|
4316
4367
|
};
|
|
4317
4368
|
}
|
|
4318
4369
|
function isObjectShapedAlias(type, ctx) {
|
|
@@ -4411,6 +4462,7 @@ function serializeResolvedMembers(type, node, ctx) {
|
|
|
4411
4462
|
if (prop.flags & ts11.SymbolFlags.Method)
|
|
4412
4463
|
flags.methodSyntax = true;
|
|
4413
4464
|
const schema = kind === "property" ? decoratePropertySchema(buildSchema(propType, checker, ctx), prop, propType, checker) : decoratePropertySchema({ "x-ts-function": true }, prop, propType, checker);
|
|
4465
|
+
const inlineTags = parseInlineTags(description);
|
|
4414
4466
|
members.push({
|
|
4415
4467
|
name: prop.getName(),
|
|
4416
4468
|
kind,
|
|
@@ -4419,6 +4471,7 @@ function serializeResolvedMembers(type, node, ctx) {
|
|
|
4419
4471
|
schema,
|
|
4420
4472
|
signatures: kind === "method" ? buildSignatures(callSigs, checker, ctx) : undefined,
|
|
4421
4473
|
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
4474
|
+
...inlineTags ? { inlineTags } : {},
|
|
4422
4475
|
...deprecated ? { deprecated: true, deprecationReason } : {}
|
|
4423
4476
|
});
|
|
4424
4477
|
}
|
|
@@ -4594,7 +4647,7 @@ function serializeVariable(node, statement, ctx) {
|
|
|
4594
4647
|
const name = symbol?.getName() ?? node.name.getText();
|
|
4595
4648
|
if (!name)
|
|
4596
4649
|
return null;
|
|
4597
|
-
const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, ctx.typeChecker, statement);
|
|
4650
|
+
const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, ctx.typeChecker, statement);
|
|
4598
4651
|
const type = ctx.typeChecker.getTypeAtLocation(node);
|
|
4599
4652
|
const schemaExtraction = extractSchemaType(type, ctx.typeChecker);
|
|
4600
4653
|
const typeToSerialize = schemaExtraction?.outputType ?? type;
|
|
@@ -4614,7 +4667,8 @@ function serializeVariable(node, statement, ctx) {
|
|
|
4614
4667
|
schema,
|
|
4615
4668
|
...flags ? { flags } : {},
|
|
4616
4669
|
...deprecated ? { deprecated: true, deprecationReason } : {},
|
|
4617
|
-
...examples.length > 0 ? { examples } : {}
|
|
4670
|
+
...examples.length > 0 ? { examples } : {},
|
|
4671
|
+
...inlineTags ? { inlineTags } : {}
|
|
4618
4672
|
};
|
|
4619
4673
|
}
|
|
4620
4674
|
|
|
@@ -7177,6 +7231,7 @@ function serializeDeclaration2(declaration, exportSymbol, exportName, ctx, isTyp
|
|
|
7177
7231
|
}
|
|
7178
7232
|
function serializeNamespaceExport(symbol, exportName, ctx) {
|
|
7179
7233
|
const { description, tags, examples } = getJSDocFromExportSymbol(symbol);
|
|
7234
|
+
const inlineTags = parseInlineTags(description);
|
|
7180
7235
|
const members = [];
|
|
7181
7236
|
const checker = ctx.program.getTypeChecker();
|
|
7182
7237
|
let targetSymbol = symbol;
|
|
@@ -7201,7 +7256,8 @@ function serializeNamespaceExport(symbol, exportName, ctx) {
|
|
|
7201
7256
|
description,
|
|
7202
7257
|
tags,
|
|
7203
7258
|
...examples.length > 0 ? { examples } : {},
|
|
7204
|
-
...members.length > 0 ? { members } : {}
|
|
7259
|
+
...members.length > 0 ? { members } : {},
|
|
7260
|
+
...inlineTags ? { inlineTags } : {}
|
|
7205
7261
|
};
|
|
7206
7262
|
}
|
|
7207
7263
|
function serializeNamespaceMember(symbol, memberName, ctx) {
|
|
@@ -7248,15 +7304,22 @@ function serializeNamespaceMember(symbol, memberName, ctx) {
|
|
|
7248
7304
|
registerReferencedTypes(type, ctx);
|
|
7249
7305
|
schema = buildSchema(type, ctx.typeChecker, ctx);
|
|
7250
7306
|
}
|
|
7307
|
+
const inlineTags = parseInlineTags(description);
|
|
7251
7308
|
return {
|
|
7252
7309
|
name: memberName,
|
|
7253
7310
|
kind,
|
|
7254
7311
|
...description ? { description } : {},
|
|
7255
7312
|
...signatures ? { signatures } : {},
|
|
7256
7313
|
...schema ? { schema } : {},
|
|
7314
|
+
...inlineTags ? { inlineTags } : {},
|
|
7257
7315
|
...deprecated ? { flags: { deprecated: true } } : {}
|
|
7258
7316
|
};
|
|
7259
7317
|
}
|
|
7318
|
+
function flattenJSDocComment(comment) {
|
|
7319
|
+
if (comment === undefined)
|
|
7320
|
+
return "";
|
|
7321
|
+
return typeof comment === "string" ? comment : ts18.getTextOfJSDocComment(comment) ?? "";
|
|
7322
|
+
}
|
|
7260
7323
|
function getJSDocFromExportSymbol(symbol) {
|
|
7261
7324
|
const tags = [];
|
|
7262
7325
|
const examples = [];
|
|
@@ -7267,7 +7330,7 @@ function getJSDocFromExportSymbol(symbol) {
|
|
|
7267
7330
|
const jsDocs = ts18.getJSDocCommentsAndTags(exportDecl);
|
|
7268
7331
|
for (const doc of jsDocs) {
|
|
7269
7332
|
if (ts18.isJSDoc(doc) && doc.comment) {
|
|
7270
|
-
const commentText =
|
|
7333
|
+
const commentText = flattenJSDocComment(doc.comment);
|
|
7271
7334
|
if (commentText) {
|
|
7272
7335
|
return {
|
|
7273
7336
|
description: commentText,
|
|
@@ -7297,8 +7360,9 @@ function extractJSDocTags(doc) {
|
|
|
7297
7360
|
const tags = [];
|
|
7298
7361
|
for (const tag of doc.tags ?? []) {
|
|
7299
7362
|
if (tag.tagName.text !== "example") {
|
|
7300
|
-
const text =
|
|
7301
|
-
|
|
7363
|
+
const text = flattenJSDocComment(tag.comment);
|
|
7364
|
+
const inlineTags = parseInlineTags(text);
|
|
7365
|
+
tags.push({ name: tag.tagName.text, text, ...inlineTags ? { inlineTags } : {} });
|
|
7302
7366
|
}
|
|
7303
7367
|
}
|
|
7304
7368
|
return tags;
|
|
@@ -7307,7 +7371,7 @@ function extractExamples(doc) {
|
|
|
7307
7371
|
const examples = [];
|
|
7308
7372
|
for (const tag of doc.tags ?? []) {
|
|
7309
7373
|
if (tag.tagName.text === "example") {
|
|
7310
|
-
const text =
|
|
7374
|
+
const text = flattenJSDocComment(tag.comment);
|
|
7311
7375
|
if (text)
|
|
7312
7376
|
examples.push(text);
|
|
7313
7377
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpkg-ts/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "TypeScript API extraction SDK - programmatic primitives for OpenPkg specs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openpkg",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"test": "bun test"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@openpkg-ts/spec": "^0.
|
|
46
|
+
"@openpkg-ts/spec": "^0.50.0",
|
|
47
47
|
"picomatch": "4.0.3",
|
|
48
48
|
"typescript": "^5.0.0"
|
|
49
49
|
},
|