@doccov/sdk 0.25.7 → 0.25.9
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/README.md +114 -18
- package/dist/index.d.ts +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @doccov/sdk
|
|
2
2
|
|
|
3
|
-
Programmatic API for documentation coverage analysis.
|
|
3
|
+
Programmatic API for documentation coverage analysis, drift detection, and spec generation.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -8,36 +8,132 @@ Programmatic API for documentation coverage analysis.
|
|
|
8
8
|
npm install @doccov/sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Quick Start
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { DocCov } from '@doccov/sdk';
|
|
14
|
+
import { DocCov, buildDocCovSpec } from '@doccov/sdk';
|
|
15
15
|
|
|
16
|
+
// Analyze a package
|
|
16
17
|
const doccov = new DocCov();
|
|
17
|
-
const
|
|
18
|
+
const result = await doccov.analyzeFileWithDiagnostics('src/index.ts');
|
|
19
|
+
|
|
20
|
+
// Build coverage spec
|
|
21
|
+
const spec = buildDocCovSpec({
|
|
22
|
+
openpkg: result.spec,
|
|
23
|
+
openpkgPath: 'src/index.ts',
|
|
24
|
+
packagePath: process.cwd(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
console.log(`Coverage: ${spec.summary.score}%`);
|
|
28
|
+
console.log(`Drift issues: ${spec.summary.drift.total}`);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Core API
|
|
32
|
+
|
|
33
|
+
### DocCov Class
|
|
34
|
+
|
|
35
|
+
Main analysis engine.
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { DocCov } from '@doccov/sdk';
|
|
18
39
|
|
|
19
|
-
|
|
40
|
+
const doccov = new DocCov({
|
|
41
|
+
resolveExternalTypes: true,
|
|
42
|
+
maxDepth: 20,
|
|
43
|
+
useCache: true,
|
|
44
|
+
});
|
|
20
45
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
46
|
+
const { spec, diagnostics } = await doccov.analyzeFileWithDiagnostics(
|
|
47
|
+
'src/index.ts',
|
|
48
|
+
{ filters: { visibility: ['public', 'beta'] } }
|
|
49
|
+
);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Coverage Analysis
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { buildDocCovSpec, getExportDrift } from '@doccov/sdk';
|
|
56
|
+
|
|
57
|
+
// Build DocCov spec with coverage data
|
|
58
|
+
const doccovSpec = buildDocCovSpec({ openpkg, openpkgPath, packagePath });
|
|
59
|
+
|
|
60
|
+
// Get drift for specific export
|
|
61
|
+
const drifts = getExportDrift(someExport, doccovSpec);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Example Validation
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { runExamples, typecheckExamples, validateExamples } from '@doccov/sdk';
|
|
68
|
+
|
|
69
|
+
// Run @example blocks
|
|
70
|
+
const results = await runExamples(spec.exports, { cwd: process.cwd() });
|
|
71
|
+
|
|
72
|
+
// Typecheck examples
|
|
73
|
+
const typeErrors = await typecheckExamples(spec.exports, { cwd: process.cwd() });
|
|
74
|
+
|
|
75
|
+
// Full validation
|
|
76
|
+
const validation = await validateExamples(spec, {
|
|
77
|
+
validations: ['presence', 'typecheck', 'run'],
|
|
78
|
+
targetDir: process.cwd(),
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Target Resolution
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { resolveTarget, NodeFileSystem } from '@doccov/sdk';
|
|
86
|
+
|
|
87
|
+
const fs = new NodeFileSystem(process.cwd());
|
|
88
|
+
const { entryFile, targetDir, packageInfo } = await resolveTarget(fs, {
|
|
89
|
+
cwd: process.cwd(),
|
|
90
|
+
package: '@my/package', // For monorepos
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### History & Trends
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { saveSnapshot, loadSnapshots, getTrend } from '@doccov/sdk';
|
|
98
|
+
|
|
99
|
+
// Save coverage snapshot
|
|
100
|
+
saveSnapshot(computeSnapshot(spec), process.cwd());
|
|
101
|
+
|
|
102
|
+
// Load history
|
|
103
|
+
const snapshots = loadSnapshots(process.cwd());
|
|
104
|
+
|
|
105
|
+
// Get trend analysis
|
|
106
|
+
const trend = getTrend(spec, process.cwd());
|
|
107
|
+
console.log(`Delta: ${trend.delta}%`);
|
|
27
108
|
```
|
|
28
109
|
|
|
29
110
|
## Exports
|
|
30
111
|
|
|
112
|
+
### Analysis
|
|
31
113
|
- `DocCov` - Main analysis class
|
|
32
|
-
- `
|
|
33
|
-
- `
|
|
114
|
+
- `buildDocCovSpec` - Build coverage spec
|
|
115
|
+
- `getExportDrift` - Get drift for an export
|
|
116
|
+
- `generateReport` - Generate coverage reports
|
|
117
|
+
|
|
118
|
+
### Examples
|
|
119
|
+
- `runExamples` / `runExample` - Execute @example blocks
|
|
120
|
+
- `typecheckExamples` - Type-check examples
|
|
121
|
+
- `validateExamples` - Full example validation
|
|
122
|
+
|
|
123
|
+
### Resolution
|
|
124
|
+
- `resolveTarget` - Resolve entry points
|
|
125
|
+
- `NodeFileSystem` - File system adapter
|
|
126
|
+
- `detectPackageManager` - Detect npm/yarn/pnpm/bun
|
|
34
127
|
|
|
35
|
-
|
|
128
|
+
### History
|
|
129
|
+
- `saveSnapshot` / `loadSnapshots` - Manage coverage history
|
|
130
|
+
- `getTrend` / `getExtendedTrend` - Trend analysis
|
|
131
|
+
- `pruneHistory` - Clean old snapshots
|
|
36
132
|
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
133
|
+
### Utilities
|
|
134
|
+
- `diffSpecWithDocs` - Diff specs with doc impact
|
|
135
|
+
- `parseMarkdownFiles` - Parse markdown for refs
|
|
136
|
+
- `generateFix` / `applyPatchToJSDoc` - Auto-fix drift
|
|
41
137
|
|
|
42
138
|
## License
|
|
43
139
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2515,7 +2515,7 @@ interface SpecSummary {
|
|
|
2515
2515
|
* ```
|
|
2516
2516
|
*/
|
|
2517
2517
|
declare function extractSpecSummary(openpkg: OpenPkg8, doccov: DocCovSpec4): SpecSummary;
|
|
2518
|
-
import { OpenPkg as
|
|
2518
|
+
import { OpenPkg as OpenPkg_gniycepely } from "@openpkg-ts/spec";
|
|
2519
2519
|
/**
|
|
2520
2520
|
* Build Plan types for AI-powered repository scanning.
|
|
2521
2521
|
*/
|
|
@@ -2612,7 +2612,7 @@ interface BuildPlanExecutionResult {
|
|
|
2612
2612
|
/** Whether all required steps succeeded */
|
|
2613
2613
|
success: boolean;
|
|
2614
2614
|
/** Generated OpenPkg spec (if successful) */
|
|
2615
|
-
spec?:
|
|
2615
|
+
spec?: OpenPkg_gniycepely;
|
|
2616
2616
|
/** Results for each step */
|
|
2617
2617
|
stepResults: BuildPlanStepResult[];
|
|
2618
2618
|
/** Total execution time in milliseconds */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doccov/sdk",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.9",
|
|
4
4
|
"description": "DocCov SDK - Documentation coverage and drift detection for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@doccov/spec": "^0.24.1",
|
|
51
|
-
"@openpkg-ts/extract": "^0.14.
|
|
51
|
+
"@openpkg-ts/extract": "^0.14.3",
|
|
52
52
|
"@openpkg-ts/spec": "^0.12.0",
|
|
53
53
|
"@vercel/sandbox": "^1.0.3",
|
|
54
54
|
"mdast": "^3.0.0",
|