@doccov/sdk 0.7.0 → 0.9.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.
Files changed (2) hide show
  1. package/dist/index.js +262 -19
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2063,6 +2063,35 @@ import * as fs2 from "node:fs";
2063
2063
  import * as path3 from "node:path";
2064
2064
  import { SCHEMA_URL, SCHEMA_VERSION } from "@openpkg-ts/spec";
2065
2065
 
2066
+ // src/analysis/decorator-utils.ts
2067
+ function extractDecorators(node) {
2068
+ if (!ts2.canHaveDecorators(node)) {
2069
+ return;
2070
+ }
2071
+ const decorators = ts2.getDecorators(node);
2072
+ if (!decorators || decorators.length === 0) {
2073
+ return;
2074
+ }
2075
+ return decorators.map((decorator) => {
2076
+ const expression = decorator.expression;
2077
+ if (ts2.isIdentifier(expression)) {
2078
+ return { name: expression.text };
2079
+ }
2080
+ if (ts2.isCallExpression(expression)) {
2081
+ const name = ts2.isIdentifier(expression.expression) ? expression.expression.text : expression.expression.getText();
2082
+ const argumentsText = expression.arguments.map((arg) => arg.getText());
2083
+ return { name, argumentsText };
2084
+ }
2085
+ if (ts2.isPropertyAccessExpression(expression)) {
2086
+ return { name: expression.getText() };
2087
+ }
2088
+ return { name: expression.getText() };
2089
+ });
2090
+ }
2091
+ function extractParameterDecorators(param) {
2092
+ return extractDecorators(param);
2093
+ }
2094
+
2066
2095
  // src/utils/parameter-utils.ts
2067
2096
  var BUILTIN_TYPE_SCHEMAS = {
2068
2097
  Date: { type: "string", format: "date-time" },
@@ -2991,6 +3020,10 @@ function structureParameter(param, paramDecl, paramType, typeChecker, typeRefs,
2991
3020
  if (paramDecl.dotDotDotToken) {
2992
3021
  out.rest = true;
2993
3022
  }
3023
+ const decorators = extractParameterDecorators(paramDecl);
3024
+ if (decorators) {
3025
+ out.decorators = decorators;
3026
+ }
2994
3027
  return out;
2995
3028
  }
2996
3029
 
@@ -2999,7 +3032,10 @@ function parseJSDocBlock(commentText) {
2999
3032
  const result = {
3000
3033
  description: "",
3001
3034
  params: [],
3035
+ throws: [],
3002
3036
  examples: [],
3037
+ structuredExamples: [],
3038
+ seeAlso: [],
3003
3039
  tags: [],
3004
3040
  rawParamNames: []
3005
3041
  };
@@ -3104,6 +3140,59 @@ function parseReturnContent(content) {
3104
3140
  description: processInlineLinks(remaining)
3105
3141
  };
3106
3142
  }
3143
+ function parseThrowsContent(content) {
3144
+ const trimmed = content.trim();
3145
+ let remaining = trimmed;
3146
+ let type;
3147
+ if (remaining.startsWith("{")) {
3148
+ const typeEnd = findMatchingBrace(remaining, 0);
3149
+ if (typeEnd > 0) {
3150
+ type = remaining.slice(1, typeEnd).trim();
3151
+ remaining = remaining.slice(typeEnd + 1).trim();
3152
+ }
3153
+ }
3154
+ return {
3155
+ type,
3156
+ description: processInlineLinks(remaining)
3157
+ };
3158
+ }
3159
+ function parseExampleContent(content) {
3160
+ const trimmed = content.trim();
3161
+ if (!trimmed)
3162
+ return null;
3163
+ const lines = trimmed.split(`
3164
+ `);
3165
+ let title;
3166
+ let description;
3167
+ let language;
3168
+ let codeStartIndex = 0;
3169
+ const firstLine = lines[0]?.trim() ?? "";
3170
+ const looksLikeCode = /^(import|const|let|var|function|class|export|async|await|if|for|while|return|\/\/|\/\*|\{|\[)/.test(firstLine);
3171
+ if (firstLine && !firstLine.startsWith("```") && !looksLikeCode) {
3172
+ title = firstLine;
3173
+ codeStartIndex = 1;
3174
+ }
3175
+ const codeBlockStart = lines.findIndex((l, i) => i >= codeStartIndex && l.trim().startsWith("```"));
3176
+ if (codeBlockStart !== -1) {
3177
+ const fenceMatch = lines[codeBlockStart].match(/```(\w+)?/);
3178
+ language = fenceMatch?.[1];
3179
+ if (codeBlockStart > codeStartIndex) {
3180
+ const descLines = lines.slice(codeStartIndex, codeBlockStart).filter((l) => l.trim());
3181
+ if (descLines.length > 0) {
3182
+ description = descLines.join(`
3183
+ `).trim();
3184
+ }
3185
+ }
3186
+ const codeBlockEnd = lines.findIndex((l, i) => i > codeBlockStart && l.trim() === "```");
3187
+ const codeLines = codeBlockEnd === -1 ? lines.slice(codeBlockStart + 1) : lines.slice(codeBlockStart + 1, codeBlockEnd);
3188
+ const code2 = codeLines.join(`
3189
+ `);
3190
+ return { code: code2, title, description, language };
3191
+ }
3192
+ const code = lines.slice(codeStartIndex).join(`
3193
+ `).trim();
3194
+ return { code, title, language: "ts" };
3195
+ }
3107
3196
  function findMatchingBrace(text, startIndex) {
3108
3197
  if (text[startIndex] !== "{")
3109
3198
  return -1;
@@ -3179,27 +3268,47 @@ function processTagContent(result, tag, content) {
3179
3268
  });
3180
3269
  break;
3181
3270
  }
3271
+ case "throws":
3272
+ case "throw":
3273
+ case "exception": {
3274
+ const parsed = parseThrowsContent(trimmedContent);
3275
+ result.throws.push(parsed);
3276
+ result.tags.push({
3277
+ name: "throws",
3278
+ text: trimmedContent,
3279
+ typeAnnotation: parsed.type
3280
+ });
3281
+ break;
3282
+ }
3182
3283
  case "example": {
3183
3284
  const example = processInlineLinks(trimmedContent);
3184
3285
  if (example) {
3185
3286
  result.examples.push(example);
3186
3287
  }
3187
- const langMatch = trimmedContent.match(/^```(\w+)/);
3288
+ const structuredExample = parseExampleContent(trimmedContent);
3289
+ if (structuredExample) {
3290
+ result.structuredExamples.push(structuredExample);
3291
+ }
3188
3292
  result.tags.push({
3189
3293
  name: "example",
3190
3294
  text: example,
3191
- language: langMatch?.[1]
3295
+ language: structuredExample?.language
3192
3296
  });
3193
3297
  break;
3194
3298
  }
3195
3299
  case "see": {
3196
3300
  const linkTargets = extractAllLinkTargets(trimmedContent);
3197
3301
  for (const target of linkTargets) {
3302
+ result.seeAlso.push(target);
3198
3303
  result.tags.push({ name: "link", text: target, reference: target });
3199
3304
  result.tags.push({ name: "see", text: target, reference: target });
3200
3305
  }
3201
3306
  if (linkTargets.length === 0) {
3202
- result.tags.push({ name: "see", text: trimmedContent, reference: trimmedContent });
3307
+ const plainRef = trimmedContent.trim().split(/\s+/)[0];
3308
+ if (plainRef) {
3309
+ result.seeAlso.push(plainRef);
3310
+ }
3311
+ result.tags.push({ name: "see", text: trimmedContent, reference: plainRef || trimmedContent });
3203
3312
  }
3204
3313
  break;
3205
3314
  }
@@ -3327,6 +3436,8 @@ function parseJSDocText(commentText) {
3327
3436
  type: p.type
3328
3437
  })),
3329
3438
  examples: parsed.examples.length > 0 ? parsed.examples : undefined,
3439
+ structuredExamples: parsed.structuredExamples.length > 0 ? parsed.structuredExamples : undefined,
3440
+ seeAlso: parsed.seeAlso.length > 0 ? parsed.seeAlso : undefined,
3330
3441
  tags: parsed.tags.length > 0 ? parsed.tags : undefined,
3331
3442
  rawParamNames: parsed.rawParamNames
3332
3443
  };
@@ -3334,6 +3445,9 @@ function parseJSDocText(commentText) {
3334
3445
  result.returns = parsed.returns.description;
3335
3446
  result.returnsType = parsed.returns.type;
3336
3447
  }
3448
+ if (parsed.throws.length > 0) {
3449
+ result.throws = parsed.throws;
3450
+ }
3337
3451
  return result;
3338
3452
  }
3339
3453
  function extractDestructuredParams(parsedDoc, paramName) {
@@ -3463,6 +3577,23 @@ function extractPresentationMetadata(doc) {
3463
3577
  }
3464
3578
 
3465
3579
  // src/analysis/serializers/classes.ts
3580
+ function extractClassRelations(heritage, parsedDoc) {
3581
+ const relations = [];
3582
+ if (heritage.extends) {
3583
+ relations.push({ type: "extends", target: heritage.extends });
3584
+ }
3585
+ if (heritage.implements) {
3586
+ for (const impl of heritage.implements) {
3587
+ relations.push({ type: "implements", target: impl });
3588
+ }
3589
+ }
3590
+ if (parsedDoc?.seeAlso) {
3591
+ for (const ref of parsedDoc.seeAlso) {
3592
+ relations.push({ type: "see-also", target: ref });
3593
+ }
3594
+ }
3595
+ return relations;
3596
+ }
3466
3597
  function serializeClass(declaration, symbol, context) {
3467
3598
  const { checker, typeRegistry } = context;
3468
3599
  const typeRefs = typeRegistry.getTypeRefs();
@@ -3473,6 +3604,8 @@ function serializeClass(declaration, symbol, context) {
3473
3604
  const parsedDoc = parseJSDocComment(symbol, context.checker);
3474
3605
  const description = parsedDoc?.description ?? getJSDocComment(symbol, context.checker);
3475
3606
  const metadata = extractPresentationMetadata(parsedDoc);
3607
+ const decorators = extractDecorators(declaration);
3608
+ const relations = extractClassRelations(heritage, parsedDoc);
3476
3609
  const exportEntry = {
3477
3610
  id: symbol.getName(),
3478
3611
  name: symbol.getName(),
@@ -3486,7 +3619,9 @@ function serializeClass(declaration, symbol, context) {
3486
3619
  ...heritage.extends ? { extends: heritage.extends } : {},
3487
3620
  ...heritage.implements && heritage.implements.length > 0 ? { implements: heritage.implements } : {},
3488
3621
  tags: parsedDoc?.tags,
3489
- examples: parsedDoc?.examples
3622
+ examples: parsedDoc?.examples,
3623
+ decorators,
3624
+ related: relations.length > 0 ? relations : undefined
3490
3625
  };
3491
3626
  const typeDefinition = {
3492
3627
  id: symbol.getName(),
@@ -3498,7 +3633,8 @@ function serializeClass(declaration, symbol, context) {
3498
3633
  members: members.length > 0 ? members : undefined,
3499
3634
  ...heritage.extends ? { extends: heritage.extends } : {},
3500
3635
  ...heritage.implements && heritage.implements.length > 0 ? { implements: heritage.implements } : {},
3501
- tags: parsedDoc?.tags
3636
+ tags: parsedDoc?.tags,
3637
+ related: relations.length > 0 ? relations : undefined
3502
3638
  };
3503
3639
  return {
3504
3640
  exportEntry,
@@ -3579,7 +3715,8 @@ function serializeClassMembers(declaration, checker, typeRefs, referencedTypes)
3579
3715
  schema,
3580
3716
  description: memberDoc?.description ?? (memberSymbol ? getJSDocComment(memberSymbol, checker) : undefined),
3581
3717
  flags: Object.keys(flags).length > 0 ? flags : undefined,
3582
- tags: memberDoc?.tags
3718
+ tags: memberDoc?.tags,
3719
+ decorators: extractDecorators(member)
3583
3720
  });
3584
3721
  continue;
3585
3722
  }
@@ -3601,7 +3738,8 @@ function serializeClassMembers(declaration, checker, typeRefs, referencedTypes)
3601
3738
  signatures,
3602
3739
  description: methodDoc?.description ?? (memberSymbol ? getJSDocComment(memberSymbol, checker) : undefined),
3603
3740
  flags: getMethodFlags(member),
3604
- tags: methodDoc?.tags
3741
+ tags: methodDoc?.tags,
3742
+ decorators: extractDecorators(member)
3605
3743
  });
3606
3744
  continue;
3607
3745
  }
@@ -3621,7 +3759,8 @@ function serializeClassMembers(declaration, checker, typeRefs, referencedTypes)
3621
3759
  visibility: getMemberVisibility(member.modifiers),
3622
3760
  signatures,
3623
3761
  description: ctorDoc?.description ?? (ctorSymbol ? getJSDocComment(ctorSymbol, checker) : undefined),
3624
- tags: ctorDoc?.tags
3762
+ tags: ctorDoc?.tags,
3763
+ decorators: extractDecorators(member)
3625
3764
  });
3626
3765
  continue;
3627
3766
  }
@@ -3654,7 +3793,8 @@ function serializeClassMembers(declaration, checker, typeRefs, referencedTypes)
3654
3793
  schema,
3655
3794
  description: memberDoc?.description ?? (memberSymbol ? getJSDocComment(memberSymbol, checker) : undefined),
3656
3795
  flags: Object.keys(flags).length > 0 ? flags : undefined,
3657
- tags: memberDoc?.tags
3796
+ tags: memberDoc?.tags,
3797
+ decorators: extractDecorators(primaryMember)
3658
3798
  });
3659
3799
  }
3660
3800
  }
@@ -3662,6 +3802,10 @@ function serializeClassMembers(declaration, checker, typeRefs, referencedTypes)
3662
3802
  }
3663
3803
  function serializeSignature(signature, checker, typeRefs, referencedTypes, doc, symbol) {
3664
3804
  const typeParameters = serializeTypeParameterDeclarations(signature.declaration?.typeParameters, checker, referencedTypes);
3805
+ const throws = doc?.throws?.map((t) => ({
3806
+ type: t.type,
3807
+ description: t.description
3808
+ }));
3665
3809
  return {
3666
3810
  parameters: signature.getParameters().map((param) => {
3667
3811
  const paramDecl = param.valueDeclaration;
@@ -3675,7 +3819,8 @@ function serializeSignature(signature, checker, typeRefs, referencedTypes, doc,
3675
3819
  description: doc?.returns || ""
3676
3820
  },
3677
3821
  description: doc?.description || (symbol ? getJSDocComment(symbol, checker) : undefined),
3678
- typeParameters
3822
+ typeParameters,
3823
+ throws: throws && throws.length > 0 ? throws : undefined
3679
3824
  };
3680
3825
  }
3681
3826
  function getMemberVisibility(modifiers) {
@@ -3793,6 +3938,10 @@ function serializeCallSignatures(signatures, symbol, context, parsedDoc) {
3793
3938
  ...isAsserts ? { asserts: true } : {}
3794
3939
  };
3795
3940
  }
3941
+ const throws = functionDoc?.throws?.map((t) => ({
3942
+ type: t.type,
3943
+ description: t.description
3944
+ }));
3796
3945
  return {
3797
3946
  parameters,
3798
3947
  returns: {
@@ -3803,10 +3952,27 @@ function serializeCallSignatures(signatures, symbol, context, parsedDoc) {
3803
3952
  },
3804
3953
  description: functionDoc?.description || undefined,
3805
3954
  typeParameters,
3806
- overloadIndex: signatures.length > 1 ? index : undefined
3955
+ overloadIndex: signatures.length > 1 ? index : undefined,
3956
+ throws: throws && throws.length > 0 ? throws : undefined
3807
3957
  };
3808
3958
  });
3809
3959
  }
3960
+ function extractFunctionRelations(declaration, checker, parsedDoc) {
3961
+ const relations = [];
3962
+ if (declaration.type && ts2.isTypeReferenceNode(declaration.type)) {
3963
+ const typeName = declaration.type.typeName.getText();
3964
+ const builtIns = ["Promise", "Array", "Map", "Set", "Record", "Partial", "Required", "Pick", "Omit"];
3965
+ if (!builtIns.includes(typeName)) {
3966
+ relations.push({ type: "returns", target: typeName });
3967
+ }
3968
+ }
3969
+ if (parsedDoc?.seeAlso) {
3970
+ for (const ref of parsedDoc.seeAlso) {
3971
+ relations.push({ type: "see-also", target: ref });
3972
+ }
3973
+ }
3974
+ return relations;
3975
+ }
3810
3976
  function serializeFunctionExport(declaration, symbol, context) {
3811
3977
  const { checker } = context;
3812
3978
  const funcSymbol = checker.getSymbolAtLocation(declaration.name || declaration);
@@ -3815,6 +3981,7 @@ function serializeFunctionExport(declaration, symbol, context) {
3815
3981
  const metadata = extractPresentationMetadata(parsedDoc);
3816
3982
  const type = checker.getTypeAtLocation(declaration.name || declaration);
3817
3983
  const callSignatures = type.getCallSignatures();
3984
+ const relations = extractFunctionRelations(declaration, checker, parsedDoc);
3818
3985
  return {
3819
3986
  id: symbol.getName(),
3820
3987
  name: symbol.getName(),
@@ -3825,7 +3992,8 @@ function serializeFunctionExport(declaration, symbol, context) {
3825
3992
  description,
3826
3993
  source: getSourceLocation(declaration),
3827
3994
  examples: parsedDoc?.examples,
3828
- tags: parsedDoc?.tags
3995
+ tags: parsedDoc?.tags,
3996
+ related: relations.length > 0 ? relations : undefined
3829
3997
  };
3830
3998
  }
3831
3999
 
@@ -3913,6 +4081,25 @@ function serializeInterfaceMembers(declaration, checker, typeRefs, referencedTyp
3913
4081
  }
3914
4082
  return members;
3915
4083
  }
4084
+ function extractInterfaceRelations(declaration, parsedDoc) {
4085
+ const relations = [];
4086
+ if (declaration.heritageClauses) {
4087
+ for (const clause of declaration.heritageClauses) {
4088
+ if (clause.token === ts2.SyntaxKind.ExtendsKeyword) {
4089
+ for (const type of clause.types) {
4090
+ const typeName = type.expression.getText();
4091
+ relations.push({ type: "extends", target: typeName });
4092
+ }
4093
+ }
4094
+ }
4095
+ }
4096
+ if (parsedDoc?.seeAlso) {
4097
+ for (const ref of parsedDoc.seeAlso) {
4098
+ relations.push({ type: "see-also", target: ref });
4099
+ }
4100
+ }
4101
+ return relations;
4102
+ }
3916
4103
  function serializeInterface(declaration, symbol, context) {
3917
4104
  const { checker, typeRegistry } = context;
3918
4105
  const parsedDoc = parseJSDocComment(symbol, checker);
@@ -3922,6 +4109,7 @@ function serializeInterface(declaration, symbol, context) {
3922
4109
  const typeRefs = typeRegistry.getTypeRefs();
3923
4110
  const typeParameters = serializeTypeParameterDeclarations(declaration.typeParameters, checker, referencedTypes);
3924
4111
  const members = serializeInterfaceMembers(declaration, checker, typeRefs, referencedTypes);
4112
+ const relations = extractInterfaceRelations(declaration, parsedDoc);
3925
4113
  const exportEntry = {
3926
4114
  id: symbol.getName(),
3927
4115
  name: symbol.getName(),
@@ -3933,7 +4121,8 @@ function serializeInterface(declaration, symbol, context) {
3933
4121
  members,
3934
4122
  typeParameters,
3935
4123
  tags: parsedDoc?.tags,
3936
- examples: parsedDoc?.examples
4124
+ examples: parsedDoc?.examples,
4125
+ related: relations.length > 0 ? relations : undefined
3937
4126
  };
3938
4127
  const schema = interfaceToSchema(declaration, checker, typeRefs, referencedTypes);
3939
4128
  const typeDefinition = {
@@ -3945,7 +4134,8 @@ function serializeInterface(declaration, symbol, context) {
3945
4134
  members,
3946
4135
  description,
3947
4136
  source: getSourceLocation(declaration),
3948
- tags: parsedDoc?.tags
4137
+ tags: parsedDoc?.tags,
4138
+ related: relations.length > 0 ? relations : undefined
3949
4139
  };
3950
4140
  return {
3951
4141
  exportEntry,
@@ -4095,6 +4285,8 @@ function serializeNamespace(declaration, symbol, context) {
4095
4285
  const description = parsedDoc?.description ?? getJSDocComment(symbol, checker);
4096
4286
  const metadata = extractPresentationMetadata(parsedDoc);
4097
4287
  const members = extractNamespaceMembers(declaration, checker);
4288
+ const isAugmentation = ts2.isStringLiteral(declaration.name);
4289
+ const augmentedModule = isAugmentation ? declaration.name.text : undefined;
4098
4290
  return {
4099
4291
  id: symbol.getName(),
4100
4292
  name: symbol.getName(),
@@ -4105,7 +4297,9 @@ function serializeNamespace(declaration, symbol, context) {
4105
4297
  source: getSourceLocation(declaration),
4106
4298
  members: members.length > 0 ? members : undefined,
4107
4299
  tags: parsedDoc?.tags,
4108
- examples: parsedDoc?.examples
4300
+ examples: parsedDoc?.examples,
4301
+ isAugmentation: isAugmentation || undefined,
4302
+ augmentedModule
4109
4303
  };
4110
4304
  }
4111
4305
  function extractNamespaceMembers(declaration, checker) {
@@ -4197,6 +4391,46 @@ function extractNamespaceMembers(declaration, checker) {
4197
4391
  }
4198
4392
 
4199
4393
  // src/analysis/serializers/type-aliases.ts
4394
+ function analyzeTypeAliasKind(typeNode) {
4395
+ if (ts2.isConditionalTypeNode(typeNode)) {
4396
+ return {
4397
+ typeAliasKind: "conditional",
4398
+ conditionalType: {
4399
+ checkType: typeNode.checkType.getText(),
4400
+ extendsType: typeNode.extendsType.getText(),
4401
+ trueType: typeNode.trueType.getText(),
4402
+ falseType: typeNode.falseType.getText()
4403
+ }
4404
+ };
4405
+ }
4406
+ if (ts2.isMappedTypeNode(typeNode)) {
4407
+ const readonlyToken = typeNode.readonlyToken;
4408
+ const questionToken = typeNode.questionToken;
4409
+ return {
4410
+ typeAliasKind: "mapped",
4411
+ mappedType: {
4412
+ typeParameter: typeNode.typeParameter.getText(),
4413
+ nameType: typeNode.nameType?.getText(),
4414
+ valueType: typeNode.type?.getText(),
4415
+ readonly: readonlyToken ? readonlyToken.kind === ts2.SyntaxKind.MinusToken ? "-" : readonlyToken.kind === ts2.SyntaxKind.PlusToken ? "+" : true : undefined,
4416
+ optional: questionToken ? questionToken.kind === ts2.SyntaxKind.MinusToken ? "-" : questionToken.kind === ts2.SyntaxKind.PlusToken ? "+" : true : undefined
4417
+ }
4418
+ };
4419
+ }
4420
+ if (ts2.isTemplateLiteralTypeNode(typeNode)) {
4421
+ return { typeAliasKind: "template-literal" };
4422
+ }
4423
+ if (containsInferType(typeNode)) {
4424
+ return { typeAliasKind: "infer" };
4425
+ }
4426
+ return { typeAliasKind: "alias" };
4427
+ }
4428
+ function containsInferType(node) {
4429
+ if (ts2.isInferTypeNode(node)) {
4430
+ return true;
4431
+ }
4432
+ return ts2.forEachChild(node, containsInferType) ?? false;
4433
+ }
4200
4434
  function serializeTypeAlias(declaration, symbol, context) {
4201
4435
  const { checker, typeRegistry } = context;
4202
4436
  const typeRefs = typeRegistry.getTypeRefs();
@@ -4205,6 +4439,7 @@ function serializeTypeAlias(declaration, symbol, context) {
4205
4439
  const description = parsedDoc?.description ?? getJSDocComment(symbol, checker);
4206
4440
  const metadata = extractPresentationMetadata(parsedDoc);
4207
4441
  const typeParameters = serializeTypeParameterDeclarations(declaration.typeParameters, checker, referencedTypes);
4442
+ const typeAnalysis = analyzeTypeAliasKind(declaration.type);
4208
4443
  const exportEntry = {
4209
4444
  id: symbol.getName(),
4210
4445
  name: symbol.getName(),
@@ -4216,7 +4451,10 @@ function serializeTypeAlias(declaration, symbol, context) {
4216
4451
  source: getSourceLocation(declaration),
4217
4452
  typeParameters,
4218
4453
  tags: parsedDoc?.tags,
4219
- examples: parsedDoc?.examples
4454
+ examples: parsedDoc?.examples,
4455
+ typeAliasKind: typeAnalysis.typeAliasKind !== "alias" ? typeAnalysis.typeAliasKind : undefined,
4456
+ conditionalType: typeAnalysis.conditionalType,
4457
+ mappedType: typeAnalysis.mappedType
4220
4458
  };
4221
4459
  const aliasType = checker.getTypeAtLocation(declaration.type);
4222
4460
  const aliasName = symbol.getName();
@@ -4235,7 +4473,10 @@ function serializeTypeAlias(declaration, symbol, context) {
4235
4473
  kind: "type",
4236
4474
  description,
4237
4475
  source: getSourceLocation(declaration),
4238
- tags: parsedDoc?.tags
4476
+ tags: parsedDoc?.tags,
4477
+ typeAliasKind: typeAnalysis.typeAliasKind !== "alias" ? typeAnalysis.typeAliasKind : undefined,
4478
+ conditionalType: typeAnalysis.conditionalType,
4479
+ mappedType: typeAnalysis.mappedType
4239
4480
  };
4240
4481
  if (typeof aliasSchema === "string") {
4241
4482
  typeDefinition.type = aliasSchema;
@@ -5074,7 +5315,9 @@ function generateAssertionFix(drift, exportEntry) {
5074
5315
  const oldValue = oldValueMatch?.[1];
5075
5316
  if (!oldValue)
5076
5317
  return null;
5077
- const updatedExample = oldExample.replace(new RegExp(`//\\s*=>\\s*${escapeRegex(oldValue)}`, "g"), `// => ${newValue}`);
5318
+ const oldExampleCode = typeof oldExample === "string" ? oldExample : oldExample.code;
5319
+ const updatedCode = oldExampleCode.replace(new RegExp(`//\\s*=>\\s*${escapeRegex(oldValue)}`, "g"), `// => ${newValue}`);
5320
+ const updatedExample = typeof oldExample === "string" ? updatedCode : { ...oldExample, code: updatedCode };
5078
5321
  const updatedExamples = [...examples];
5079
5322
  updatedExamples[exampleIndex] = updatedExample;
5080
5323
  return {
@@ -5406,7 +5649,7 @@ function serializeJSDoc(patch, indent = "") {
5406
5649
  }
5407
5650
  lines.push(tagLine);
5408
5651
  }
5409
- if (patch.deprecated && patch.deprecated !== false) {
5652
+ if (patch.deprecated && typeof patch.deprecated === "string") {
5410
5653
  lines.push(`@deprecated ${patch.deprecated}`);
5411
5654
  }
5412
5655
  if (patch.examples) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doccov/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "DocCov SDK - Documentation coverage and drift detection for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
@@ -39,7 +39,7 @@
39
39
  "dist"
40
40
  ],
41
41
  "dependencies": {
42
- "@openpkg-ts/spec": "^0.5.0",
42
+ "@openpkg-ts/spec": "^0.7.0",
43
43
  "@vercel/sandbox": "^1.0.3",
44
44
  "mdast": "^3.0.0",
45
45
  "remark-mdx": "^3.1.0",