@doccov/sdk 0.24.2 → 0.25.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/analysis/index.d.ts +61 -83
- package/dist/analysis/index.js +15 -62
- package/dist/index.d.ts +74 -76
- package/dist/index.js +23 -149
- package/dist/shared/{chunk-p1stkhse.js → chunk-e9mvnrys.js} +184 -95
- package/package.json +1 -1
package/dist/analysis/index.d.ts
CHANGED
|
@@ -5,7 +5,21 @@ interface DetectedSchemaEntry {
|
|
|
5
5
|
schema: Record<string, unknown>;
|
|
6
6
|
vendor: string;
|
|
7
7
|
}
|
|
8
|
-
import {
|
|
8
|
+
import { DocCovSpec } from "@doccov/spec";
|
|
9
|
+
import { OpenPkg } from "@openpkg-ts/spec";
|
|
10
|
+
type OpenPkgSpec = OpenPkg;
|
|
11
|
+
interface BuildDocCovOptions {
|
|
12
|
+
openpkgPath: string;
|
|
13
|
+
openpkg: OpenPkgSpec;
|
|
14
|
+
packagePath?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Build a DocCov spec from an OpenPkg spec.
|
|
18
|
+
*
|
|
19
|
+
* @param options - Build options
|
|
20
|
+
* @returns DocCov specification with coverage analysis
|
|
21
|
+
*/
|
|
22
|
+
declare function buildDocCovSpec(options: BuildDocCovOptions): DocCovSpec;
|
|
9
23
|
/**
|
|
10
24
|
* All possible drift type identifiers.
|
|
11
25
|
*/
|
|
@@ -20,11 +34,6 @@ type SpecDocDrift = {
|
|
|
20
34
|
* Drift categories group related drift types for progressive disclosure.
|
|
21
35
|
*/
|
|
22
36
|
type DriftCategory = "structural" | "semantic" | "example";
|
|
23
|
-
type SpecDocsMetadata = {
|
|
24
|
-
coverageScore?: number;
|
|
25
|
-
missing?: string[];
|
|
26
|
-
drift?: SpecDocDrift[];
|
|
27
|
-
};
|
|
28
37
|
/**
|
|
29
38
|
* Result of computing drift for a single export.
|
|
30
39
|
*/
|
|
@@ -72,7 +81,6 @@ interface DriftSummary {
|
|
|
72
81
|
byCategory: Record<DriftCategory, number>;
|
|
73
82
|
fixable: number;
|
|
74
83
|
}
|
|
75
|
-
import { OpenPkg as OpenPkg2, SpecExport as SpecExport7 } from "@openpkg-ts/spec";
|
|
76
84
|
/**
|
|
77
85
|
* Categorize a single drift issue.
|
|
78
86
|
*
|
|
@@ -136,8 +144,6 @@ declare function getDriftSummary(drifts: SpecDocDrift[]): DriftSummary;
|
|
|
136
144
|
*/
|
|
137
145
|
declare function formatDriftSummaryLine(summary: DriftSummary): string;
|
|
138
146
|
import { SpecExport } from "@openpkg-ts/spec";
|
|
139
|
-
import { OpenPkg } from "@openpkg-ts/spec";
|
|
140
|
-
type OpenPkgSpec = OpenPkg;
|
|
141
147
|
/**
|
|
142
148
|
* Build a registry of all export/type names for cross-reference validation.
|
|
143
149
|
*/
|
|
@@ -234,80 +240,49 @@ declare function hasNonAssertionComments(code: string): boolean;
|
|
|
234
240
|
* Detect assertion failures by comparing stdout to expected values.
|
|
235
241
|
*/
|
|
236
242
|
declare function detectExampleAssertionFailures(entry: SpecExport2, runtimeResults: Map<number, ExampleRunResult>): SpecDocDrift[];
|
|
243
|
+
import { DocCovDrift, DocCovSpec as DocCovSpec2, ExportAnalysis, MissingDocRule } from "@doccov/spec";
|
|
244
|
+
import { SpecExport as SpecExport7 } from "@openpkg-ts/spec";
|
|
237
245
|
/**
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
};
|
|
244
|
-
/**
|
|
245
|
-
* Extended docs metadata.
|
|
246
|
+
* Get the full analysis data for an export.
|
|
247
|
+
*
|
|
248
|
+
* @param exp - The to look up
|
|
249
|
+
* @param doccov - The DocCov spec containing analysis data
|
|
250
|
+
* @returns Export analysis or undefined if not found
|
|
246
251
|
*/
|
|
247
|
-
|
|
252
|
+
declare function getExportAnalysis(exp: SpecExport7, doccov: DocCovSpec2): ExportAnalysis | undefined;
|
|
248
253
|
/**
|
|
249
|
-
*
|
|
250
|
-
*
|
|
254
|
+
* Get the coverage score for an export.
|
|
255
|
+
*
|
|
256
|
+
* @param exp - The to look up
|
|
257
|
+
* @param doccov - The DocCov spec containing analysis data
|
|
258
|
+
* @returns Coverage score (0-100) or 100 if not found
|
|
251
259
|
*/
|
|
252
|
-
|
|
253
|
-
exports: EnrichedExport[];
|
|
254
|
-
docs?: EnrichedDocsMetadata;
|
|
255
|
-
/** Drift summary with category breakdown (if drift exists) */
|
|
256
|
-
driftSummary?: DriftSummary;
|
|
257
|
-
};
|
|
258
|
-
interface EnrichOptions {
|
|
259
|
-
/**
|
|
260
|
-
* Per-drift issues to include in enrichment.
|
|
261
|
-
* Map from ID to drift issues.
|
|
262
|
-
*/
|
|
263
|
-
driftByExport?: Map<string, SpecDocDrift[]>;
|
|
264
|
-
}
|
|
260
|
+
declare function getExportScore(exp: SpecExport7, doccov: DocCovSpec2): number;
|
|
265
261
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* Computes coverage scores and detects drift issues.
|
|
269
|
-
*
|
|
270
|
-
* @param spec - The pure OpenPkg spec to enrich
|
|
271
|
-
* @param options - Optional enrichment configuration
|
|
272
|
-
* @returns An enriched spec with documentation metadata
|
|
273
|
-
*
|
|
274
|
-
* @example
|
|
275
|
-
* ```ts
|
|
276
|
-
* import { DocCov, enrichSpec } from '@doccov/sdk';
|
|
277
|
-
*
|
|
278
|
-
* const doccov = new DocCov();
|
|
279
|
-
* const { spec } = await doccov.analyzeFileWithDiagnostics('src/index.ts');
|
|
262
|
+
* Get drift issues for an export.
|
|
280
263
|
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
264
|
+
* @param exp - The to look up
|
|
265
|
+
* @param doccov - The DocCov spec containing analysis data
|
|
266
|
+
* @returns Array of drift issues or empty array if none
|
|
284
267
|
*/
|
|
285
|
-
declare function
|
|
268
|
+
declare function getExportDrift(exp: SpecExport7, doccov: DocCovSpec2): DocCovDrift[];
|
|
286
269
|
/**
|
|
287
|
-
*
|
|
270
|
+
* Get missing documentation rules for an export.
|
|
271
|
+
*
|
|
272
|
+
* @param exp - The to look up
|
|
273
|
+
* @param doccov - The DocCov spec containing analysis data
|
|
274
|
+
* @returns Array of missing rule IDs or empty array if none
|
|
288
275
|
*/
|
|
289
|
-
|
|
290
|
-
coverageDelta: number;
|
|
291
|
-
oldCoverage: number;
|
|
292
|
-
newCoverage: number;
|
|
293
|
-
newUndocumented: string[];
|
|
294
|
-
improvedExports: string[];
|
|
295
|
-
regressedExports: string[];
|
|
296
|
-
driftIntroduced: number;
|
|
297
|
-
driftResolved: number;
|
|
298
|
-
}
|
|
299
|
-
type ExportWithDocs = EnrichedExport & {
|
|
300
|
-
docs?: SpecDocsMetadata;
|
|
301
|
-
};
|
|
302
|
-
type SpecWithDocs = EnrichedOpenPkg & {
|
|
303
|
-
docs?: SpecDocsMetadata;
|
|
304
|
-
exports: ExportWithDocs[];
|
|
305
|
-
};
|
|
276
|
+
declare function getExportMissing(exp: SpecExport7, doccov: DocCovSpec2): MissingDocRule[];
|
|
306
277
|
/**
|
|
307
|
-
*
|
|
278
|
+
* Check if an has complete documentation.
|
|
279
|
+
*
|
|
280
|
+
* @param exp - The to check
|
|
281
|
+
* @param doccov - The DocCov spec containing analysis data
|
|
282
|
+
* @returns True if has 100% coverage and no drift
|
|
308
283
|
*/
|
|
309
|
-
declare function
|
|
310
|
-
import { OpenPkg as
|
|
284
|
+
declare function isExportFullyDocumented(exp: SpecExport7, doccov: DocCovSpec2): boolean;
|
|
285
|
+
import { OpenPkg as OpenPkg2 } from "@openpkg-ts/spec";
|
|
311
286
|
/** Directory for storing history snapshots */
|
|
312
287
|
declare const HISTORY_DIR = ".doccov/history";
|
|
313
288
|
/**
|
|
@@ -402,7 +377,7 @@ interface ExtendedTrendAnalysis {
|
|
|
402
377
|
/**
|
|
403
378
|
* Compute a coverage snapshot from an OpenPkg spec.
|
|
404
379
|
*/
|
|
405
|
-
declare function computeSnapshot(spec:
|
|
380
|
+
declare function computeSnapshot(spec: OpenPkg2, options?: {
|
|
406
381
|
commit?: string;
|
|
407
382
|
branch?: string;
|
|
408
383
|
}): CoverageSnapshot;
|
|
@@ -428,7 +403,7 @@ declare function loadSnapshots(cwd: string): CoverageSnapshot[];
|
|
|
428
403
|
* @param options - Optional git metadata
|
|
429
404
|
* @returns Trend data with history and delta
|
|
430
405
|
*/
|
|
431
|
-
declare function getTrend(spec:
|
|
406
|
+
declare function getTrend(spec: OpenPkg2, cwd: string, options?: {
|
|
432
407
|
commit?: string;
|
|
433
408
|
branch?: string;
|
|
434
409
|
}): CoverageTrend;
|
|
@@ -485,12 +460,13 @@ declare function generateWeeklySummaries(snapshots: CoverageSnapshot[]): WeeklyS
|
|
|
485
460
|
* @param options - Analysis options
|
|
486
461
|
* @returns Extended trend analysis
|
|
487
462
|
*/
|
|
488
|
-
declare function getExtendedTrend(spec:
|
|
463
|
+
declare function getExtendedTrend(spec: OpenPkg2, cwd: string, options?: {
|
|
489
464
|
commit?: string;
|
|
490
465
|
branch?: string;
|
|
491
466
|
tier?: RetentionTier;
|
|
492
467
|
}): ExtendedTrendAnalysis;
|
|
493
|
-
import {
|
|
468
|
+
import { DocCovSpec as DocCovSpec3 } from "@doccov/spec";
|
|
469
|
+
import { OpenPkg as OpenPkg3 } from "@openpkg-ts/spec";
|
|
494
470
|
/**
|
|
495
471
|
* Drift summary with category breakdown.
|
|
496
472
|
*/
|
|
@@ -601,6 +577,7 @@ interface DocCovReport {
|
|
|
601
577
|
* Generate a DocCov report from an OpenPkg spec.
|
|
602
578
|
*
|
|
603
579
|
* @param spec - The pure OpenPkg spec to analyze
|
|
580
|
+
* @param openpkgPath - Path to the openpkg spec file (for source tracking)
|
|
604
581
|
* @returns A DocCov report with coverage analysis
|
|
605
582
|
*
|
|
606
583
|
* @example
|
|
@@ -614,17 +591,18 @@ interface DocCovReport {
|
|
|
614
591
|
* console.log(`Coverage: ${report.coverage.score}%`);
|
|
615
592
|
* ```
|
|
616
593
|
*/
|
|
617
|
-
declare function generateReport(spec:
|
|
594
|
+
declare function generateReport(spec: OpenPkg3, openpkgPath?: string): DocCovReport;
|
|
618
595
|
/**
|
|
619
|
-
* Generate a DocCov report from
|
|
596
|
+
* Generate a DocCov report from OpenPkg spec + DocCov spec composition.
|
|
620
597
|
*
|
|
621
|
-
* Use this when you've already called
|
|
598
|
+
* Use this when you've already called buildDocCovSpec() and want to avoid
|
|
622
599
|
* recomputing coverage data.
|
|
623
600
|
*
|
|
624
|
-
* @param
|
|
601
|
+
* @param openpkg - The pure OpenPkg spec
|
|
602
|
+
* @param doccov - The DocCov spec with analysis data
|
|
625
603
|
* @returns A DocCov report with coverage analysis
|
|
626
604
|
*/
|
|
627
|
-
declare function
|
|
605
|
+
declare function generateReportFromDocCov(openpkg: OpenPkg3, doccov: DocCovSpec3): DocCovReport;
|
|
628
606
|
/**
|
|
629
607
|
* Load a cached DocCov report from disk.
|
|
630
608
|
*
|
|
@@ -672,7 +650,7 @@ declare function isCachedReportValid(reportPath?: string, sourceFiles?: string[]
|
|
|
672
650
|
* fs.writeFileSync('api-surface.md', apiSurface);
|
|
673
651
|
* ```
|
|
674
652
|
*/
|
|
675
|
-
declare function renderApiSurface(spec:
|
|
653
|
+
declare function renderApiSurface(spec: OpenPkg3): string;
|
|
676
654
|
interface SchemaDetectionContext {
|
|
677
655
|
baseDir: string;
|
|
678
656
|
entryFile: string;
|
|
@@ -688,4 +666,4 @@ interface SchemaDetectionResult {
|
|
|
688
666
|
noCompiledJsWarning?: boolean;
|
|
689
667
|
}
|
|
690
668
|
declare function detectRuntimeSchemas(context: SchemaDetectionContext): Promise<SchemaDetectionResult>;
|
|
691
|
-
export { saveSnapshot, saveReport, renderSparkline, renderApiSurface, pruneHistory, pruneByTier, parseAssertions, loadSnapshotsForDays, loadSnapshots, loadCachedReport, isCachedReportValid, hasNonAssertionComments, groupDriftsByCategory, getTrend, getExtendedTrend, getDriftSummary, generateWeeklySummaries,
|
|
669
|
+
export { saveSnapshot, saveReport, renderSparkline, renderApiSurface, pruneHistory, pruneByTier, parseAssertions, loadSnapshotsForDays, loadSnapshots, loadCachedReport, isExportFullyDocumented, isCachedReportValid, hasNonAssertionComments, groupDriftsByCategory, getTrend, getExtendedTrend, getExportScore, getExportMissing, getExportDrift, getExportAnalysis, getDriftSummary, generateWeeklySummaries, generateReportFromDocCov, generateReport, formatDriftSummaryLine, formatDelta, ensureSpecCoverage, detectRuntimeSchemas, detectExampleRuntimeErrors, detectExampleAssertionFailures, computeSnapshot, computeExportDrift, computeDrift, categorizeDrift, calculateAggregateCoverage, buildExportRegistry, buildDocCovSpec, WeeklySummary, SchemaDetectionResult, SchemaDetectionContext, RetentionTier, RETENTION_DAYS, OpenPkgSpec, HISTORY_DIR, ExtendedTrendAnalysis, ExportDriftResult, DriftSummary, DriftResult, DetectedSchemaEntry, CoverageTrend, CoverageSnapshot, CategorizedDrift, BuildDocCovOptions };
|
package/dist/analysis/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HISTORY_DIR,
|
|
3
3
|
RETENTION_DAYS,
|
|
4
|
+
buildDocCovSpec,
|
|
4
5
|
buildExportRegistry,
|
|
5
6
|
calculateAggregateCoverage,
|
|
6
7
|
categorizeDrift,
|
|
@@ -10,19 +11,23 @@ import {
|
|
|
10
11
|
detectExampleAssertionFailures,
|
|
11
12
|
detectExampleRuntimeErrors,
|
|
12
13
|
detectRuntimeSchemas,
|
|
13
|
-
enrichSpec,
|
|
14
14
|
ensureSpecCoverage,
|
|
15
15
|
formatDelta,
|
|
16
16
|
formatDriftSummaryLine,
|
|
17
17
|
generateReport,
|
|
18
|
-
|
|
18
|
+
generateReportFromDocCov,
|
|
19
19
|
generateWeeklySummaries,
|
|
20
20
|
getDriftSummary,
|
|
21
|
+
getExportAnalysis,
|
|
22
|
+
getExportDrift,
|
|
23
|
+
getExportMissing,
|
|
24
|
+
getExportScore,
|
|
21
25
|
getExtendedTrend,
|
|
22
26
|
getTrend,
|
|
23
27
|
groupDriftsByCategory,
|
|
24
28
|
hasNonAssertionComments,
|
|
25
29
|
isCachedReportValid,
|
|
30
|
+
isExportFullyDocumented,
|
|
26
31
|
loadCachedReport,
|
|
27
32
|
loadSnapshots,
|
|
28
33
|
loadSnapshotsForDays,
|
|
@@ -33,64 +38,8 @@ import {
|
|
|
33
38
|
renderSparkline,
|
|
34
39
|
saveReport,
|
|
35
40
|
saveSnapshot
|
|
36
|
-
} from "../shared/chunk-
|
|
41
|
+
} from "../shared/chunk-e9mvnrys.js";
|
|
37
42
|
import"../shared/chunk-esptwrfq.js";
|
|
38
|
-
|
|
39
|
-
// src/analysis/diff-enriched.ts
|
|
40
|
-
import { diffSpec } from "@openpkg-ts/spec";
|
|
41
|
-
function diffEnrichedSpec(oldSpec, newSpec) {
|
|
42
|
-
const baseDiff = diffSpec(oldSpec, newSpec);
|
|
43
|
-
const result = {
|
|
44
|
-
...baseDiff,
|
|
45
|
-
coverageDelta: 0,
|
|
46
|
-
oldCoverage: 0,
|
|
47
|
-
newCoverage: 0,
|
|
48
|
-
newUndocumented: [],
|
|
49
|
-
improvedExports: [],
|
|
50
|
-
regressedExports: [],
|
|
51
|
-
driftIntroduced: 0,
|
|
52
|
-
driftResolved: 0
|
|
53
|
-
};
|
|
54
|
-
result.oldCoverage = oldSpec.docs?.coverageScore ?? 0;
|
|
55
|
-
result.newCoverage = newSpec.docs?.coverageScore ?? 0;
|
|
56
|
-
result.coverageDelta = Math.round((result.newCoverage - result.oldCoverage) * 10) / 10;
|
|
57
|
-
const oldExportMap = toExportMap(oldSpec.exports);
|
|
58
|
-
const newExportMap = toExportMap(newSpec.exports);
|
|
59
|
-
for (const [id, newExport] of newExportMap.entries()) {
|
|
60
|
-
const oldExport = oldExportMap.get(id);
|
|
61
|
-
const newScore = newExport.docs?.coverageScore ?? 0;
|
|
62
|
-
const newDriftCount = newExport.docs?.drift?.length ?? 0;
|
|
63
|
-
if (!oldExport) {
|
|
64
|
-
if (newScore < 100 || (newExport.docs?.missing?.length ?? 0) > 0) {
|
|
65
|
-
result.newUndocumented.push(id);
|
|
66
|
-
}
|
|
67
|
-
result.driftIntroduced += newDriftCount;
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
const oldScore = oldExport.docs?.coverageScore ?? 0;
|
|
71
|
-
const oldDriftCount = oldExport.docs?.drift?.length ?? 0;
|
|
72
|
-
if (newScore > oldScore) {
|
|
73
|
-
result.improvedExports.push(id);
|
|
74
|
-
} else if (newScore < oldScore) {
|
|
75
|
-
result.regressedExports.push(id);
|
|
76
|
-
}
|
|
77
|
-
if (newDriftCount > oldDriftCount) {
|
|
78
|
-
result.driftIntroduced += newDriftCount - oldDriftCount;
|
|
79
|
-
} else if (oldDriftCount > newDriftCount) {
|
|
80
|
-
result.driftResolved += oldDriftCount - newDriftCount;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
function toExportMap(exports) {
|
|
86
|
-
const map = new Map;
|
|
87
|
-
for (const exp of exports) {
|
|
88
|
-
if (exp && typeof exp.id === "string") {
|
|
89
|
-
map.set(exp.id, exp);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return map;
|
|
93
|
-
}
|
|
94
43
|
export {
|
|
95
44
|
saveSnapshot,
|
|
96
45
|
saveReport,
|
|
@@ -102,20 +51,23 @@ export {
|
|
|
102
51
|
loadSnapshotsForDays,
|
|
103
52
|
loadSnapshots,
|
|
104
53
|
loadCachedReport,
|
|
54
|
+
isExportFullyDocumented,
|
|
105
55
|
isCachedReportValid,
|
|
106
56
|
hasNonAssertionComments,
|
|
107
57
|
groupDriftsByCategory,
|
|
108
58
|
getTrend,
|
|
109
59
|
getExtendedTrend,
|
|
60
|
+
getExportScore,
|
|
61
|
+
getExportMissing,
|
|
62
|
+
getExportDrift,
|
|
63
|
+
getExportAnalysis,
|
|
110
64
|
getDriftSummary,
|
|
111
65
|
generateWeeklySummaries,
|
|
112
|
-
|
|
66
|
+
generateReportFromDocCov,
|
|
113
67
|
generateReport,
|
|
114
68
|
formatDriftSummaryLine,
|
|
115
69
|
formatDelta,
|
|
116
70
|
ensureSpecCoverage,
|
|
117
|
-
enrichSpec,
|
|
118
|
-
diffEnrichedSpec,
|
|
119
71
|
detectRuntimeSchemas,
|
|
120
72
|
detectExampleRuntimeErrors,
|
|
121
73
|
detectExampleAssertionFailures,
|
|
@@ -125,6 +77,7 @@ export {
|
|
|
125
77
|
categorizeDrift,
|
|
126
78
|
calculateAggregateCoverage,
|
|
127
79
|
buildExportRegistry,
|
|
80
|
+
buildDocCovSpec,
|
|
128
81
|
RETENTION_DAYS,
|
|
129
82
|
HISTORY_DIR
|
|
130
83
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DocCovSpec } from "@doccov/spec";
|
|
2
|
-
import { OpenPkg
|
|
3
|
-
type OpenPkgSpec =
|
|
2
|
+
import { OpenPkg } from "@openpkg-ts/spec";
|
|
3
|
+
type OpenPkgSpec = OpenPkg;
|
|
4
4
|
interface BuildDocCovOptions {
|
|
5
5
|
openpkgPath: string;
|
|
6
6
|
openpkg: OpenPkgSpec;
|
|
@@ -39,11 +39,6 @@ declare const DRIFT_CATEGORY_LABELS: Record<DriftCategory, string>;
|
|
|
39
39
|
* Category descriptions for help text.
|
|
40
40
|
*/
|
|
41
41
|
declare const DRIFT_CATEGORY_DESCRIPTIONS: Record<DriftCategory, string>;
|
|
42
|
-
type SpecDocsMetadata = {
|
|
43
|
-
coverageScore?: number;
|
|
44
|
-
missing?: string[];
|
|
45
|
-
drift?: SpecDocDrift[];
|
|
46
|
-
};
|
|
47
42
|
/**
|
|
48
43
|
* Result of computing drift for a single export.
|
|
49
44
|
*/
|
|
@@ -289,57 +284,50 @@ declare function hasNonAssertionComments(code: string): boolean;
|
|
|
289
284
|
* Detect assertion failures by comparing stdout to expected values.
|
|
290
285
|
*/
|
|
291
286
|
declare function detectExampleAssertionFailures(entry: SpecExport2, runtimeResults: Map<number, ExampleRunResult>): SpecDocDrift[];
|
|
292
|
-
import {
|
|
287
|
+
import { DocCovDrift, DocCovSpec as DocCovSpec2, ExportAnalysis, MissingDocRule } from "@doccov/spec";
|
|
288
|
+
import { SpecExport as SpecExport7 } from "@openpkg-ts/spec";
|
|
293
289
|
/**
|
|
294
|
-
*
|
|
295
|
-
*
|
|
290
|
+
* Get the full analysis data for an export.
|
|
291
|
+
*
|
|
292
|
+
* @param exp - The to look up
|
|
293
|
+
* @param doccov - The DocCov spec containing analysis data
|
|
294
|
+
* @returns Export analysis or undefined if not found
|
|
296
295
|
*/
|
|
297
|
-
|
|
298
|
-
docs?: EnrichedDocsMetadata;
|
|
299
|
-
};
|
|
296
|
+
declare function getExportAnalysis(exp: SpecExport7, doccov: DocCovSpec2): ExportAnalysis | undefined;
|
|
300
297
|
/**
|
|
301
|
-
*
|
|
298
|
+
* Get the coverage score for an export.
|
|
299
|
+
*
|
|
300
|
+
* @param exp - The to look up
|
|
301
|
+
* @param doccov - The DocCov spec containing analysis data
|
|
302
|
+
* @returns Coverage score (0-100) or 100 if not found
|
|
302
303
|
*/
|
|
303
|
-
|
|
304
|
+
declare function getExportScore(exp: SpecExport7, doccov: DocCovSpec2): number;
|
|
304
305
|
/**
|
|
305
|
-
*
|
|
306
|
-
*
|
|
306
|
+
* Get drift issues for an export.
|
|
307
|
+
*
|
|
308
|
+
* @param exp - The to look up
|
|
309
|
+
* @param doccov - The DocCov spec containing analysis data
|
|
310
|
+
* @returns Array of drift issues or empty array if none
|
|
307
311
|
*/
|
|
308
|
-
|
|
309
|
-
exports: EnrichedExport[];
|
|
310
|
-
docs?: EnrichedDocsMetadata;
|
|
311
|
-
/** Drift summary with category breakdown (if drift exists) */
|
|
312
|
-
driftSummary?: DriftSummary;
|
|
313
|
-
};
|
|
314
|
-
interface EnrichOptions {
|
|
315
|
-
/**
|
|
316
|
-
* Per-drift issues to include in enrichment.
|
|
317
|
-
* Map from ID to drift issues.
|
|
318
|
-
*/
|
|
319
|
-
driftByExport?: Map<string, SpecDocDrift[]>;
|
|
320
|
-
}
|
|
312
|
+
declare function getExportDrift(exp: SpecExport7, doccov: DocCovSpec2): DocCovDrift[];
|
|
321
313
|
/**
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
* Computes coverage scores and detects drift issues.
|
|
314
|
+
* Get missing documentation rules for an export.
|
|
325
315
|
*
|
|
326
|
-
* @param
|
|
327
|
-
* @param
|
|
328
|
-
* @returns
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
* const doccov = new DocCov();
|
|
335
|
-
* const { spec } = await doccov.analyzeFileWithDiagnostics('src/index.ts');
|
|
316
|
+
* @param exp - The to look up
|
|
317
|
+
* @param doccov - The DocCov spec containing analysis data
|
|
318
|
+
* @returns Array of missing rule IDs or empty array if none
|
|
319
|
+
*/
|
|
320
|
+
declare function getExportMissing(exp: SpecExport7, doccov: DocCovSpec2): MissingDocRule[];
|
|
321
|
+
/**
|
|
322
|
+
* Check if an has complete documentation.
|
|
336
323
|
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
324
|
+
* @param exp - The to check
|
|
325
|
+
* @param doccov - The DocCov spec containing analysis data
|
|
326
|
+
* @returns True if has 100% coverage and no drift
|
|
340
327
|
*/
|
|
341
|
-
declare function
|
|
342
|
-
import {
|
|
328
|
+
declare function isExportFullyDocumented(exp: SpecExport7, doccov: DocCovSpec2): boolean;
|
|
329
|
+
import { DocCovSpec as DocCovSpec3 } from "@doccov/spec";
|
|
330
|
+
import { OpenPkg as OpenPkg2 } from "@openpkg-ts/spec";
|
|
343
331
|
/**
|
|
344
332
|
* DocCov report schema version.
|
|
345
333
|
*/
|
|
@@ -520,6 +508,7 @@ interface DocCovReport {
|
|
|
520
508
|
* Generate a DocCov report from an OpenPkg spec.
|
|
521
509
|
*
|
|
522
510
|
* @param spec - The pure OpenPkg spec to analyze
|
|
511
|
+
* @param openpkgPath - Path to the openpkg spec file (for source tracking)
|
|
523
512
|
* @returns A DocCov report with coverage analysis
|
|
524
513
|
*
|
|
525
514
|
* @example
|
|
@@ -533,17 +522,18 @@ interface DocCovReport {
|
|
|
533
522
|
* console.log(`Coverage: ${report.coverage.score}%`);
|
|
534
523
|
* ```
|
|
535
524
|
*/
|
|
536
|
-
declare function generateReport(spec:
|
|
525
|
+
declare function generateReport(spec: OpenPkg2, openpkgPath?: string): DocCovReport;
|
|
537
526
|
/**
|
|
538
|
-
* Generate a DocCov report from
|
|
527
|
+
* Generate a DocCov report from OpenPkg spec + DocCov spec composition.
|
|
539
528
|
*
|
|
540
|
-
* Use this when you've already called
|
|
529
|
+
* Use this when you've already called buildDocCovSpec() and want to avoid
|
|
541
530
|
* recomputing coverage data.
|
|
542
531
|
*
|
|
543
|
-
* @param
|
|
532
|
+
* @param openpkg - The pure OpenPkg spec
|
|
533
|
+
* @param doccov - The DocCov spec with analysis data
|
|
544
534
|
* @returns A DocCov report with coverage analysis
|
|
545
535
|
*/
|
|
546
|
-
declare function
|
|
536
|
+
declare function generateReportFromDocCov(openpkg: OpenPkg2, doccov: DocCovSpec3): DocCovReport;
|
|
547
537
|
/**
|
|
548
538
|
* Load a cached DocCov report from disk.
|
|
549
539
|
*
|
|
@@ -578,7 +568,7 @@ declare function saveReport(report: DocCovReport, reportPath?: string): void;
|
|
|
578
568
|
* fs.writeFileSync('api-surface.md', apiSurface);
|
|
579
569
|
* ```
|
|
580
570
|
*/
|
|
581
|
-
declare function renderApiSurface(spec:
|
|
571
|
+
declare function renderApiSurface(spec: OpenPkg2): string;
|
|
582
572
|
import { EntryPointDetectionMethod } from "@openpkg-ts/spec";
|
|
583
573
|
/**
|
|
584
574
|
* Configuration types for DocCov.
|
|
@@ -748,7 +738,7 @@ declare function hashFiles(filePaths: string[], cwd: string): Record<string, str
|
|
|
748
738
|
* @returns Array of file paths that changed, were added, or were removed
|
|
749
739
|
*/
|
|
750
740
|
declare function diffHashes(cached: Record<string, string>, current: Record<string, string>): string[];
|
|
751
|
-
import { OpenPkg as
|
|
741
|
+
import { OpenPkg as OpenPkg3 } from "@openpkg-ts/spec";
|
|
752
742
|
/** Current cache format version */
|
|
753
743
|
declare const CACHE_VERSION = "1.0.0";
|
|
754
744
|
/** Default cache file path */
|
|
@@ -783,7 +773,7 @@ interface SpecCache {
|
|
|
783
773
|
/** Analysis configuration that affects output */
|
|
784
774
|
config: SpecCacheConfig;
|
|
785
775
|
/** The cached OpenPkg spec */
|
|
786
|
-
spec:
|
|
776
|
+
spec: OpenPkg3;
|
|
787
777
|
}
|
|
788
778
|
/**
|
|
789
779
|
* Result of cache validation.
|
|
@@ -826,7 +816,7 @@ declare function loadSpecCache(cwd: string): SpecCache | null;
|
|
|
826
816
|
* @param spec - OpenPkg spec to cache
|
|
827
817
|
* @param context - Cache context with file paths and config
|
|
828
818
|
*/
|
|
829
|
-
declare function saveSpecCache(spec:
|
|
819
|
+
declare function saveSpecCache(spec: OpenPkg3, context: CacheContext): void;
|
|
830
820
|
/**
|
|
831
821
|
* Validate if cached spec is still valid.
|
|
832
822
|
*
|
|
@@ -1533,9 +1523,13 @@ declare function isFixableDrift(drift: SpecDocDrift): boolean;
|
|
|
1533
1523
|
*/
|
|
1534
1524
|
declare function generateFix(drift: SpecDocDrift, exportEntry: SpecExport9, existingPatch?: JSDocPatch): FixSuggestion | null;
|
|
1535
1525
|
/**
|
|
1536
|
-
* Generate all fixes for an export's drift issues
|
|
1526
|
+
* Generate all fixes for an export's drift issues.
|
|
1527
|
+
*
|
|
1528
|
+
* @param exportEntry - The to generate fixes for
|
|
1529
|
+
* @param existingPatch - Optional existing JSDoc patch to merge with
|
|
1530
|
+
* @param driftList - Optional drift list from DocCovSpec (if not provided, reads from exportEntry.docs?.drift for backward compat)
|
|
1537
1531
|
*/
|
|
1538
|
-
declare function generateFixesForExport(exportEntry: SpecExport9, existingPatch?: JSDocPatch): FixSuggestion[];
|
|
1532
|
+
declare function generateFixesForExport(exportEntry: SpecExport9, existingPatch?: JSDocPatch, driftList?: SpecDocDrift[]): FixSuggestion[];
|
|
1539
1533
|
/**
|
|
1540
1534
|
* Merge multiple fix patches into a single patch
|
|
1541
1535
|
*/
|
|
@@ -1703,7 +1697,7 @@ declare function getDocumentedExports(markdownFiles: MarkdownDocFile[], exportNa
|
|
|
1703
1697
|
* Get all exports that lack documentation
|
|
1704
1698
|
*/
|
|
1705
1699
|
declare function getUndocumentedExports(markdownFiles: MarkdownDocFile[], exportNames: string[]): string[];
|
|
1706
|
-
import { CategorizedBreaking, OpenPkg as
|
|
1700
|
+
import { CategorizedBreaking, OpenPkg as OpenPkg5, SpecDiff as SpecDiff2 } from "@openpkg-ts/spec";
|
|
1707
1701
|
/**
|
|
1708
1702
|
* Extended spec diff result with docs impact
|
|
1709
1703
|
*/
|
|
@@ -1749,7 +1743,7 @@ interface DiffWithDocsOptions {
|
|
|
1749
1743
|
* }
|
|
1750
1744
|
* ```
|
|
1751
1745
|
*/
|
|
1752
|
-
declare function diffSpecWithDocs(oldSpec:
|
|
1746
|
+
declare function diffSpecWithDocs(oldSpec: OpenPkg5, newSpec: OpenPkg5, options?: DiffWithDocsOptions): SpecDiffWithDocs;
|
|
1753
1747
|
/**
|
|
1754
1748
|
* Check if a diff has any docs impact
|
|
1755
1749
|
*/
|
|
@@ -1813,7 +1807,7 @@ declare function typecheckExample(example: string, packagePath: string, options?
|
|
|
1813
1807
|
* Type-check multiple examples
|
|
1814
1808
|
*/
|
|
1815
1809
|
declare function typecheckExamples(examples: string[], packagePath: string, options?: TypecheckOptions): TypecheckResult;
|
|
1816
|
-
import { OpenPkg as
|
|
1810
|
+
import { OpenPkg as OpenPkg6 } from "@openpkg-ts/spec";
|
|
1817
1811
|
/** Directory for storing history snapshots */
|
|
1818
1812
|
declare const HISTORY_DIR = ".doccov/history";
|
|
1819
1813
|
/**
|
|
@@ -1908,7 +1902,7 @@ interface ExtendedTrendAnalysis {
|
|
|
1908
1902
|
/**
|
|
1909
1903
|
* Compute a coverage snapshot from an OpenPkg spec.
|
|
1910
1904
|
*/
|
|
1911
|
-
declare function computeSnapshot(spec:
|
|
1905
|
+
declare function computeSnapshot(spec: OpenPkg6, options?: {
|
|
1912
1906
|
commit?: string;
|
|
1913
1907
|
branch?: string;
|
|
1914
1908
|
}): CoverageSnapshot;
|
|
@@ -1934,7 +1928,7 @@ declare function loadSnapshots(cwd: string): CoverageSnapshot[];
|
|
|
1934
1928
|
* @param options - Optional git metadata
|
|
1935
1929
|
* @returns Trend data with history and delta
|
|
1936
1930
|
*/
|
|
1937
|
-
declare function getTrend(spec:
|
|
1931
|
+
declare function getTrend(spec: OpenPkg6, cwd: string, options?: {
|
|
1938
1932
|
commit?: string;
|
|
1939
1933
|
branch?: string;
|
|
1940
1934
|
}): CoverageTrend;
|
|
@@ -1976,7 +1970,7 @@ declare function pruneByTier(cwd: string, tier: RetentionTier): number;
|
|
|
1976
1970
|
* @param options - Analysis options
|
|
1977
1971
|
* @returns Extended trend analysis
|
|
1978
1972
|
*/
|
|
1979
|
-
declare function getExtendedTrend(spec:
|
|
1973
|
+
declare function getExtendedTrend(spec: OpenPkg6, cwd: string, options?: {
|
|
1980
1974
|
commit?: string;
|
|
1981
1975
|
branch?: string;
|
|
1982
1976
|
tier?: RetentionTier;
|
|
@@ -2189,7 +2183,7 @@ declare function parseListFlag(value?: string | string[]): string[] | undefined;
|
|
|
2189
2183
|
* ```
|
|
2190
2184
|
*/
|
|
2191
2185
|
declare function mergeFilters(config: DocCovConfig | null, overrides: FilterOptions): ResolvedFilters;
|
|
2192
|
-
import { OpenPkg as
|
|
2186
|
+
import { OpenPkg as OpenPkg7 } from "@openpkg-ts/spec";
|
|
2193
2187
|
/**
|
|
2194
2188
|
* Parsed components of a GitHub URL.
|
|
2195
2189
|
*/
|
|
@@ -2282,7 +2276,7 @@ declare function buildRawUrl(parsed: ParsedGitHubUrl, filePath: string): string;
|
|
|
2282
2276
|
* }
|
|
2283
2277
|
* ```
|
|
2284
2278
|
*/
|
|
2285
|
-
declare function fetchSpecFromGitHub(parsed: ParsedGitHubUrl): Promise<
|
|
2279
|
+
declare function fetchSpecFromGitHub(parsed: ParsedGitHubUrl): Promise<OpenPkg7 | null>;
|
|
2286
2280
|
/**
|
|
2287
2281
|
* Options for fetching a spec from GitHub.
|
|
2288
2282
|
*/
|
|
@@ -2302,7 +2296,7 @@ interface FetchSpecOptions {
|
|
|
2302
2296
|
* @param branchOrOptions - Branch name (default: 'main') or options object
|
|
2303
2297
|
* @returns The OpenPkg spec, or null if not found
|
|
2304
2298
|
*/
|
|
2305
|
-
declare function fetchSpec(owner: string, repo: string, branchOrOptions?: string | FetchSpecOptions): Promise<
|
|
2299
|
+
declare function fetchSpec(owner: string, repo: string, branchOrOptions?: string | FetchSpecOptions): Promise<OpenPkg7 | null>;
|
|
2306
2300
|
/**
|
|
2307
2301
|
* Progress event for installation status updates.
|
|
2308
2302
|
*/
|
|
@@ -2489,6 +2483,8 @@ declare function fetchGitHubContext(repoUrl: string, refOrOptions?: string | Fet
|
|
|
2489
2483
|
* List packages in a monorepo workspace.
|
|
2490
2484
|
*/
|
|
2491
2485
|
declare function listWorkspacePackages(owner: string, repo: string, ref: string, patterns: string[], authToken?: string): Promise<string[]>;
|
|
2486
|
+
import { DocCovSpec as DocCovSpec4 } from "@doccov/spec";
|
|
2487
|
+
import { OpenPkg as OpenPkg8 } from "@openpkg-ts/spec";
|
|
2492
2488
|
/**
|
|
2493
2489
|
* A documentation drift issue in a spec summary.
|
|
2494
2490
|
*/
|
|
@@ -2521,27 +2517,29 @@ interface SpecSummary {
|
|
|
2521
2517
|
drift: SummaryDriftIssue[];
|
|
2522
2518
|
}
|
|
2523
2519
|
/**
|
|
2524
|
-
* Extract a summary from
|
|
2520
|
+
* Extract a summary from OpenPkg spec + DocCov spec composition.
|
|
2525
2521
|
*
|
|
2526
2522
|
* This consolidates the logic previously duplicated in:
|
|
2527
2523
|
* - CLI scan.ts (drift collection)
|
|
2528
2524
|
* - CLI reports/stats.ts (computeStats)
|
|
2529
2525
|
* - API scan-stream.ts (inline extraction script)
|
|
2530
2526
|
*
|
|
2531
|
-
* @param
|
|
2527
|
+
* @param openpkg - The pure OpenPkg spec
|
|
2528
|
+
* @param doccov - The DocCov spec with analysis data
|
|
2532
2529
|
* @returns Summary of documentation coverage
|
|
2533
2530
|
*
|
|
2534
2531
|
* @example
|
|
2535
2532
|
* ```typescript
|
|
2536
|
-
* import {
|
|
2533
|
+
* import { buildDocCovSpec, extractSpecSummary } from '@doccov/sdk';
|
|
2537
2534
|
*
|
|
2538
|
-
* const
|
|
2539
|
-
* const summary = extractSpecSummary(
|
|
2535
|
+
* const doccov = buildDocCovSpec({ openpkg: spec, openpkgPath: 'openpkg.json' });
|
|
2536
|
+
* const summary = extractSpecSummary(spec, doccov);
|
|
2540
2537
|
* console.log(`Coverage: ${summary.coverage}%`);
|
|
2541
2538
|
* console.log(`Undocumented: ${summary.undocumented.length}`);
|
|
2542
2539
|
* ```
|
|
2543
2540
|
*/
|
|
2544
|
-
declare function extractSpecSummary(
|
|
2541
|
+
declare function extractSpecSummary(openpkg: OpenPkg8, doccov: DocCovSpec4): SpecSummary;
|
|
2542
|
+
import { OpenPkg as OpenPkg_mulpcdndjy } from "@openpkg-ts/spec";
|
|
2545
2543
|
/**
|
|
2546
2544
|
* Build Plan types for AI-powered repository scanning.
|
|
2547
2545
|
*/
|
|
@@ -2638,7 +2636,7 @@ interface BuildPlanExecutionResult {
|
|
|
2638
2636
|
/** Whether all required steps succeeded */
|
|
2639
2637
|
success: boolean;
|
|
2640
2638
|
/** Generated OpenPkg spec (if successful) */
|
|
2641
|
-
spec?:
|
|
2639
|
+
spec?: OpenPkg_mulpcdndjy;
|
|
2642
2640
|
/** Results for each step */
|
|
2643
2641
|
stepResults: BuildPlanStepResult[];
|
|
2644
2642
|
/** Total execution time in milliseconds */
|
|
@@ -2646,4 +2644,4 @@ interface BuildPlanExecutionResult {
|
|
|
2646
2644
|
/** Overall error message if failed */
|
|
2647
2645
|
error?: string;
|
|
2648
2646
|
}
|
|
2649
|
-
export { validateSpecCache, validateExamples, typecheckExamples, typecheckExample, shouldValidate, serializeJSDoc, saveSpecCache, saveSnapshot, saveReport, safeParseJson, runExamplesWithPackage, runExamples, runExample, resolveTarget, resolveCompiledPath, renderSparkline, renderApiSurface, readPackageJson, pruneHistory, pruneByTier, parseGitHubUrl2 as parseScanGitHubUrl, parseMarkdownFiles, parseMarkdownFile, parseListFlag, parseJSDocToPatch, parseGitHubUrl, parseExamplesFlag, parseAssertions, mergeFixes, mergeFilters, loadSpecCache, loadSnapshots, loadCachedReport, listWorkspacePackages, isStandardJSONSchema, isSchemaType, isFixableDrift, isExecutableLang, installDependencies, hashString, hashFiles, hashFile, hasNonAssertionComments, hasDocsImpact, hasDocsForExport, groupDriftsByCategory, getUndocumentedExports, getTrend, getSupportedLibraries, getSpecCachePath, getRunCommand, getReportPath, getRegisteredAdapters, getPrimaryBuildScript, getInstallCommand, getExtendedTrend, getDriftSummary, getDocumentedExports, getDocsImpactSummary, getDiffReportPath,
|
|
2647
|
+
export { validateSpecCache, validateExamples, typecheckExamples, typecheckExample, shouldValidate, serializeJSDoc, saveSpecCache, saveSnapshot, saveReport, safeParseJson, runExamplesWithPackage, runExamples, runExample, resolveTarget, resolveCompiledPath, renderSparkline, renderApiSurface, readPackageJson, pruneHistory, pruneByTier, parseGitHubUrl2 as parseScanGitHubUrl, parseMarkdownFiles, parseMarkdownFile, parseListFlag, parseJSDocToPatch, parseGitHubUrl, parseExamplesFlag, parseAssertions, mergeFixes, mergeFilters, loadSpecCache, loadSnapshots, loadCachedReport, listWorkspacePackages, isStandardJSONSchema, isSchemaType, isFixableDrift, isExportFullyDocumented, isExecutableLang, installDependencies, hashString, hashFiles, hashFile, hasNonAssertionComments, hasDocsImpact, hasDocsForExport, groupDriftsByCategory, getUndocumentedExports, getTrend, getSupportedLibraries, getSpecCachePath, getRunCommand, getReportPath, getRegisteredAdapters, getPrimaryBuildScript, getInstallCommand, getExtendedTrend, getExportScore, getExportMissing, getExportDrift, getExportAnalysis, getDriftSummary, getDocumentedExports, getDocsImpactSummary, getDiffReportPath, generateReportFromDocCov, generateReport, generateFixesForExport, generateFix, formatPackageList, formatDriftSummaryLine, formatDelta, findRemovedReferences, findPackageByName, findJSDocLocation, findExportReferences, findDeprecatedReferences, findAdapter, fetchSpecFromGitHub, fetchSpec, fetchGitHubContext, extractStandardSchemasFromProject, extractStandardSchemas, extractSpecSummary, extractSchemaType, extractSchemaOutputType, extractPackageSpec, extractImports, extractFunctionCalls, ensureSpecCoverage, diffSpecWithDocs, diffHashes, detectRuntimeSchemas, detectPackageManager, detectMonorepo, detectExampleRuntimeErrors, detectExampleAssertionFailures, detectEntryPoint, detectBuildInfo, defineConfig, createSourceFile, createNodeCommandRunner, computeSnapshot, computeExportDrift, computeDrift, clearSpecCache, categorizeDrifts, categorizeDrift, calculateAggregateCoverage, buildRawUrl, buildExportRegistry, buildDocCovSpec, buildDisplayUrl, buildCloneUrl, blockReferencesExport, applyPatchToJSDoc, applyEdits, analyzeProject2 as analyzeProject, analyzeFile, analyzeDocsImpact, analyze, WorkspacePackage, WorkspaceConfig, VALIDATION_INFO, TypecheckValidationResult, TypecheckResult, TypecheckOptions, SummaryDriftIssue, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, SpecSummary, SpecDocDrift, SpecDiffWithDocs, SpecCacheConfig, SpecCache, SchemaExtractionResult, SchemaExtractionMode, SchemaDetectionResult, SchemaDetectionContext, SchemaAdapter, SandboxFileSystem, SPEC_CACHE_FILE, RuntimeDrift, RunValidationResult, RunExamplesWithPackageResult, RunExamplesWithPackageOptions, RunExampleOptions, RetentionTier, ResolvedTarget, ResolvedFilters, ResolveTargetOptions, ReleaseTag, RETENTION_DAYS, REPORT_VERSION, REPORT_EXTENSIONS, ProjectInfo, PresenceResult, ParsedGitHubUrl, PackageManagerInfo, PackageManager, PackageJson, PackageExports, OpenPkgSpec, NodeFileSystem, MonorepoType, MonorepoInfo, MemberChange, MarkdownDocFile, MarkdownCodeBlock, LLMAssertion, JSDocTag, JSDocReturn, JSDocPatch, JSDocParam, JSDocEdit, InstallResult, InstallOptions, HISTORY_DIR, GitHubRepoMetadata, GitHubProjectContext, FixType, FixSuggestion, FilterSource, FilterOptions, FileSystem, FetchGitHubContextOptions, ExtractStandardSchemasOptions, ExtendedTrendAnalysis, ExportReference, ExportDriftResult, ExportCoverageData, ExampleValidationTypeError, ExampleValidationResult, ExampleValidationOptions, ExampleValidationMode, ExampleValidation, ExampleTypeError, ExampleRunResult, EntryPointSource, EntryPointInfo, DriftType, DriftSummary, DriftResult, DriftReportSummary, DriftReport, DriftCategory, DocsImpactResult, DocsImpactReference, DocsImpact, DocsConfig, DocsChangeType, DocCovReport, DocCovOptions, DocCovConfig, DocCov, DiffWithDocsOptions, Diagnostic2 as Diagnostic, DetectedSchemaEntry, DetectedPackageManager, DRIFT_CATEGORY_LABELS, DRIFT_CATEGORY_DESCRIPTIONS, DRIFT_CATEGORIES, DEFAULT_REPORT_PATH, DEFAULT_REPORT_DIR, CoverageTrend, CoverageSummary, CoverageSnapshot, CommandRunner, CommandResult, CheckConfig, CategorizedDrift, CacheValidationResult, CacheContext, CACHE_VERSION, BuildPlanTarget, BuildPlanStepResult, BuildPlanStep, BuildPlanExecutionResult, BuildPlanEnvironment, BuildPlan, BuildInfo, BuildHints, BuildDocCovOptions, ApplyEditsResult, AnalyzeProjectOptions, AnalyzeOptions, AnalysisResult, ALL_VALIDATIONS };
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
RETENTION_DAYS,
|
|
7
7
|
applyEdits,
|
|
8
8
|
applyPatchToJSDoc,
|
|
9
|
+
buildDocCovSpec,
|
|
9
10
|
buildExportRegistry,
|
|
10
11
|
calculateAggregateCoverage,
|
|
11
12
|
categorizeDrift,
|
|
@@ -17,7 +18,6 @@ import {
|
|
|
17
18
|
detectExampleAssertionFailures,
|
|
18
19
|
detectExampleRuntimeErrors,
|
|
19
20
|
detectRuntimeSchemas,
|
|
20
|
-
enrichSpec,
|
|
21
21
|
ensureSpecCoverage,
|
|
22
22
|
extractStandardSchemas,
|
|
23
23
|
extractStandardSchemasFromProject,
|
|
@@ -27,14 +27,19 @@ import {
|
|
|
27
27
|
generateFix,
|
|
28
28
|
generateFixesForExport,
|
|
29
29
|
generateReport,
|
|
30
|
-
|
|
30
|
+
generateReportFromDocCov,
|
|
31
31
|
getDriftSummary,
|
|
32
|
+
getExportAnalysis,
|
|
33
|
+
getExportDrift,
|
|
34
|
+
getExportMissing,
|
|
35
|
+
getExportScore,
|
|
32
36
|
getExtendedTrend,
|
|
33
37
|
getTrend,
|
|
34
38
|
groupDriftsByCategory,
|
|
35
39
|
hasNonAssertionComments,
|
|
36
40
|
isBuiltInIdentifier,
|
|
37
41
|
isBuiltInTypeName,
|
|
42
|
+
isExportFullyDocumented,
|
|
38
43
|
isFixableDrift,
|
|
39
44
|
isStandardJSONSchema,
|
|
40
45
|
loadCachedReport,
|
|
@@ -51,7 +56,7 @@ import {
|
|
|
51
56
|
saveSnapshot,
|
|
52
57
|
serializeJSDoc,
|
|
53
58
|
ts
|
|
54
|
-
} from "./shared/chunk-
|
|
59
|
+
} from "./shared/chunk-e9mvnrys.js";
|
|
55
60
|
import {
|
|
56
61
|
mergeFilters,
|
|
57
62
|
parseListFlag
|
|
@@ -66,141 +71,6 @@ import {
|
|
|
66
71
|
getDiffReportPath,
|
|
67
72
|
getReportPath
|
|
68
73
|
} from "./shared/chunk-esptwrfq.js";
|
|
69
|
-
|
|
70
|
-
// src/analysis/doccov-builder.ts
|
|
71
|
-
import { DRIFT_CATEGORIES as DRIFT_CATEGORIES2 } from "@doccov/spec";
|
|
72
|
-
function buildDocCovSpec(options) {
|
|
73
|
-
const { openpkg, openpkgPath } = options;
|
|
74
|
-
const registry = buildExportRegistry(openpkg);
|
|
75
|
-
const exports = {};
|
|
76
|
-
let totalScore = 0;
|
|
77
|
-
let documentedCount = 0;
|
|
78
|
-
const missingByRule = {
|
|
79
|
-
description: 0,
|
|
80
|
-
params: 0,
|
|
81
|
-
returns: 0,
|
|
82
|
-
examples: 0,
|
|
83
|
-
throws: 0
|
|
84
|
-
};
|
|
85
|
-
const driftByCategory = {
|
|
86
|
-
structural: 0,
|
|
87
|
-
semantic: 0,
|
|
88
|
-
example: 0
|
|
89
|
-
};
|
|
90
|
-
let totalDrift = 0;
|
|
91
|
-
let fixableDrift = 0;
|
|
92
|
-
for (const exp of openpkg.exports ?? []) {
|
|
93
|
-
const coverage = computeExportCoverage(exp);
|
|
94
|
-
const rawDrifts = computeExportDrift(exp, registry);
|
|
95
|
-
const categorizedDrifts = rawDrifts.map((d) => toCategorizedDrift(d));
|
|
96
|
-
const exportId = exp.id ?? exp.name;
|
|
97
|
-
exports[exportId] = {
|
|
98
|
-
coverageScore: coverage.score,
|
|
99
|
-
missing: coverage.missing.length > 0 ? coverage.missing : undefined,
|
|
100
|
-
drift: categorizedDrifts.length > 0 ? categorizedDrifts : undefined
|
|
101
|
-
};
|
|
102
|
-
totalScore += coverage.score;
|
|
103
|
-
if (coverage.score === 100)
|
|
104
|
-
documentedCount++;
|
|
105
|
-
for (const rule of coverage.missing) {
|
|
106
|
-
missingByRule[rule]++;
|
|
107
|
-
}
|
|
108
|
-
for (const d of categorizedDrifts) {
|
|
109
|
-
driftByCategory[d.category]++;
|
|
110
|
-
totalDrift++;
|
|
111
|
-
if (d.fixable)
|
|
112
|
-
fixableDrift++;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const exportCount = openpkg.exports?.length ?? 0;
|
|
116
|
-
const summary = {
|
|
117
|
-
score: exportCount > 0 ? Math.round(totalScore / exportCount) : 100,
|
|
118
|
-
totalExports: exportCount,
|
|
119
|
-
documentedExports: documentedCount,
|
|
120
|
-
missingByRule,
|
|
121
|
-
drift: {
|
|
122
|
-
total: totalDrift,
|
|
123
|
-
fixable: fixableDrift,
|
|
124
|
-
byCategory: driftByCategory
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
return {
|
|
128
|
-
doccov: "1.0.0",
|
|
129
|
-
source: {
|
|
130
|
-
file: openpkgPath,
|
|
131
|
-
specVersion: openpkg.openpkg,
|
|
132
|
-
packageName: openpkg.meta.name,
|
|
133
|
-
packageVersion: openpkg.meta.version
|
|
134
|
-
},
|
|
135
|
-
generatedAt: new Date().toISOString(),
|
|
136
|
-
summary,
|
|
137
|
-
exports
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function computeExportCoverage(exp) {
|
|
141
|
-
const missing = [];
|
|
142
|
-
let points = 0;
|
|
143
|
-
let maxPoints = 0;
|
|
144
|
-
maxPoints += 30;
|
|
145
|
-
if (exp.description && exp.description.trim().length > 0) {
|
|
146
|
-
points += 30;
|
|
147
|
-
} else {
|
|
148
|
-
missing.push("description");
|
|
149
|
-
}
|
|
150
|
-
const isCallable = exp.kind === "function" || exp.kind === "class";
|
|
151
|
-
if (isCallable && exp.signatures?.length) {
|
|
152
|
-
const sig = exp.signatures[0];
|
|
153
|
-
const params = sig.parameters ?? [];
|
|
154
|
-
if (params.length > 0) {
|
|
155
|
-
maxPoints += 25;
|
|
156
|
-
const documentedParams = params.filter((p) => p.description && p.description.trim().length > 0);
|
|
157
|
-
if (documentedParams.length === params.length) {
|
|
158
|
-
points += 25;
|
|
159
|
-
} else if (documentedParams.length > 0) {
|
|
160
|
-
points += Math.round(documentedParams.length / params.length * 25);
|
|
161
|
-
missing.push("params");
|
|
162
|
-
} else {
|
|
163
|
-
missing.push("params");
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (exp.kind === "function" && sig.returns) {
|
|
167
|
-
maxPoints += 20;
|
|
168
|
-
if (sig.returns.description && sig.returns.description.trim().length > 0) {
|
|
169
|
-
points += 20;
|
|
170
|
-
} else {
|
|
171
|
-
missing.push("returns");
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (sig.throws && sig.throws.length > 0) {
|
|
175
|
-
maxPoints += 10;
|
|
176
|
-
const documentedThrows = sig.throws.filter((t) => t.description);
|
|
177
|
-
if (documentedThrows.length === sig.throws.length) {
|
|
178
|
-
points += 10;
|
|
179
|
-
} else {
|
|
180
|
-
missing.push("throws");
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
maxPoints += 15;
|
|
185
|
-
if (exp.examples && exp.examples.length > 0) {
|
|
186
|
-
points += 15;
|
|
187
|
-
} else {
|
|
188
|
-
missing.push("examples");
|
|
189
|
-
}
|
|
190
|
-
const score = maxPoints > 0 ? Math.round(points / maxPoints * 100) : 100;
|
|
191
|
-
return { score, missing };
|
|
192
|
-
}
|
|
193
|
-
function toCategorizedDrift(drift) {
|
|
194
|
-
const driftType = drift.type;
|
|
195
|
-
return {
|
|
196
|
-
type: driftType,
|
|
197
|
-
target: drift.target,
|
|
198
|
-
issue: drift.issue,
|
|
199
|
-
suggestion: drift.suggestion,
|
|
200
|
-
category: DRIFT_CATEGORIES2[driftType],
|
|
201
|
-
fixable: isFixableDrift(drift)
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
74
|
// src/openpkg.ts
|
|
205
75
|
import * as fsSync from "node:fs";
|
|
206
76
|
import * as fs5 from "node:fs/promises";
|
|
@@ -6740,20 +6610,20 @@ async function listWorkspacePackages(owner, repo, ref, patterns, authToken) {
|
|
|
6740
6610
|
return packages;
|
|
6741
6611
|
}
|
|
6742
6612
|
// src/scan/summary.ts
|
|
6743
|
-
function extractSpecSummary(
|
|
6744
|
-
const exports =
|
|
6613
|
+
function extractSpecSummary(openpkg, doccov) {
|
|
6614
|
+
const exports = openpkg.exports ?? [];
|
|
6745
6615
|
const undocumented = [];
|
|
6746
6616
|
const drift = [];
|
|
6747
6617
|
for (const exp of exports) {
|
|
6748
|
-
const
|
|
6749
|
-
if (!
|
|
6618
|
+
const analysis = getExportAnalysis(exp, doccov);
|
|
6619
|
+
if (!analysis)
|
|
6750
6620
|
continue;
|
|
6751
|
-
const hasMissing = (
|
|
6752
|
-
const isPartial = (
|
|
6621
|
+
const hasMissing = (analysis.missing?.length ?? 0) > 0;
|
|
6622
|
+
const isPartial = (analysis.coverageScore ?? 0) < 100;
|
|
6753
6623
|
if (hasMissing || isPartial) {
|
|
6754
6624
|
undocumented.push(exp.name);
|
|
6755
6625
|
}
|
|
6756
|
-
for (const d of
|
|
6626
|
+
for (const d of analysis.drift ?? []) {
|
|
6757
6627
|
drift.push({
|
|
6758
6628
|
export: exp.name,
|
|
6759
6629
|
type: d.type,
|
|
@@ -6763,9 +6633,9 @@ function extractSpecSummary(spec) {
|
|
|
6763
6633
|
}
|
|
6764
6634
|
}
|
|
6765
6635
|
return {
|
|
6766
|
-
coverage:
|
|
6636
|
+
coverage: doccov.summary.score,
|
|
6767
6637
|
exportCount: exports.length,
|
|
6768
|
-
typeCount:
|
|
6638
|
+
typeCount: openpkg.types?.length ?? 0,
|
|
6769
6639
|
driftCount: drift.length,
|
|
6770
6640
|
undocumented,
|
|
6771
6641
|
drift
|
|
@@ -6809,6 +6679,7 @@ export {
|
|
|
6809
6679
|
isStandardJSONSchema,
|
|
6810
6680
|
isSchemaType,
|
|
6811
6681
|
isFixableDrift,
|
|
6682
|
+
isExportFullyDocumented,
|
|
6812
6683
|
isExecutableLang,
|
|
6813
6684
|
installDependencies,
|
|
6814
6685
|
hashString,
|
|
@@ -6828,11 +6699,15 @@ export {
|
|
|
6828
6699
|
getPrimaryBuildScript,
|
|
6829
6700
|
getInstallCommand,
|
|
6830
6701
|
getExtendedTrend,
|
|
6702
|
+
getExportScore,
|
|
6703
|
+
getExportMissing,
|
|
6704
|
+
getExportDrift,
|
|
6705
|
+
getExportAnalysis,
|
|
6831
6706
|
getDriftSummary,
|
|
6832
6707
|
getDocumentedExports,
|
|
6833
6708
|
getDocsImpactSummary,
|
|
6834
6709
|
getDiffReportPath,
|
|
6835
|
-
|
|
6710
|
+
generateReportFromDocCov,
|
|
6836
6711
|
generateReport,
|
|
6837
6712
|
generateFixesForExport,
|
|
6838
6713
|
generateFix,
|
|
@@ -6857,7 +6732,6 @@ export {
|
|
|
6857
6732
|
extractImports,
|
|
6858
6733
|
extractFunctionCalls,
|
|
6859
6734
|
ensureSpecCoverage,
|
|
6860
|
-
enrichSpec,
|
|
6861
6735
|
diffSpecWithDocs,
|
|
6862
6736
|
diffHashes,
|
|
6863
6737
|
detectRuntimeSchemas,
|
|
@@ -42,10 +42,10 @@ function generateFix(drift, exportEntry, existingPatch) {
|
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
function generateFixesForExport(exportEntry, existingPatch) {
|
|
45
|
+
function generateFixesForExport(exportEntry, existingPatch, driftList) {
|
|
46
46
|
const fixes = [];
|
|
47
|
-
const
|
|
48
|
-
for (const drift of
|
|
47
|
+
const drifts = driftList ?? exportEntry.docs?.drift ?? [];
|
|
48
|
+
for (const drift of drifts) {
|
|
49
49
|
const fix = generateFix(drift, exportEntry, existingPatch);
|
|
50
50
|
if (fix) {
|
|
51
51
|
fixes.push(fix);
|
|
@@ -2016,8 +2016,143 @@ function computeExportDrift(entry, registry) {
|
|
|
2016
2016
|
];
|
|
2017
2017
|
}
|
|
2018
2018
|
|
|
2019
|
+
// src/analysis/doccov-builder.ts
|
|
2020
|
+
import { DRIFT_CATEGORIES } from "@doccov/spec";
|
|
2021
|
+
function buildDocCovSpec(options) {
|
|
2022
|
+
const { openpkg, openpkgPath } = options;
|
|
2023
|
+
const registry = buildExportRegistry(openpkg);
|
|
2024
|
+
const exports = {};
|
|
2025
|
+
let totalScore = 0;
|
|
2026
|
+
let documentedCount = 0;
|
|
2027
|
+
const missingByRule = {
|
|
2028
|
+
description: 0,
|
|
2029
|
+
params: 0,
|
|
2030
|
+
returns: 0,
|
|
2031
|
+
examples: 0,
|
|
2032
|
+
throws: 0
|
|
2033
|
+
};
|
|
2034
|
+
const driftByCategory = {
|
|
2035
|
+
structural: 0,
|
|
2036
|
+
semantic: 0,
|
|
2037
|
+
example: 0
|
|
2038
|
+
};
|
|
2039
|
+
let totalDrift = 0;
|
|
2040
|
+
let fixableDrift = 0;
|
|
2041
|
+
for (const exp of openpkg.exports ?? []) {
|
|
2042
|
+
const coverage = computeExportCoverage(exp);
|
|
2043
|
+
const rawDrifts = computeExportDrift(exp, registry);
|
|
2044
|
+
const categorizedDrifts = rawDrifts.map((d) => toCategorizedDrift(d));
|
|
2045
|
+
const exportId = exp.id ?? exp.name;
|
|
2046
|
+
exports[exportId] = {
|
|
2047
|
+
coverageScore: coverage.score,
|
|
2048
|
+
missing: coverage.missing.length > 0 ? coverage.missing : undefined,
|
|
2049
|
+
drift: categorizedDrifts.length > 0 ? categorizedDrifts : undefined
|
|
2050
|
+
};
|
|
2051
|
+
totalScore += coverage.score;
|
|
2052
|
+
if (coverage.score === 100)
|
|
2053
|
+
documentedCount++;
|
|
2054
|
+
for (const rule of coverage.missing) {
|
|
2055
|
+
missingByRule[rule]++;
|
|
2056
|
+
}
|
|
2057
|
+
for (const d of categorizedDrifts) {
|
|
2058
|
+
driftByCategory[d.category]++;
|
|
2059
|
+
totalDrift++;
|
|
2060
|
+
if (d.fixable)
|
|
2061
|
+
fixableDrift++;
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
const exportCount = openpkg.exports?.length ?? 0;
|
|
2065
|
+
const summary = {
|
|
2066
|
+
score: exportCount > 0 ? Math.round(totalScore / exportCount) : 100,
|
|
2067
|
+
totalExports: exportCount,
|
|
2068
|
+
documentedExports: documentedCount,
|
|
2069
|
+
missingByRule,
|
|
2070
|
+
drift: {
|
|
2071
|
+
total: totalDrift,
|
|
2072
|
+
fixable: fixableDrift,
|
|
2073
|
+
byCategory: driftByCategory
|
|
2074
|
+
}
|
|
2075
|
+
};
|
|
2076
|
+
return {
|
|
2077
|
+
doccov: "1.0.0",
|
|
2078
|
+
source: {
|
|
2079
|
+
file: openpkgPath,
|
|
2080
|
+
specVersion: openpkg.openpkg,
|
|
2081
|
+
packageName: openpkg.meta.name,
|
|
2082
|
+
packageVersion: openpkg.meta.version
|
|
2083
|
+
},
|
|
2084
|
+
generatedAt: new Date().toISOString(),
|
|
2085
|
+
summary,
|
|
2086
|
+
exports
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
function computeExportCoverage(exp) {
|
|
2090
|
+
const missing = [];
|
|
2091
|
+
let points = 0;
|
|
2092
|
+
let maxPoints = 0;
|
|
2093
|
+
maxPoints += 30;
|
|
2094
|
+
if (exp.description && exp.description.trim().length > 0) {
|
|
2095
|
+
points += 30;
|
|
2096
|
+
} else {
|
|
2097
|
+
missing.push("description");
|
|
2098
|
+
}
|
|
2099
|
+
const isCallable = exp.kind === "function" || exp.kind === "class";
|
|
2100
|
+
if (isCallable && exp.signatures?.length) {
|
|
2101
|
+
const sig = exp.signatures[0];
|
|
2102
|
+
const params = sig.parameters ?? [];
|
|
2103
|
+
if (params.length > 0) {
|
|
2104
|
+
maxPoints += 25;
|
|
2105
|
+
const documentedParams = params.filter((p) => p.description && p.description.trim().length > 0);
|
|
2106
|
+
if (documentedParams.length === params.length) {
|
|
2107
|
+
points += 25;
|
|
2108
|
+
} else if (documentedParams.length > 0) {
|
|
2109
|
+
points += Math.round(documentedParams.length / params.length * 25);
|
|
2110
|
+
missing.push("params");
|
|
2111
|
+
} else {
|
|
2112
|
+
missing.push("params");
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
if (exp.kind === "function" && sig.returns) {
|
|
2116
|
+
maxPoints += 20;
|
|
2117
|
+
if (sig.returns.description && sig.returns.description.trim().length > 0) {
|
|
2118
|
+
points += 20;
|
|
2119
|
+
} else {
|
|
2120
|
+
missing.push("returns");
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
if (sig.throws && sig.throws.length > 0) {
|
|
2124
|
+
maxPoints += 10;
|
|
2125
|
+
const documentedThrows = sig.throws.filter((t) => t.description);
|
|
2126
|
+
if (documentedThrows.length === sig.throws.length) {
|
|
2127
|
+
points += 10;
|
|
2128
|
+
} else {
|
|
2129
|
+
missing.push("throws");
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
maxPoints += 15;
|
|
2134
|
+
if (exp.examples && exp.examples.length > 0) {
|
|
2135
|
+
points += 15;
|
|
2136
|
+
} else {
|
|
2137
|
+
missing.push("examples");
|
|
2138
|
+
}
|
|
2139
|
+
const score = maxPoints > 0 ? Math.round(points / maxPoints * 100) : 100;
|
|
2140
|
+
return { score, missing };
|
|
2141
|
+
}
|
|
2142
|
+
function toCategorizedDrift(drift) {
|
|
2143
|
+
const driftType = drift.type;
|
|
2144
|
+
return {
|
|
2145
|
+
type: driftType,
|
|
2146
|
+
target: drift.target,
|
|
2147
|
+
issue: drift.issue,
|
|
2148
|
+
suggestion: drift.suggestion,
|
|
2149
|
+
category: DRIFT_CATEGORIES[driftType],
|
|
2150
|
+
fixable: isFixableDrift(drift)
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2019
2154
|
// src/analysis/drift/types.ts
|
|
2020
|
-
var
|
|
2155
|
+
var DRIFT_CATEGORIES2 = {
|
|
2021
2156
|
"param-mismatch": "structural",
|
|
2022
2157
|
"param-type-mismatch": "structural",
|
|
2023
2158
|
"return-type-mismatch": "structural",
|
|
@@ -2048,7 +2183,7 @@ var DRIFT_CATEGORY_DESCRIPTIONS = {
|
|
|
2048
2183
|
function categorizeDrift(drift) {
|
|
2049
2184
|
return {
|
|
2050
2185
|
...drift,
|
|
2051
|
-
category:
|
|
2186
|
+
category: DRIFT_CATEGORIES2[drift.type],
|
|
2052
2187
|
fixable: isFixableDrift(drift)
|
|
2053
2188
|
};
|
|
2054
2189
|
}
|
|
@@ -2125,129 +2260,83 @@ function ensureSpecCoverage(spec) {
|
|
|
2125
2260
|
}
|
|
2126
2261
|
};
|
|
2127
2262
|
}
|
|
2128
|
-
// src/analysis/
|
|
2129
|
-
function
|
|
2130
|
-
const
|
|
2131
|
-
|
|
2132
|
-
if (exp.docs?.missing) {
|
|
2133
|
-
for (const ruleId of exp.docs.missing) {
|
|
2134
|
-
allMissing.add(ruleId);
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
return Array.from(allMissing);
|
|
2263
|
+
// src/analysis/lookup.ts
|
|
2264
|
+
function getExportAnalysis(exp, doccov) {
|
|
2265
|
+
const id = exp.id ?? exp.name;
|
|
2266
|
+
return doccov.exports[id];
|
|
2139
2267
|
}
|
|
2140
|
-
function
|
|
2141
|
-
const
|
|
2142
|
-
|
|
2143
|
-
if (exp.docs?.drift) {
|
|
2144
|
-
allDrift.push(...exp.docs.drift);
|
|
2145
|
-
}
|
|
2146
|
-
}
|
|
2147
|
-
return allDrift;
|
|
2268
|
+
function getExportScore(exp, doccov) {
|
|
2269
|
+
const analysis = getExportAnalysis(exp, doccov);
|
|
2270
|
+
return analysis?.coverageScore ?? 100;
|
|
2148
2271
|
}
|
|
2149
|
-
function
|
|
2150
|
-
const
|
|
2151
|
-
|
|
2152
|
-
missing.push("has-description");
|
|
2153
|
-
return { score: 0, missing };
|
|
2154
|
-
}
|
|
2155
|
-
return { score: 100, missing: [] };
|
|
2272
|
+
function getExportDrift(exp, doccov) {
|
|
2273
|
+
const analysis = getExportAnalysis(exp, doccov);
|
|
2274
|
+
return analysis?.drift ?? [];
|
|
2156
2275
|
}
|
|
2157
|
-
function
|
|
2158
|
-
const
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
totalCoverage += coverage.score;
|
|
2167
|
-
const docs2 = {
|
|
2168
|
-
coverageScore: coverage.score
|
|
2169
|
-
};
|
|
2170
|
-
if (coverage.missing.length > 0) {
|
|
2171
|
-
docs2.missing = coverage.missing;
|
|
2172
|
-
}
|
|
2173
|
-
if (allDrift2.length > 0) {
|
|
2174
|
-
docs2.drift = allDrift2;
|
|
2175
|
-
}
|
|
2176
|
-
return {
|
|
2177
|
-
...exp,
|
|
2178
|
-
docs: docs2
|
|
2179
|
-
};
|
|
2180
|
-
});
|
|
2181
|
-
const count = enrichedExports.length;
|
|
2182
|
-
const allMissing = collectAllMissing(enrichedExports);
|
|
2183
|
-
const allDrift = collectAllDrift(enrichedExports);
|
|
2184
|
-
const docs = {
|
|
2185
|
-
coverageScore: count === 0 ? 100 : Math.round(totalCoverage / count)
|
|
2186
|
-
};
|
|
2187
|
-
if (allMissing.length > 0) {
|
|
2188
|
-
docs.missing = allMissing;
|
|
2189
|
-
}
|
|
2190
|
-
if (allDrift.length > 0) {
|
|
2191
|
-
docs.drift = allDrift;
|
|
2192
|
-
}
|
|
2193
|
-
const driftSummary = allDrift.length > 0 ? getDriftSummary(allDrift) : undefined;
|
|
2194
|
-
return {
|
|
2195
|
-
...spec,
|
|
2196
|
-
exports: enrichedExports,
|
|
2197
|
-
docs,
|
|
2198
|
-
driftSummary
|
|
2199
|
-
};
|
|
2276
|
+
function getExportMissing(exp, doccov) {
|
|
2277
|
+
const analysis = getExportAnalysis(exp, doccov);
|
|
2278
|
+
return analysis?.missing ?? [];
|
|
2279
|
+
}
|
|
2280
|
+
function isExportFullyDocumented(exp, doccov) {
|
|
2281
|
+
const analysis = getExportAnalysis(exp, doccov);
|
|
2282
|
+
if (!analysis)
|
|
2283
|
+
return true;
|
|
2284
|
+
return analysis.coverageScore === 100 && (!analysis.drift || analysis.drift.length === 0);
|
|
2200
2285
|
}
|
|
2201
2286
|
|
|
2202
2287
|
// src/analysis/report.ts
|
|
2203
2288
|
import * as fs2 from "node:fs";
|
|
2204
2289
|
import * as path2 from "node:path";
|
|
2205
|
-
function generateReport(spec) {
|
|
2206
|
-
const
|
|
2207
|
-
return
|
|
2290
|
+
function generateReport(spec, openpkgPath = "openpkg.json") {
|
|
2291
|
+
const doccov = buildDocCovSpec({ openpkg: spec, openpkgPath });
|
|
2292
|
+
return generateReportFromDocCov(spec, doccov);
|
|
2208
2293
|
}
|
|
2209
|
-
function
|
|
2294
|
+
function generateReportFromDocCov(openpkg, doccov) {
|
|
2210
2295
|
const exportsData = {};
|
|
2211
2296
|
const missingByRule = {};
|
|
2212
2297
|
let documentedExports = 0;
|
|
2213
2298
|
let totalDrift = 0;
|
|
2214
|
-
for (const exp of
|
|
2299
|
+
for (const exp of openpkg.exports ?? []) {
|
|
2300
|
+
const analysis = getExportAnalysis(exp, doccov);
|
|
2215
2301
|
const data = {
|
|
2216
2302
|
name: exp.name,
|
|
2217
2303
|
kind: exp.kind,
|
|
2218
|
-
coverageScore:
|
|
2304
|
+
coverageScore: analysis?.coverageScore ?? 100
|
|
2219
2305
|
};
|
|
2220
|
-
if (
|
|
2221
|
-
data.missing =
|
|
2222
|
-
for (const ruleId of
|
|
2306
|
+
if (analysis?.missing && analysis.missing.length > 0) {
|
|
2307
|
+
data.missing = analysis.missing;
|
|
2308
|
+
for (const ruleId of analysis.missing) {
|
|
2223
2309
|
missingByRule[ruleId] = (missingByRule[ruleId] ?? 0) + 1;
|
|
2224
2310
|
}
|
|
2225
2311
|
} else {
|
|
2226
2312
|
documentedExports++;
|
|
2227
2313
|
}
|
|
2228
|
-
if (
|
|
2229
|
-
data.drift =
|
|
2230
|
-
totalDrift +=
|
|
2314
|
+
if (analysis?.drift && analysis.drift.length > 0) {
|
|
2315
|
+
data.drift = analysis.drift;
|
|
2316
|
+
totalDrift += analysis.drift.length;
|
|
2231
2317
|
}
|
|
2232
|
-
|
|
2318
|
+
const exportId = exp.id ?? exp.name;
|
|
2319
|
+
exportsData[exportId] = data;
|
|
2233
2320
|
}
|
|
2234
|
-
const allDrifts = enriched.exports.flatMap((exp) => exp.docs?.drift ?? []);
|
|
2235
|
-
const driftSummary = allDrifts.length > 0 ? getDriftSummary(allDrifts) : undefined;
|
|
2236
2321
|
const coverage = {
|
|
2237
|
-
score:
|
|
2238
|
-
totalExports:
|
|
2322
|
+
score: doccov.summary.score,
|
|
2323
|
+
totalExports: doccov.summary.totalExports,
|
|
2239
2324
|
documentedExports,
|
|
2240
2325
|
missingByRule,
|
|
2241
2326
|
driftCount: totalDrift,
|
|
2242
|
-
driftSummary
|
|
2327
|
+
driftSummary: doccov.summary.drift.total > 0 ? {
|
|
2328
|
+
total: doccov.summary.drift.total,
|
|
2329
|
+
fixable: doccov.summary.drift.fixable,
|
|
2330
|
+
byCategory: doccov.summary.drift.byCategory
|
|
2331
|
+
} : undefined
|
|
2243
2332
|
};
|
|
2244
2333
|
return {
|
|
2245
2334
|
$schema: "https://doccov.com/schemas/v1.0.0/report.schema.json",
|
|
2246
2335
|
version: REPORT_VERSION,
|
|
2247
2336
|
generatedAt: new Date().toISOString(),
|
|
2248
2337
|
spec: {
|
|
2249
|
-
name:
|
|
2250
|
-
version:
|
|
2338
|
+
name: openpkg.meta.name,
|
|
2339
|
+
version: openpkg.meta.version
|
|
2251
2340
|
},
|
|
2252
2341
|
coverage,
|
|
2253
2342
|
exports: exportsData
|
|
@@ -2911,4 +3000,4 @@ function getExtendedTrend(spec, cwd, options) {
|
|
|
2911
3000
|
};
|
|
2912
3001
|
}
|
|
2913
3002
|
|
|
2914
|
-
export { isFixableDrift, generateFix, generateFixesForExport, mergeFixes, categorizeDrifts, ts, parseJSDocToPatch, applyPatchToJSDoc, serializeJSDoc, findJSDocLocation, applyEdits, createSourceFile, isBuiltInTypeName, isBuiltInIdentifier, detectExampleRuntimeErrors, parseAssertions, hasNonAssertionComments, detectExampleAssertionFailures, buildExportRegistry, computeDrift, computeExportDrift, DRIFT_CATEGORIES, DRIFT_CATEGORY_LABELS, DRIFT_CATEGORY_DESCRIPTIONS, categorizeDrift, groupDriftsByCategory, getDriftSummary, formatDriftSummaryLine, calculateAggregateCoverage, ensureSpecCoverage,
|
|
3003
|
+
export { isFixableDrift, generateFix, generateFixesForExport, mergeFixes, categorizeDrifts, ts, parseJSDocToPatch, applyPatchToJSDoc, serializeJSDoc, findJSDocLocation, applyEdits, createSourceFile, isBuiltInTypeName, isBuiltInIdentifier, detectExampleRuntimeErrors, parseAssertions, hasNonAssertionComments, detectExampleAssertionFailures, buildExportRegistry, computeDrift, computeExportDrift, buildDocCovSpec, DRIFT_CATEGORIES2 as DRIFT_CATEGORIES, DRIFT_CATEGORY_LABELS, DRIFT_CATEGORY_DESCRIPTIONS, categorizeDrift, groupDriftsByCategory, getDriftSummary, formatDriftSummaryLine, calculateAggregateCoverage, ensureSpecCoverage, getExportAnalysis, getExportScore, getExportDrift, getExportMissing, isExportFullyDocumented, generateReport, generateReportFromDocCov, loadCachedReport, saveReport, isCachedReportValid, renderApiSurface, isStandardJSONSchema, resolveCompiledPath, extractStandardSchemas, extractStandardSchemasFromProject, detectRuntimeSchemas, HISTORY_DIR, RETENTION_DAYS, computeSnapshot, saveSnapshot, loadSnapshots, getTrend, renderSparkline, formatDelta, pruneHistory, pruneByTier, loadSnapshotsForDays, generateWeeklySummaries, getExtendedTrend };
|