/
githubmirror
/
trpc
Обзор
Документация
Войти
/
githubmirror
/
trpc
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
www/docusaurus.typedoc.js
95 строк
3 KB
Nick Lucas
feat(docs): revamp docs content for 2026, more framework agnostic, improved Next.js docs (#7193)
08 мар 2026, 12:14
Не верифицирован
08 мар 2026, 12:14
2bf122d
Код
Авторство
О чём код?
/* eslint-disable @typescript-eslint/no-var-requires */ // @ts-check const fs = require('fs'); const path = require('path'); /** * @param {string[]} directories */ function generateTypedocDocusaurusPlugins(directories) { const withEntryPoints = directories.map((directory) => { const pkgJson = JSON.parse( fs.readFileSync( path.join(__dirname, `../packages/${directory}/package.json`), 'utf-8', ), ); /** * @type { Record<string, { import: { default: string; types: string }; require: { default: string; types: string }; } | string> } */ const exports = pkgJson.exports; const entrypoints = Object.entries(exports) .flatMap(([_key, value]) => { if (typeof value === 'string') { return []; } return [value.import.default]; }) .map((it) => it.replace('./dist/', '').replace('.mjs', '.ts')) .filter((it) => { if (it.includes('unstable')) { return false; } switch (directory) { case 'client': { return true; } case 'next': // FIXME: this shouldn't be excluded return it === 'index.ts'; case 'server': // Exclude deprecated shared.ts re-export, include everything else return it !== 'shared.ts'; } return true; }); return { directory, entrypoints, }; }); console.log('TypeDoc entrypoints:', withEntryPoints); return withEntryPoints.map((opts, idx) => { const { directory, entrypoints } = opts; return [ 'docusaurus-plugin-typedoc', { // TypeDoc options // https://typedoc.org/guides/options/ skipErrorChecking: true, id: directory, entryPoints: entrypoints.map( (it) => `../packages/${directory}/src/${it}`, ), tsconfig: `../packages/${directory}/tsconfig.build.json`, out: `./docs/typedoc/${directory}`, readme: 'none', sourceLinkTemplate: 'https://github.com/trpc/trpc/blob/{gitRevision}/{path}#L{line}', excludeInternal: true, excludePrivate: true, excludeProtected: true, excludeExternals: true, parametersFormat: 'table', sidebar: { autoConfiguration: true, pretty: true, }, //Possible not needed code: // docusaurus-plugin-typedoc options // https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc#plugin-options // sidebar: { // categoryLabel: `@trpc/${directory}`, // position: idx, // }, }, ]; }); } module.exports = { generateTypedocDocusaurusPlugins };