@doccov/sdk 0.5.6 → 0.5.7

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/index.d.ts CHANGED
@@ -159,8 +159,10 @@ interface DocsImpact {
159
159
  interface DocsImpactResult {
160
160
  /** Files with impacted references */
161
161
  impactedFiles: DocsImpact[];
162
- /** New exports that have no documentation */
162
+ /** New exports (from this diff) that have no documentation */
163
163
  missingDocs: string[];
164
+ /** ALL exports from the spec that have no documentation in the scanned files */
165
+ allUndocumented: string[];
164
166
  /** Statistics */
165
167
  stats: {
166
168
  /** Total markdown files scanned */
@@ -171,6 +173,10 @@ interface DocsImpactResult {
171
173
  referencesFound: number;
172
174
  /** References impacted by changes */
173
175
  impactedReferences: number;
176
+ /** Total exports in the spec */
177
+ totalExports: number;
178
+ /** Exports found documented in markdown */
179
+ documentedExports: number;
174
180
  };
175
181
  }
176
182
  /**
@@ -255,7 +261,7 @@ declare function getDocumentedExports(markdownFiles: MarkdownDocFile[], exportNa
255
261
  * Get all exports that lack documentation
256
262
  */
257
263
  declare function getUndocumentedExports(markdownFiles: MarkdownDocFile[], exportNames: string[]): string[];
258
- import { OpenPkg as OpenPkg3, SpecDiff as SpecDiff2 } from "@openpkg-ts/spec";
264
+ import { CategorizedBreaking, OpenPkg as OpenPkg3, SpecDiff as SpecDiff2 } from "@openpkg-ts/spec";
259
265
  /**
260
266
  * Extended spec diff result with docs impact
261
267
  */
@@ -264,6 +270,8 @@ interface SpecDiffWithDocs extends SpecDiff2 {
264
270
  docsImpact?: DocsImpactResult;
265
271
  /** Member-level changes for classes (methods added/removed/changed) */
266
272
  memberChanges?: MemberChange[];
273
+ /** Breaking changes categorized by severity (high/medium/low) */
274
+ categorizedBreaking?: CategorizedBreaking[];
267
275
  }
268
276
  /**
269
277
  * Options for diffSpecWithDocs
@@ -756,4 +764,4 @@ declare function readPackageJson(fs: FileSystem, dir: string): Promise<PackageJs
756
764
  * ```
757
765
  */
758
766
  declare function analyzeProject2(fs: FileSystem, options?: AnalyzeProjectOptions): Promise<ProjectInfo>;
759
- export { serializeJSDoc, safeParseJson, runExamplesWithPackage, runExamples, runExample, readPackageJson, parseMarkdownFiles, parseMarkdownFile, parseJSDocToPatch, parseAssertions, mergeFixes, isFixableDrift, isExecutableLang, hasNonAssertionComments, hasDocsImpact, hasDocsForExport, getUndocumentedExports, getRunCommand, getPrimaryBuildScript, getInstallCommand, getDocumentedExports, getDocsImpactSummary, generateFixesForExport, generateFix, formatPackageList, findRemovedReferences, findPackageByName, findJSDocLocation, findExportReferences, findDeprecatedReferences, extractPackageSpec, extractImports, extractFunctionCalls, diffSpecWithDocs, detectPackageManager, detectMonorepo, detectExampleRuntimeErrors, detectExampleAssertionFailures, detectEntryPoint, detectBuildInfo, createSourceFile, categorizeDrifts, blockReferencesExport, applyPatchToJSDoc, applyEdits, analyzeProject2 as analyzeProject, analyzeFile, analyzeDocsImpact, analyze, WorkspacePackage, SpecDiffWithDocs, SandboxFileSystem, RunExamplesWithPackageResult, RunExamplesWithPackageOptions, RunExampleOptions, ProjectInfo, PackageManagerInfo, PackageManager, PackageJson, PackageExports, OpenPkgSpec, OpenPkgOptions, OpenPkg4 as OpenPkg, NodeFileSystem, MonorepoType, MonorepoInfo, MarkdownDocFile, MarkdownCodeBlock, JSDocTag, JSDocReturn, JSDocPatch, JSDocParam, JSDocEdit, FixType, FixSuggestion, FilterOptions, FileSystem, ExportReference, ExampleRunResult, EntryPointSource, EntryPointInfo, DocsImpactResult, DocsImpactReference, DocsImpact, DocsChangeType, DocCovOptions, DocCov, DiffWithDocsOptions, Diagnostic, BuildInfo, ApplyEditsResult, AnalyzeProjectOptions, AnalyzeOptions, AnalysisResult };
767
+ export { serializeJSDoc, safeParseJson, runExamplesWithPackage, runExamples, runExample, readPackageJson, parseMarkdownFiles, parseMarkdownFile, parseJSDocToPatch, parseAssertions, mergeFixes, isFixableDrift, isExecutableLang, hasNonAssertionComments, hasDocsImpact, hasDocsForExport, getUndocumentedExports, getRunCommand, getPrimaryBuildScript, getInstallCommand, getDocumentedExports, getDocsImpactSummary, generateFixesForExport, generateFix, formatPackageList, findRemovedReferences, findPackageByName, findJSDocLocation, findExportReferences, findDeprecatedReferences, extractPackageSpec, extractImports, extractFunctionCalls, diffSpecWithDocs, detectPackageManager, detectMonorepo, detectExampleRuntimeErrors, detectExampleAssertionFailures, detectEntryPoint, detectBuildInfo, createSourceFile, categorizeDrifts, blockReferencesExport, applyPatchToJSDoc, applyEdits, analyzeProject2 as analyzeProject, analyzeFile, analyzeDocsImpact, analyze, WorkspacePackage, SpecDiffWithDocs, SandboxFileSystem, RunExamplesWithPackageResult, RunExamplesWithPackageOptions, RunExampleOptions, ProjectInfo, PackageManagerInfo, PackageManager, PackageJson, PackageExports, OpenPkgSpec, OpenPkgOptions, OpenPkg4 as OpenPkg, NodeFileSystem, MonorepoType, MonorepoInfo, MemberChange, MarkdownDocFile, MarkdownCodeBlock, JSDocTag, JSDocReturn, JSDocPatch, JSDocParam, JSDocEdit, FixType, FixSuggestion, FilterOptions, FileSystem, ExportReference, ExampleRunResult, EntryPointSource, EntryPointInfo, DocsImpactResult, DocsImpactReference, DocsImpact, DocsChangeType, DocCovOptions, DocCov, DiffWithDocsOptions, Diagnostic, BuildInfo, ApplyEditsResult, AnalyzeProjectOptions, AnalyzeOptions, AnalysisResult };
package/dist/index.js CHANGED
@@ -1201,8 +1201,11 @@ function blockReferencesExport(block, exportName) {
1201
1201
  return calls.includes(exportName);
1202
1202
  }
1203
1203
  // src/markdown/analyzer.ts
1204
- function getChangeType(exportName, diff) {
1204
+ function getChangeType(exportName, diff, newExportNames) {
1205
1205
  if (diff.breaking.includes(exportName)) {
1206
+ if (!newExportNames.includes(exportName)) {
1207
+ return "removed";
1208
+ }
1206
1209
  return "signature-changed";
1207
1210
  }
1208
1211
  return null;
@@ -1284,7 +1287,7 @@ function analyzeDocsImpact(diff, markdownFiles, newExportNames = [], memberChang
1284
1287
  if (exportsWithoutMemberChanges.length > 0) {
1285
1288
  const refs = findExportReferences([{ ...mdFile, codeBlocks: [block] }], exportsWithoutMemberChanges);
1286
1289
  for (const ref of refs) {
1287
- const changeType = getChangeType(ref.exportName, diff);
1290
+ const changeType = getChangeType(ref.exportName, diff, newExportNames);
1288
1291
  if (!changeType)
1289
1292
  continue;
1290
1293
  const refKey = `${ref.file}:${ref.line}:${ref.exportName}`;
@@ -1301,17 +1304,18 @@ function analyzeDocsImpact(diff, markdownFiles, newExportNames = [], memberChang
1301
1304
  }
1302
1305
  }
1303
1306
  }
1304
- const documentedExports = new Set;
1307
+ const documentedExportsSet = new Set;
1305
1308
  for (const file of markdownFiles) {
1306
1309
  for (const block of file.codeBlocks) {
1307
1310
  for (const exportName of newExportNames) {
1308
1311
  if (block.code.includes(exportName)) {
1309
- documentedExports.add(exportName);
1312
+ documentedExportsSet.add(exportName);
1310
1313
  }
1311
1314
  }
1312
1315
  }
1313
1316
  }
1314
- const missingDocs = diff.nonBreaking.filter((name) => !documentedExports.has(name));
1317
+ const missingDocs = diff.nonBreaking.filter((name) => !documentedExportsSet.has(name));
1318
+ const allUndocumented = newExportNames.filter((name) => !documentedExportsSet.has(name));
1315
1319
  const totalCodeBlocks = markdownFiles.reduce((sum, f) => sum + f.codeBlocks.length, 0);
1316
1320
  const allReferences = findExportReferences(markdownFiles, [...changedExports, ...diff.nonBreaking]);
1317
1321
  let impactedReferences = 0;
@@ -1321,11 +1325,14 @@ function analyzeDocsImpact(diff, markdownFiles, newExportNames = [], memberChang
1321
1325
  return {
1322
1326
  impactedFiles: Array.from(impactByFile.values()),
1323
1327
  missingDocs,
1328
+ allUndocumented,
1324
1329
  stats: {
1325
1330
  filesScanned: markdownFiles.length,
1326
1331
  codeBlocksFound: totalCodeBlocks,
1327
1332
  referencesFound: allReferences.length,
1328
- impactedReferences
1333
+ impactedReferences,
1334
+ totalExports: newExportNames.length,
1335
+ documentedExports: documentedExportsSet.size
1329
1336
  }
1330
1337
  };
1331
1338
  }
@@ -1405,7 +1412,17 @@ function diffMemberChanges(oldSpec, newSpec, changedClassNames) {
1405
1412
  }
1406
1413
  }
1407
1414
  }
1408
- return changes;
1415
+ return deduplicateMemberChanges(changes);
1416
+ }
1417
+ function deduplicateMemberChanges(changes) {
1418
+ const seen = new Set;
1419
+ return changes.filter((mc) => {
1420
+ const key = `${mc.className}:${mc.memberName}:${mc.changeType}`;
1421
+ if (seen.has(key))
1422
+ return false;
1423
+ seen.add(key);
1424
+ return true;
1425
+ });
1409
1426
  }
1410
1427
  function toExportMap(exports) {
1411
1428
  const map = new Map;
@@ -1446,10 +1463,32 @@ function formatSignature(member) {
1446
1463
  const sig = member.signatures[0];
1447
1464
  const params = sig.parameters?.map((p) => {
1448
1465
  const optional = p.required === false ? "?" : "";
1449
- return `${p.name}${optional}`;
1466
+ const typeName = extractTypeName(p.schema);
1467
+ return typeName ? `${p.name}${optional}: ${typeName}` : `${p.name}${optional}`;
1450
1468
  }) ?? [];
1451
1469
  return `${member.name}(${params.join(", ")})`;
1452
1470
  }
1471
+ function extractTypeName(schema) {
1472
+ if (!schema || typeof schema !== "object") {
1473
+ return;
1474
+ }
1475
+ const s = schema;
1476
+ if (typeof s.$ref === "string") {
1477
+ const parts = s.$ref.split("/");
1478
+ return parts[parts.length - 1];
1479
+ }
1480
+ if (typeof s.type === "string") {
1481
+ return s.type;
1482
+ }
1483
+ if (typeof s.tsType === "string") {
1484
+ const tsType = s.tsType;
1485
+ if (tsType.length > 30) {
1486
+ return tsType.slice(0, 27) + "...";
1487
+ }
1488
+ return tsType;
1489
+ }
1490
+ return;
1491
+ }
1453
1492
  function hasSignatureChanged(oldMember, newMember) {
1454
1493
  const oldSigs = oldMember.signatures ?? [];
1455
1494
  const newSigs = newMember.signatures ?? [];
@@ -1543,14 +1582,19 @@ function splitCamelCase(str) {
1543
1582
  return str.replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase().split(" ");
1544
1583
  }
1545
1584
  // src/markdown/diff-with-docs.ts
1546
- import { diffSpec } from "@openpkg-ts/spec";
1585
+ import {
1586
+ categorizeBreakingChanges,
1587
+ diffSpec
1588
+ } from "@openpkg-ts/spec";
1547
1589
  function diffSpecWithDocs(oldSpec, newSpec, options = {}) {
1548
1590
  const baseDiff = diffSpec(oldSpec, newSpec);
1549
1591
  const memberChanges = diffMemberChanges(oldSpec, newSpec, baseDiff.breaking);
1592
+ const categorizedBreaking = categorizeBreakingChanges(baseDiff.breaking, oldSpec, newSpec, memberChanges);
1550
1593
  if (!options.markdownFiles?.length) {
1551
1594
  return {
1552
1595
  ...baseDiff,
1553
- memberChanges: memberChanges.length > 0 ? memberChanges : undefined
1596
+ memberChanges: memberChanges.length > 0 ? memberChanges : undefined,
1597
+ categorizedBreaking: categorizedBreaking.length > 0 ? categorizedBreaking : undefined
1554
1598
  };
1555
1599
  }
1556
1600
  const newExportNames = newSpec.exports?.map((e) => e.name) ?? [];
@@ -1558,7 +1602,8 @@ function diffSpecWithDocs(oldSpec, newSpec, options = {}) {
1558
1602
  return {
1559
1603
  ...baseDiff,
1560
1604
  docsImpact,
1561
- memberChanges: memberChanges.length > 0 ? memberChanges : undefined
1605
+ memberChanges: memberChanges.length > 0 ? memberChanges : undefined,
1606
+ categorizedBreaking: categorizedBreaking.length > 0 ? categorizedBreaking : undefined
1562
1607
  };
1563
1608
  }
1564
1609
  function hasDocsImpact(diff) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doccov/sdk",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
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.3.1",
42
+ "@openpkg-ts/spec": "^0.4.0",
43
43
  "@vercel/sandbox": "^1.0.3",
44
44
  "mdast": "^3.0.0",
45
45
  "remark-mdx": "^3.1.0",