Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POC] Test generating doc using TypeDoc #15836

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"string-replace-loader": "^3.1.0",
"terser-webpack-plugin": "^5.3.10",
"tsx": "^4.19.2",
"typedoc": "^0.27.4",
"typescript": "^5.7.2",
"unist-util-visit": "^5.0.0",
"util": "^0.12.5",
Expand All @@ -207,7 +208,8 @@
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]"
"[email protected]": "patches/[email protected]",
"@shikijs/[email protected]": "patches/@[email protected]"
}
}
}
14 changes: 14 additions & 0 deletions patches/@[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/package.json b/package.json
index 072aac0e6c123935c867570ff8c098f150c22594..a6152eddcb8626e225db358e38503c814c0a56ce 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,8 @@
"exports": {
".": {
"import": "./dist/index.mjs",
- "types": "./dist/index.d.mts"
+ "types": "./dist/index.d.mts",
+ "default": "./dist/index.mjs"
}
},
"main": "./dist/index.mjs",
71 changes: 71 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions scripts/tsDoc/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import path from 'path';
import { Application } from 'typedoc';
import ts from 'typescript';

async function main() {
const entryPoint = './packages/x-charts/src/index.ts';

const configFileName = ts.findConfigFile(
path.dirname(entryPoint),
ts.sys.fileExists,
'tsconfig.json',
);

if (!configFileName) {
throw new Error('Could not find a valid tsconfig.json');
}

// Application.bootstrap also exists, which will not load plugins
// Also accepts an array of option readers if you want to disable
// TypeDoc's tsconfig.json/package.json/typedoc.json option readers
const app = await Application.bootstrap({
entryPoints: [entryPoint],
// blockTags: ['@default'],
jsDocCompatibility: {
defaultTag: true,
exampleTag: true,
ignoreUnescapedBraces: true,
},
cleanOutputDir: true,
excludeTags: ['@internal'],
tsconfig: configFileName,
});

// May be undefined if errors are encountered.
const project = await app.convert();

if (project) {
const outputDir = 'generated-docs';
// Generate HTML rendered docs
await app.generateJson(project, `${outputDir}/docs.json`);
}
}

main().catch((error) => {
console.error(error.message);
process.exit(1);
});
4 changes: 4 additions & 0 deletions scripts/tsDoc/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["./**/*.ts"]
}
Loading