Skip to content

Commit b07eb8a

Browse files
committed
feat: change from compodoc to typedoc
1 parent bf1775d commit b07eb8a

File tree

11 files changed

+346
-100
lines changed

11 files changed

+346
-100
lines changed

package-lock.json

Lines changed: 162 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@
110110
"tsconfig-paths": "^4.2.0",
111111
"tsx": "^4.19.0",
112112
"type-fest": "^4.26.1",
113+
"typedoc": "^0.27.5",
114+
"typedoc-plugin-coverage": "^3.4.0",
113115
"typescript": "5.5.4",
114116
"typescript-eslint": "^8.18.0",
115117
"verdaccio": "^5.32.2",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** Dummy function */
2+
export function DUMMY_FUNCTION() {
3+
return 'Hello World';
4+
}

packages/plugin-doc-coverage/src/lib/config.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@ import { z } from 'zod';
33
export type DocType = 'percentage-coverage';
44

55
export const docCoveragePluginConfigSchema = z.object({
6-
coverageToolCommand: z
7-
.object({
8-
command: z
9-
.string({ description: 'Command to run coverage tool (compodoc).' })
10-
.min(1),
11-
args: z
12-
.array(z.string(), {
13-
description: 'Arguments to be passed to the coverage tool.',
14-
})
15-
.optional(),
6+
language: z.enum(['javascript', 'typescript'], {
7+
description: 'Programming language of the source code to analyze',
8+
}),
9+
sourceGlob: z
10+
.string({
11+
description: 'Glob pattern to find source files',
12+
})
13+
.optional(),
14+
outputFolderPath: z
15+
.string({
16+
description: 'Path to the output folder',
1617
})
1718
.optional(),
18-
outputPath: z
19-
.string({ description: 'Path to the documentation.json file.' })
20-
.default('documentation/documentation.json'),
2119
});
2220

23-
export type DocCoveragePluginConfig = z.infer<
21+
export type DocCoveragePluginConfig = z.input<
2422
typeof docCoveragePluginConfigSchema
2523
>;

packages/plugin-doc-coverage/src/lib/config.unit.test.ts

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,57 @@ describe('docCoveragePluginConfigSchema', () => {
88
it('accepts a documentation coverage configuration with all entities', () => {
99
expect(() =>
1010
docCoveragePluginConfigSchema.parse({
11-
coverageToolCommand: {
12-
command: 'npx @compodoc/compodoc',
13-
args: ['-p', 'tsconfig.json'],
14-
},
15-
outputPath: 'documentation/custom-doc.json',
11+
language: 'typescript',
12+
sourceGlob: 'src/**/*.{ts,tsx}',
1613
} satisfies DocCoveragePluginConfig),
1714
).not.toThrow();
1815
});
1916

20-
it('accepts a minimal documentation coverage configuration', () => {
17+
it('accepts minimal configuration with only language', () => {
2118
expect(() =>
22-
docCoveragePluginConfigSchema.parse({} satisfies DocCoveragePluginConfig),
19+
docCoveragePluginConfigSchema.parse({
20+
language: 'javascript',
21+
} satisfies DocCoveragePluginConfig),
2322
).not.toThrow();
2423
});
2524

26-
it('uses default output path when not provided', () => {
27-
const config = {} satisfies DocCoveragePluginConfig;
25+
it('accepts configuration without sourceGlob', () => {
26+
const config = {
27+
language: 'typescript',
28+
} satisfies DocCoveragePluginConfig;
2829
const parsed = docCoveragePluginConfigSchema.parse(config);
2930

30-
expect(parsed.outputPath).toBe('documentation/documentation.json');
31+
expect(parsed.sourceGlob).toBeUndefined();
3132
});
3233

33-
it('throws for missing command in coverageToolCommand', () => {
34+
it('throws for missing language', () => {
3435
expect(() =>
3536
docCoveragePluginConfigSchema.parse({
36-
coverageToolCommand: {
37-
args: ['-p', 'tsconfig.json'],
38-
},
37+
sourceGlob: 'src/**/*.ts',
3938
}),
4039
).toThrow('invalid_type');
4140
});
4241

43-
it('accepts empty args in coverageToolCommand', () => {
42+
it('throws for invalid language', () => {
4443
expect(() =>
4544
docCoveragePluginConfigSchema.parse({
46-
coverageToolCommand: {
47-
command: 'npx @compodoc/compodoc',
48-
},
49-
} satisfies DocCoveragePluginConfig),
45+
language: 'python',
46+
sourceGlob: 'src/**/*.py',
47+
}),
48+
).toThrow('Invalid enum value');
49+
});
50+
51+
it('accepts both typescript and javascript as valid languages', () => {
52+
expect(() =>
53+
docCoveragePluginConfigSchema.parse({
54+
language: 'typescript',
55+
}),
56+
).not.toThrow();
57+
58+
expect(() =>
59+
docCoveragePluginConfigSchema.parse({
60+
language: 'javascript',
61+
}),
5062
).not.toThrow();
5163
});
5264
});

packages/plugin-doc-coverage/src/lib/doc-coverage-plugin.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import { createRunnerConfig } from './runner/index.js';
1919
* plugins: [
2020
* // ... other plugins ...
2121
* await docCoveragePlugin({
22-
*
23-
* docTypes: ['class', 'function']
22+
* language: 'typescript'
2423
* })
2524
* ]
2625
* }

0 commit comments

Comments
 (0)