Skip to content

Commit 650b3c1

Browse files
authored
feat: Auto gen type docs via TypeDoc (#95)
Add in TypeDoc to auto generate docs for the bundler plugins. GH #50
1 parent 539b65e commit 650b3c1

File tree

20 files changed

+305
-23
lines changed

20 files changed

+305
-23
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const config = {
1616
"**/test-apps/**",
1717
"**/integration-tests/**/*.cjs",
1818
"**/integration-tests/test-api/**/*",
19+
"**/scripts/publish-docs.js",
20+
"**/typedoc/plugin-remove-references.js",
1921
],
2022
parserOptions: {
2123
ecmaVersion: "latest",

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ jobs:
4141
with:
4242
publish: pnpm changeset:publish
4343
createGithubReleases: true
44+
45+
- name: Publish new docs
46+
run: node scripts/publish-docs.js

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"prepare": "husky install",
2323
"changeset:add": "pnpm changeset",
2424
"changeset:consume": "pnpm changeset version",
25-
"changeset:publish": "pnpm run build && pnpm changeset publish"
25+
"changeset:publish": "pnpm run build && pnpm changeset publish",
26+
"generate:typedoc": "typedoc --options ./typedoc.json",
27+
"generate:typedoc:packages": "pnpm -r --filter='./packages/*' run generate:typedoc"
2628
},
2729
"devDependencies": {
2830
"@changesets/cli": "^2.27.1",
@@ -39,6 +41,7 @@
3941
"husky": "^8.0.3",
4042
"lint-staged": "^15.2.1",
4143
"prettier": "^3.2.4",
44+
"typedoc": "^0.25.12",
4245
"typescript": "^5.3.3"
4346
},
4447
"lint-staged": {

packages/bundler-plugin-core/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"format": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
3434
"format:check": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --check",
3535
"test:unit": "jest",
36-
"test:unit:ci": "JEST_JUNIT_OUTPUT_NAME='bundler-plugin-core.junit.xml' jest --coverage --reporters=jest-junit"
36+
"test:unit:ci": "JEST_JUNIT_OUTPUT_NAME='bundler-plugin-core.junit.xml' jest --coverage --reporters=jest-junit",
37+
"generate:typedoc": "typedoc --options ./typedoc.json"
3738
},
3839
"dependencies": {
3940
"chalk": "4.1.2",
@@ -47,13 +48,14 @@
4748
"@types/jest": "^29.5.11",
4849
"@types/node": "^20.11.15",
4950
"@types/semver": "^7.5.6",
50-
"codecovProdRollupPlugin": "npm:@codecov/[email protected].2",
51+
"codecovProdRollupPlugin": "npm:@codecov/[email protected].3",
5152
"jest": "^29.7.0",
5253
"jest-junit": "^16.0.0",
5354
"msw": "^2.1.5",
5455
"testdouble": "^3.20.1",
5556
"testdouble-jest": "^2.0.0",
5657
"ts-node": "^10.9.2",
58+
"typedoc": "^0.25.12",
5759
"typescript": "^5.3.3",
5860
"unbuild": "^2.0.0"
5961
},

packages/bundler-plugin-core/src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export interface BundleAnalysisUploadPluginArgs {
5151
options: NormalizedOptions;
5252
}
5353

54+
/** Configuration ptions for the Codcov bundler plugin. */
5455
export interface Options {
5556
/**
5657
* The upload token to use for uploading the bundle analysis information.
@@ -105,6 +106,7 @@ export interface Options {
105106
/** Override values for passing custom information to API. */
106107
uploadOverrides?: UploadOverrides;
107108

109+
/** A set of options to configure Sentry settings inside the plugin. */
108110
sentry?: {
109111
/**
110112
* Only send bundle stats to sentry (used within sentry bundler plugin).
@@ -141,6 +143,7 @@ export type BundleAnalysisUploadPlugin = (
141143
version: string;
142144
};
143145

146+
/** A set of overrides that are passed to Codecov. */
144147
export interface UploadOverrides {
145148
/** Specify the branch manually. */
146149
branch?: string;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://typedoc.org/schema.json",
3+
"extends": ["../../typedoc.base.json"],
4+
"entryPoints": ["src/index.ts"]
5+
}

packages/rollup-plugin/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"format": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
4040
"format:check": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --check",
4141
"test:unit": "jest",
42-
"test:unit:ci": "JEST_JUNIT_OUTPUT_NAME='rollup-plugin.junit.xml' jest --coverage --reporters=jest-junit"
42+
"test:unit:ci": "JEST_JUNIT_OUTPUT_NAME='rollup-plugin.junit.xml' jest --coverage --reporters=jest-junit",
43+
"generate:typedoc": "typedoc --options ./typedoc.json"
4344
},
4445
"dependencies": {
4546
"@codecov/bundler-plugin-core": "workspace:^"
@@ -49,12 +50,13 @@
4950
"@swc/jest": "^0.2.33",
5051
"@types/jest": "^29.5.11",
5152
"@types/node": "^20.11.15",
52-
"codecovProdRollupPlugin": "npm:@codecov/[email protected].2",
53+
"codecovProdRollupPlugin": "npm:@codecov/[email protected].3",
5354
"jest": "^29.7.0",
5455
"jest-junit": "^16.0.0",
5556
"msw": "^2.1.5",
5657
"rollup": "4.9.6",
5758
"ts-node": "^10.9.2",
59+
"typedoc": "^0.25.12",
5860
"typescript": "^5.3.3",
5961
"unbuild": "^2.0.0"
6062
},

packages/rollup-plugin/src/index.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import {
23
codecovUnpluginFactory,
34
type Options,
@@ -9,6 +10,30 @@ const codecovUnplugin = codecovUnpluginFactory({
910
bundleAnalysisUploadPlugin: rollupBundleAnalysisPlugin,
1011
});
1112

12-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
13+
// eslint-disable-next-line isaacscript/complete-sentences-jsdoc
14+
/**
15+
* Details for the Codecov Rollup plugin.
16+
*
17+
* @param {Options} options - See {@link @codecov/bundler-plugin-core!Options | Options} for more
18+
* details.
19+
*
20+
* @example
21+
* ```typescript
22+
* // rollup.config.js
23+
* import { defineConfig } from "rollup";
24+
* import { codecovRollupPlugin } from "@codecov/rollup-plugin";
25+
*
26+
* export default defineConfig({
27+
* plugins: [
28+
* // Put the Codecov rollup plugin after all other plugins
29+
* codecovRollupPlugin({
30+
* enableBundleAnalysis: true,
31+
* bundleName: "example-rollup-bundle",
32+
* uploadToken: process.env.CODECOV_TOKEN,
33+
* }),
34+
* ],
35+
* });
36+
* ```
37+
*/
1338
export const codecovRollupPlugin: (options: Options) => any =
1439
codecovUnplugin.rollup;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://typedoc.org/schema.json",
3+
"extends": ["../../typedoc.base.json"],
4+
"entryPoints": ["src/index.ts"]
5+
}

packages/vite-plugin/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"format": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
4040
"format:check": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --check",
4141
"test:unit": "jest",
42-
"test:unit:ci": "JEST_JUNIT_OUTPUT_NAME='vite-plugin.junit.xml' jest --coverage --reporters=jest-junit"
42+
"test:unit:ci": "JEST_JUNIT_OUTPUT_NAME='vite-plugin.junit.xml' jest --coverage --reporters=jest-junit",
43+
"generate:typedoc": "typedoc --options ./typedoc.json"
4344
},
4445
"dependencies": {
4546
"@codecov/bundler-plugin-core": "workspace:^"
@@ -49,11 +50,12 @@
4950
"@swc/jest": "^0.2.33",
5051
"@types/jest": "^29.5.11",
5152
"@types/node": "^20.11.15",
52-
"codecovProdRollupPlugin": "npm:@codecov/[email protected].2",
53+
"codecovProdRollupPlugin": "npm:@codecov/[email protected].3",
5354
"jest": "^29.7.0",
5455
"jest-junit": "^16.0.0",
5556
"msw": "^2.1.5",
5657
"ts-node": "^10.9.2",
58+
"typedoc": "^0.25.12",
5759
"typescript": "^5.3.3",
5860
"unbuild": "^2.0.0",
5961
"vite": "5.0.12"

0 commit comments

Comments
 (0)