@openpkg-ts/sdk 0.49.0 → 0.50.1

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 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) => ({ name: t.name, text: t.text })),
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,39 @@ 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
+ }
1332
+ var INLINE_TAGS_ONLY_RE = /^\s*(?:\{@[a-zA-Z][a-zA-Z0-9]*(?:[^}\\]|\\.)*\}\s*)+$/;
1333
+ function splitCommentLevelTags(text) {
1334
+ if (!text.includes("{@"))
1335
+ return { retained: text, hoisted: [] };
1336
+ const paragraphs = text.split(/\n\s*\n/);
1337
+ const hoisted = [];
1338
+ while (paragraphs.length > 1 && INLINE_TAGS_ONLY_RE.test(paragraphs[paragraphs.length - 1])) {
1339
+ hoisted.unshift(...parseInlineTags(paragraphs.pop()) ?? []);
1340
+ }
1341
+ return { retained: paragraphs.join(`
1342
+
1343
+ `), hoisted };
1344
+ }
1308
1345
  function parseExamplesFromTags(tags) {
1309
1346
  const examples = [];
1310
1347
  for (const tag of tags) {
@@ -1319,9 +1356,9 @@ function parseExamplesFromTags(tags) {
1319
1356
  if (lang && ["ts", "js", "tsx", "jsx", "shell", "json"].includes(lang)) {
1320
1357
  example.language = lang;
1321
1358
  }
1322
- examples.push(example);
1359
+ examples.push(withInlineTags(example, example.code));
1323
1360
  } else if (text) {
1324
- examples.push({ code: text });
1361
+ examples.push(withInlineTags({ code: text }, text));
1325
1362
  }
1326
1363
  }
1327
1364
  return examples;
@@ -1392,8 +1429,11 @@ function extractSeeTagText(tag) {
1392
1429
  }
1393
1430
  function getJSDocComment(node, symbol, checker) {
1394
1431
  const jsDocTags = ts.getJSDocTags(node);
1432
+ const commentLevelTags = [];
1395
1433
  const tags = jsDocTags.map((tag) => {
1396
1434
  const rawText = typeof tag.comment === "string" ? tag.comment : ts.getTextOfJSDocComment(tag.comment) ?? "";
1435
+ const { retained, hoisted } = tag.tagName.text === "see" ? { retained: rawText, hoisted: [] } : splitCommentLevelTags(rawText);
1436
+ commentLevelTags.push(...hoisted);
1397
1437
  if (tag.tagName.text === "param") {
1398
1438
  const paramTag = tag;
1399
1439
  let paramName = "";
@@ -1416,17 +1456,17 @@ function getJSDocComment(node, symbol, checker) {
1416
1456
  param.description = description2;
1417
1457
  if (paramTag.isBracketed)
1418
1458
  param.optional = true;
1419
- return { name: tag.tagName.text, text, param };
1459
+ return withInlineTags({ name: tag.tagName.text, text, param }, text);
1420
1460
  }
1421
1461
  if (tag.tagName.text === "typeParam") {
1422
1462
  const text = stripTypeParamSeparator(rawText) ?? "";
1423
- return { name: tag.tagName.text, text };
1463
+ return withInlineTags({ name: tag.tagName.text, text }, text);
1424
1464
  }
1425
1465
  if (tag.tagName.text === "see") {
1426
1466
  const text = extractSeeTagText(tag);
1427
- return { name: tag.tagName.text, text };
1467
+ return withInlineTags({ name: tag.tagName.text, text }, text);
1428
1468
  }
1429
- return { name: tag.tagName.text, text: rawText };
1469
+ return withInlineTags({ name: tag.tagName.text, text: rawText }, retained);
1430
1470
  });
1431
1471
  const jsDocComments = ts.getJSDocCommentsAndTags(node).filter(ts.isJSDoc);
1432
1472
  let description;
@@ -1444,7 +1484,13 @@ function getJSDocComment(node, symbol, checker) {
1444
1484
  }
1445
1485
  }
1446
1486
  const examples = parseExamplesFromTags(tags);
1447
- return { description, tags, examples };
1487
+ const inlineTags = [...parseInlineTags(description) ?? [], ...commentLevelTags];
1488
+ return {
1489
+ description,
1490
+ tags,
1491
+ examples,
1492
+ inlineTags: inlineTags.length > 0 ? inlineTags : undefined
1493
+ };
1448
1494
  }
1449
1495
  function getSourceLocation(node, sourceFile) {
1450
1496
  const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
@@ -2914,6 +2960,9 @@ function extractParameters(signature, ctx) {
2914
2960
  };
2915
2961
  if (description) {
2916
2962
  paramResult.description = description;
2963
+ const inlineTags = parseInlineTags(description);
2964
+ if (inlineTags)
2965
+ paramResult.inlineTags = inlineTags;
2917
2966
  }
2918
2967
  if (decl.initializer) {
2919
2968
  applyDefault(paramResult, decl.initializer);
@@ -2948,6 +2997,9 @@ function expandBindingPattern(paramDecl, paramType, jsdocTags, ctx) {
2948
2997
  };
2949
2998
  if (description) {
2950
2999
  param.description = description;
3000
+ const inlineTags = parseInlineTags(description);
3001
+ if (inlineTags)
3002
+ param.inlineTags = inlineTags;
2951
3003
  }
2952
3004
  if (element.initializer) {
2953
3005
  applyDefault(param, element.initializer);
@@ -3534,7 +3586,7 @@ function serializeInheritedMember(symbol, inheritedFrom, ctx, isStatic) {
3534
3586
  }
3535
3587
  if (visibility === "private")
3536
3588
  return null;
3537
- const { description, tags } = getJSDocComment(decl);
3589
+ const { description, tags, inlineTags } = getJSDocComment(decl);
3538
3590
  let kind = "property";
3539
3591
  const callSigs = type.getCallSignatures();
3540
3592
  if (callSigs.length > 0) {
@@ -3567,6 +3619,7 @@ function serializeInheritedMember(symbol, inheritedFrom, ctx, isStatic) {
3567
3619
  },
3568
3620
  ...sigDoc.description ? { description: sigDoc.description } : {},
3569
3621
  ...sigDoc.tags.length > 0 ? { tags: sigDoc.tags } : {},
3622
+ ...sigDoc.inlineTags ? { inlineTags: sigDoc.inlineTags } : {},
3570
3623
  ...callSigs.length > 1 ? { overloadIndex: index } : {}
3571
3624
  };
3572
3625
  });
@@ -3580,16 +3633,17 @@ function serializeInheritedMember(symbol, inheritedFrom, ctx, isStatic) {
3580
3633
  visibility,
3581
3634
  schema: kind !== "method" ? buildSchema(type, checker, ctx) : decoratePropertySchema({ "x-ts-function": true }, symbol, type, checker),
3582
3635
  signatures,
3583
- flags: Object.keys(flags).length > 0 ? flags : undefined
3636
+ flags: Object.keys(flags).length > 0 ? flags : undefined,
3637
+ ...inlineTags ? { inlineTags } : {}
3584
3638
  };
3585
3639
  }
3586
3640
 
3587
3641
  // src/serializers/shared.ts
3588
3642
  function extractExportMetadata(node, symbol, checker, jsdocNode) {
3589
3643
  const { deprecated, reason: deprecationReason } = isSymbolDeprecated(symbol);
3590
- const { description, tags, examples } = getJSDocComment(jsdocNode ?? node, symbol, checker);
3644
+ const { description, tags, examples, inlineTags } = getJSDocComment(jsdocNode ?? node, symbol, checker);
3591
3645
  const source = getSourceLocation(node, node.getSourceFile());
3592
- return { description, tags, examples, source, deprecated, deprecationReason };
3646
+ return { description, tags, examples, source, deprecated, deprecationReason, inlineTags };
3593
3647
  }
3594
3648
  function buildSignatures(callSignatures, checker, ctx) {
3595
3649
  return callSignatures.map((sig, index) => {
@@ -3604,6 +3658,7 @@ function buildSignatures(callSignatures, checker, ctx) {
3604
3658
  ...sigDoc.description ? { description: sigDoc.description } : {},
3605
3659
  ...sigDoc.tags.length > 0 ? { tags: sigDoc.tags } : {},
3606
3660
  ...sigDoc.examples.length > 0 ? { examples: sigDoc.examples } : {},
3661
+ ...sigDoc.inlineTags ? { inlineTags: sigDoc.inlineTags } : {},
3607
3662
  ...sigTypeParams ? { typeParameters: sigTypeParams } : {},
3608
3663
  ...callSignatures.length > 1 ? { overloadIndex: index } : {}
3609
3664
  };
@@ -3617,7 +3672,7 @@ function serializeClass(node, ctx) {
3617
3672
  const name = symbol?.getName() ?? node.name?.getText();
3618
3673
  if (!name)
3619
3674
  return null;
3620
- const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, checker);
3675
+ const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, checker);
3621
3676
  const typeParameters = extractTypeParameters(node, checker);
3622
3677
  const members = [];
3623
3678
  const signatures = [];
@@ -3693,6 +3748,7 @@ function serializeClass(node, ctx) {
3693
3748
  implements: implementsClause?.length ? implementsClause : undefined,
3694
3749
  ...deprecated ? { deprecated: true, deprecationReason } : {},
3695
3750
  ...examples.length > 0 ? { examples } : {},
3751
+ ...inlineTags ? { inlineTags } : {},
3696
3752
  ...Object.keys(classFlags).length > 0 ? { flags: classFlags } : {}
3697
3753
  };
3698
3754
  }
@@ -3734,7 +3790,7 @@ function serializeProperty(node, ctx) {
3734
3790
  const name = getMemberName(node);
3735
3791
  if (!name)
3736
3792
  return null;
3737
- const { description, tags } = getJSDocComment(node);
3793
+ const { description, tags, inlineTags } = getJSDocComment(node);
3738
3794
  const visibility = getVisibility(node);
3739
3795
  if (!ctx.includePrivate && (visibility === "private" || visibility === "protected")) {
3740
3796
  return null;
@@ -3763,6 +3819,7 @@ function serializeProperty(node, ctx) {
3763
3819
  visibility,
3764
3820
  schema,
3765
3821
  flags: Object.keys(flags).length > 0 ? flags : undefined,
3822
+ ...inlineTags ? { inlineTags } : {},
3766
3823
  ...deprecated ? { deprecated: true, deprecationReason } : {}
3767
3824
  };
3768
3825
  }
@@ -3771,7 +3828,7 @@ function serializeMethod(node, ctx) {
3771
3828
  const name = getMemberName(node);
3772
3829
  if (!name)
3773
3830
  return null;
3774
- const { description, tags } = getJSDocComment(node);
3831
+ const { description, tags, inlineTags } = getJSDocComment(node);
3775
3832
  const visibility = getVisibility(node);
3776
3833
  if (!ctx.includePrivate && (visibility === "private" || visibility === "protected")) {
3777
3834
  return null;
@@ -3804,6 +3861,7 @@ function serializeMethod(node, ctx) {
3804
3861
  schema,
3805
3862
  signatures: signatures.length > 0 ? signatures : undefined,
3806
3863
  flags: Object.keys(flags).length > 0 ? flags : undefined,
3864
+ ...inlineTags ? { inlineTags } : {},
3807
3865
  ...deprecated ? { deprecated: true, deprecationReason } : {}
3808
3866
  };
3809
3867
  }
@@ -3815,13 +3873,14 @@ function serializeConstructor(node, ctx) {
3815
3873
  return serializeConstructorSignature(node, sig, ctx);
3816
3874
  }
3817
3875
  function serializeConstructorSignature(node, sig, ctx) {
3818
- const { description, tags, examples } = getJSDocComment(node);
3876
+ const { description, tags, examples, inlineTags } = getJSDocComment(node);
3819
3877
  const params = extractParameters(sig, ctx);
3820
3878
  return {
3821
3879
  description,
3822
3880
  parameters: params.length > 0 ? params : undefined,
3823
3881
  ...tags.length > 0 ? { tags } : {},
3824
- ...examples.length > 0 ? { examples } : {}
3882
+ ...examples.length > 0 ? { examples } : {},
3883
+ ...inlineTags ? { inlineTags } : {}
3825
3884
  };
3826
3885
  }
3827
3886
  function serializeInheritedConstructors(node, ctx) {
@@ -3852,7 +3911,7 @@ function serializeAccessor(node, ctx) {
3852
3911
  const name = getMemberName(node);
3853
3912
  if (!name)
3854
3913
  return null;
3855
- const { description, tags } = getJSDocComment(node);
3914
+ const { description, tags, inlineTags } = getJSDocComment(node);
3856
3915
  const visibility = getVisibility(node);
3857
3916
  if (!ctx.includePrivate && (visibility === "private" || visibility === "protected")) {
3858
3917
  return null;
@@ -3890,7 +3949,8 @@ function serializeAccessor(node, ctx) {
3890
3949
  visibility,
3891
3950
  schema,
3892
3951
  signatures,
3893
- flags: Object.keys(flags).length > 0 ? flags : undefined
3952
+ flags: Object.keys(flags).length > 0 ? flags : undefined,
3953
+ ...inlineTags ? { inlineTags } : {}
3894
3954
  };
3895
3955
  }
3896
3956
  function getExtendsClause(node, checker) {
@@ -3930,7 +3990,7 @@ function serializeEnum(node, ctx) {
3930
3990
  const name = symbol?.getName() ?? node.name?.getText();
3931
3991
  if (!name)
3932
3992
  return null;
3933
- const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, checker);
3993
+ const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, checker);
3934
3994
  const members = node.members.map((member) => {
3935
3995
  const memberSymbol = checker.getSymbolAtLocation(member.name);
3936
3996
  const memberName = memberSymbol?.getName() ?? member.name.getText();
@@ -3943,7 +4003,11 @@ function serializeEnum(node, ctx) {
3943
4003
  } else if (member.initializer) {
3944
4004
  schema = { type: member.initializer.getText() };
3945
4005
  }
3946
- const { description: memberDesc, tags: memberTags } = getJSDocComment(member);
4006
+ const {
4007
+ description: memberDesc,
4008
+ tags: memberTags,
4009
+ inlineTags: memberInlineTags
4010
+ } = getJSDocComment(member);
3947
4011
  const { deprecated: deprecated2, reason: deprecationReason2 } = isSymbolDeprecated(memberSymbol);
3948
4012
  return {
3949
4013
  id: memberName,
@@ -3952,6 +4016,7 @@ function serializeEnum(node, ctx) {
3952
4016
  ...schema ? { schema } : {},
3953
4017
  ...memberDesc ? { description: memberDesc } : {},
3954
4018
  ...memberTags.length > 0 ? { tags: memberTags } : {},
4019
+ ...memberInlineTags ? { inlineTags: memberInlineTags } : {},
3955
4020
  ...deprecated2 ? { deprecated: true, deprecationReason: deprecationReason2 } : {}
3956
4021
  };
3957
4022
  });
@@ -3964,7 +4029,8 @@ function serializeEnum(node, ctx) {
3964
4029
  source,
3965
4030
  members,
3966
4031
  ...deprecated ? { deprecated: true, deprecationReason } : {},
3967
- ...examples.length > 0 ? { examples } : {}
4032
+ ...examples.length > 0 ? { examples } : {},
4033
+ ...inlineTags ? { inlineTags } : {}
3968
4034
  };
3969
4035
  }
3970
4036
 
@@ -4003,7 +4069,7 @@ function serializeFunctionExport(node, ctx, nameOverride) {
4003
4069
  const name = nameOverride ?? symbol?.getName() ?? node.name?.getText();
4004
4070
  if (!name)
4005
4071
  return null;
4006
- const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, ctx.typeChecker);
4072
+ const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, ctx.typeChecker);
4007
4073
  const typeParameters = extractTypeParameters(node, ctx.typeChecker);
4008
4074
  const type = ctx.typeChecker.getTypeAtLocation(node);
4009
4075
  const callSignatures = type.getCallSignatures();
@@ -4040,7 +4106,8 @@ function serializeFunctionExport(node, ctx, nameOverride) {
4040
4106
  signatures,
4041
4107
  ...Object.keys(flags).length > 0 ? { flags } : {},
4042
4108
  ...deprecated ? { deprecated: true, deprecationReason } : {},
4043
- ...examples.length > 0 ? { examples } : {}
4109
+ ...examples.length > 0 ? { examples } : {},
4110
+ ...inlineTags ? { inlineTags } : {}
4044
4111
  };
4045
4112
  }
4046
4113
 
@@ -4052,7 +4119,7 @@ function serializeInterface(node, ctx) {
4052
4119
  const name = symbol?.getName() ?? node.name?.getText();
4053
4120
  if (!name)
4054
4121
  return null;
4055
- const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, checker);
4122
+ const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, checker);
4056
4123
  const typeParameters = extractTypeParameters(node, checker);
4057
4124
  const members = [];
4058
4125
  const methodsByName = new Map;
@@ -4130,13 +4197,14 @@ function serializeInterface(node, ctx) {
4130
4197
  signatures: exportSignatures,
4131
4198
  extends: extendsClause,
4132
4199
  ...deprecated ? { deprecated: true, deprecationReason } : {},
4133
- ...examples.length > 0 ? { examples } : {}
4200
+ ...examples.length > 0 ? { examples } : {},
4201
+ ...inlineTags ? { inlineTags } : {}
4134
4202
  };
4135
4203
  }
4136
4204
  function serializePropertySignature(node, ctx) {
4137
4205
  const { typeChecker: checker } = ctx;
4138
4206
  const name = node.name.getText();
4139
- const { description, tags } = getJSDocComment(node);
4207
+ const { description, tags, inlineTags } = getJSDocComment(node);
4140
4208
  const rawType = checker.getTypeAtLocation(node);
4141
4209
  const type = node.questionToken ? stripUndefinedFromType(rawType, checker) : rawType;
4142
4210
  let schema = buildSchema(type, checker, ctx);
@@ -4159,13 +4227,14 @@ function serializePropertySignature(node, ctx) {
4159
4227
  tags: tags.length > 0 ? tags : undefined,
4160
4228
  schema,
4161
4229
  flags: Object.keys(flags).length > 0 ? flags : undefined,
4230
+ ...inlineTags ? { inlineTags } : {},
4162
4231
  ...deprecated ? { deprecated: true, deprecationReason } : {}
4163
4232
  };
4164
4233
  }
4165
4234
  function serializeMethodSignature(node, ctx) {
4166
4235
  const { typeChecker: checker } = ctx;
4167
4236
  const name = node.name.getText();
4168
- const { description, tags } = getJSDocComment(node);
4237
+ const { description, tags, inlineTags } = getJSDocComment(node);
4169
4238
  const type = checker.getTypeAtLocation(node);
4170
4239
  const callSignatures = type.getCallSignatures();
4171
4240
  const signatures = buildSignatures(callSignatures, checker, ctx);
@@ -4184,12 +4253,13 @@ function serializeMethodSignature(node, ctx) {
4184
4253
  schema,
4185
4254
  signatures: signatures.length > 0 ? signatures : undefined,
4186
4255
  flags: Object.keys(flags).length > 0 ? flags : undefined,
4256
+ ...inlineTags ? { inlineTags } : {},
4187
4257
  ...deprecated ? { deprecated: true, deprecationReason } : {}
4188
4258
  };
4189
4259
  }
4190
4260
  function serializeCallSignature(node, ctx) {
4191
4261
  const { typeChecker: checker } = ctx;
4192
- const { description, tags } = getJSDocComment(node);
4262
+ const { description, tags, inlineTags } = getJSDocComment(node);
4193
4263
  const sig = checker.getSignatureFromDeclaration(node);
4194
4264
  if (!sig)
4195
4265
  return null;
@@ -4201,6 +4271,7 @@ function serializeCallSignature(node, ctx) {
4201
4271
  kind: "call-signature",
4202
4272
  description,
4203
4273
  tags: tags.length > 0 ? tags : undefined,
4274
+ ...inlineTags ? { inlineTags } : {},
4204
4275
  signatures: [
4205
4276
  {
4206
4277
  parameters: params.length > 0 ? params : undefined,
@@ -4213,7 +4284,7 @@ function serializeCallSignature(node, ctx) {
4213
4284
  }
4214
4285
  function serializeIndexSignature(node, ctx) {
4215
4286
  const { typeChecker: checker } = ctx;
4216
- const { description, tags } = getJSDocComment(node);
4287
+ const { description, tags, inlineTags } = getJSDocComment(node);
4217
4288
  const valueType = node.type ? checker.getTypeAtLocation(node.type) : checker.getAnyType();
4218
4289
  const valueSchema = buildSchema(valueType, checker, ctx);
4219
4290
  registerReferencedTypes(valueType, ctx);
@@ -4225,7 +4296,8 @@ function serializeIndexSignature(node, ctx) {
4225
4296
  kind: "index-signature",
4226
4297
  description,
4227
4298
  tags: tags.length > 0 ? tags : undefined,
4228
- schema: valueSchema
4299
+ schema: valueSchema,
4300
+ ...inlineTags ? { inlineTags } : {}
4229
4301
  };
4230
4302
  }
4231
4303
  function getInterfaceExtends(node, checker) {
@@ -4266,7 +4338,7 @@ function serializeTypeAlias(node, ctx) {
4266
4338
  const name = symbol?.getName() ?? node.name?.getText();
4267
4339
  if (!name)
4268
4340
  return null;
4269
- const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, ctx.typeChecker);
4341
+ const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, ctx.typeChecker);
4270
4342
  const typeParameters = extractTypeParameters(node, ctx.typeChecker);
4271
4343
  const type = ctx.typeChecker.getTypeAtLocation(node);
4272
4344
  registerReferencedTypes(type, ctx);
@@ -4312,7 +4384,8 @@ function serializeTypeAlias(node, ctx) {
4312
4384
  schema,
4313
4385
  ...members && members.length > 0 ? { members } : {},
4314
4386
  ...deprecated ? { deprecated: true, deprecationReason } : {},
4315
- ...examples.length > 0 ? { examples } : {}
4387
+ ...examples.length > 0 ? { examples } : {},
4388
+ ...inlineTags ? { inlineTags } : {}
4316
4389
  };
4317
4390
  }
4318
4391
  function isObjectShapedAlias(type, ctx) {
@@ -4411,6 +4484,7 @@ function serializeResolvedMembers(type, node, ctx) {
4411
4484
  if (prop.flags & ts11.SymbolFlags.Method)
4412
4485
  flags.methodSyntax = true;
4413
4486
  const schema = kind === "property" ? decoratePropertySchema(buildSchema(propType, checker, ctx), prop, propType, checker) : decoratePropertySchema({ "x-ts-function": true }, prop, propType, checker);
4487
+ const inlineTags = parseInlineTags(description);
4414
4488
  members.push({
4415
4489
  name: prop.getName(),
4416
4490
  kind,
@@ -4419,6 +4493,7 @@ function serializeResolvedMembers(type, node, ctx) {
4419
4493
  schema,
4420
4494
  signatures: kind === "method" ? buildSignatures(callSigs, checker, ctx) : undefined,
4421
4495
  flags: Object.keys(flags).length > 0 ? flags : undefined,
4496
+ ...inlineTags ? { inlineTags } : {},
4422
4497
  ...deprecated ? { deprecated: true, deprecationReason } : {}
4423
4498
  });
4424
4499
  }
@@ -4594,7 +4669,7 @@ function serializeVariable(node, statement, ctx) {
4594
4669
  const name = symbol?.getName() ?? node.name.getText();
4595
4670
  if (!name)
4596
4671
  return null;
4597
- const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, ctx.typeChecker, statement);
4672
+ const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, ctx.typeChecker, statement);
4598
4673
  const type = ctx.typeChecker.getTypeAtLocation(node);
4599
4674
  const schemaExtraction = extractSchemaType(type, ctx.typeChecker);
4600
4675
  const typeToSerialize = schemaExtraction?.outputType ?? type;
@@ -4614,7 +4689,8 @@ function serializeVariable(node, statement, ctx) {
4614
4689
  schema,
4615
4690
  ...flags ? { flags } : {},
4616
4691
  ...deprecated ? { deprecated: true, deprecationReason } : {},
4617
- ...examples.length > 0 ? { examples } : {}
4692
+ ...examples.length > 0 ? { examples } : {},
4693
+ ...inlineTags ? { inlineTags } : {}
4618
4694
  };
4619
4695
  }
4620
4696
 
@@ -7177,6 +7253,7 @@ function serializeDeclaration2(declaration, exportSymbol, exportName, ctx, isTyp
7177
7253
  }
7178
7254
  function serializeNamespaceExport(symbol, exportName, ctx) {
7179
7255
  const { description, tags, examples } = getJSDocFromExportSymbol(symbol);
7256
+ const inlineTags = parseInlineTags(description);
7180
7257
  const members = [];
7181
7258
  const checker = ctx.program.getTypeChecker();
7182
7259
  let targetSymbol = symbol;
@@ -7201,7 +7278,8 @@ function serializeNamespaceExport(symbol, exportName, ctx) {
7201
7278
  description,
7202
7279
  tags,
7203
7280
  ...examples.length > 0 ? { examples } : {},
7204
- ...members.length > 0 ? { members } : {}
7281
+ ...members.length > 0 ? { members } : {},
7282
+ ...inlineTags ? { inlineTags } : {}
7205
7283
  };
7206
7284
  }
7207
7285
  function serializeNamespaceMember(symbol, memberName, ctx) {
@@ -7248,15 +7326,22 @@ function serializeNamespaceMember(symbol, memberName, ctx) {
7248
7326
  registerReferencedTypes(type, ctx);
7249
7327
  schema = buildSchema(type, ctx.typeChecker, ctx);
7250
7328
  }
7329
+ const inlineTags = parseInlineTags(description);
7251
7330
  return {
7252
7331
  name: memberName,
7253
7332
  kind,
7254
7333
  ...description ? { description } : {},
7255
7334
  ...signatures ? { signatures } : {},
7256
7335
  ...schema ? { schema } : {},
7336
+ ...inlineTags ? { inlineTags } : {},
7257
7337
  ...deprecated ? { flags: { deprecated: true } } : {}
7258
7338
  };
7259
7339
  }
7340
+ function flattenJSDocComment(comment) {
7341
+ if (comment === undefined)
7342
+ return "";
7343
+ return typeof comment === "string" ? comment : ts18.getTextOfJSDocComment(comment) ?? "";
7344
+ }
7260
7345
  function getJSDocFromExportSymbol(symbol) {
7261
7346
  const tags = [];
7262
7347
  const examples = [];
@@ -7267,7 +7352,7 @@ function getJSDocFromExportSymbol(symbol) {
7267
7352
  const jsDocs = ts18.getJSDocCommentsAndTags(exportDecl);
7268
7353
  for (const doc of jsDocs) {
7269
7354
  if (ts18.isJSDoc(doc) && doc.comment) {
7270
- const commentText = typeof doc.comment === "string" ? doc.comment : doc.comment.map((c) => ("text" in c) ? c.text : "").join("");
7355
+ const commentText = flattenJSDocComment(doc.comment);
7271
7356
  if (commentText) {
7272
7357
  return {
7273
7358
  description: commentText,
@@ -7297,8 +7382,9 @@ function extractJSDocTags(doc) {
7297
7382
  const tags = [];
7298
7383
  for (const tag of doc.tags ?? []) {
7299
7384
  if (tag.tagName.text !== "example") {
7300
- const text = typeof tag.comment === "string" ? tag.comment : tag.comment?.map((c) => ("text" in c) ? c.text : "").join("") ?? "";
7301
- tags.push({ name: tag.tagName.text, text });
7385
+ const text = flattenJSDocComment(tag.comment);
7386
+ const inlineTags = parseInlineTags(text);
7387
+ tags.push({ name: tag.tagName.text, text, ...inlineTags ? { inlineTags } : {} });
7302
7388
  }
7303
7389
  }
7304
7390
  return tags;
@@ -7307,7 +7393,7 @@ function extractExamples(doc) {
7307
7393
  const examples = [];
7308
7394
  for (const tag of doc.tags ?? []) {
7309
7395
  if (tag.tagName.text === "example") {
7310
- const text = typeof tag.comment === "string" ? tag.comment : tag.comment?.map((c) => ("text" in c) ? c.text : "").join("") ?? "";
7396
+ const text = flattenJSDocComment(tag.comment);
7311
7397
  if (text)
7312
7398
  examples.push(text);
7313
7399
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/sdk",
3
- "version": "0.49.0",
3
+ "version": "0.50.1",
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.49.0",
46
+ "@openpkg-ts/spec": "^0.50.0",
47
47
  "picomatch": "4.0.3",
48
48
  "typescript": "^5.0.0"
49
49
  },