From cb8cc1757c7ed5bf400e73a37448736ed9c2928d Mon Sep 17 00:00:00 2001 From: Joe Clark Date: Tue, 25 Jun 2024 16:50:10 +0100 Subject: [PATCH] describe-package: document anything with an @function tag Not sure I like this but it's consistent with the main docsite --- packages/describe-package/package.json | 4 +- packages/describe-package/src/api.ts | 2 +- packages/describe-package/src/cli.ts | 12 ++++ .../describe-package/src/describe-project.ts | 2 +- .../src/typescript/wrapped-symbol.ts | 9 +-- packages/describe-package/tsconfig.json | 3 +- pnpm-lock.yaml | 63 ++++++++++++++++--- 7 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 packages/describe-package/src/cli.ts diff --git a/packages/describe-package/package.json b/packages/describe-package/package.json index 8ac190cd1..4bbac706d 100644 --- a/packages/describe-package/package.json +++ b/packages/describe-package/package.json @@ -32,7 +32,8 @@ "build:worker": "tsm esbuild-worker.ts", "build:node": "tsup --config tsup.config.js src/index.ts", "build": "pnpm clean && pnpm build:node && pnpm build:worker", - "pack": "pnpm pack --pack-destination ../../dist" + "pack": "pnpm pack --pack-destination ../../dist", + "cli": "npx tsx src/cli.ts" }, "keywords": [], "devDependencies": { @@ -44,7 +45,6 @@ "esbuild": "^0.18.14", "rimraf": "^3.0.2", "threads": "1.7.0", - "ts-node": "^10.9.1", "tslib": "^2.4.0", "tsm": "^2.2.1", "tsup": "^7.2.0" diff --git a/packages/describe-package/src/api.ts b/packages/describe-package/src/api.ts index a49a006f9..c34ac856f 100644 --- a/packages/describe-package/src/api.ts +++ b/packages/describe-package/src/api.ts @@ -64,7 +64,7 @@ export type ParameterDescription = { */ export const describePackage = async ( specifier: string, - _options: Options + _options: Options = {} ): Promise => { const { name, version } = getNameAndVersion(specifier); const project = new Project(); diff --git a/packages/describe-package/src/cli.ts b/packages/describe-package/src/cli.ts new file mode 100644 index 000000000..1c4eea599 --- /dev/null +++ b/packages/describe-package/src/cli.ts @@ -0,0 +1,12 @@ +import { describePackage } from './api'; + +const a = process.argv[2]; + +async function run(specifier: string) { + const result = await describePackage(specifier, {}); + + console.log(result); +} + +console.log('GENERATING FOR', a); +run(a); diff --git a/packages/describe-package/src/describe-project.ts b/packages/describe-package/src/describe-project.ts index 18f9f7593..a7dea2a2b 100644 --- a/packages/describe-package/src/describe-project.ts +++ b/packages/describe-package/src/describe-project.ts @@ -97,7 +97,7 @@ const describeProject = ( return true; } // Return all export aliases and public symbols - return symbol.isExportAlias || symbol.isPublic; + return symbol.isExportAlias || symbol.hasFunctionTag; }) .reduce((symbols, symbol) => { if (symbol.isFunctionDeclaration) { diff --git a/packages/describe-package/src/typescript/wrapped-symbol.ts b/packages/describe-package/src/typescript/wrapped-symbol.ts index 09d30453b..96c021a47 100644 --- a/packages/describe-package/src/typescript/wrapped-symbol.ts +++ b/packages/describe-package/src/typescript/wrapped-symbol.ts @@ -86,10 +86,11 @@ export class WrappedSymbol { return this.symbol.valueDeclaration?.type; } - // A function is private unless it has a public tag - public get isPublic(): boolean { - return this.jsDocTags.some( - (tag: ts.JSDocTag) => tag.tagName.escapedText === 'public' + public get hasFunctionTag(): boolean { + return Boolean( + this.jsDocTags.find( + (tag: ts.JSDocTag) => tag.tagName.escapedText === 'function' + ) ); } diff --git a/packages/describe-package/tsconfig.json b/packages/describe-package/tsconfig.json index 8faf254bc..b7d0e2788 100644 --- a/packages/describe-package/tsconfig.json +++ b/packages/describe-package/tsconfig.json @@ -4,6 +4,7 @@ "exclude": ["node_modules", "**/*.spec.ts", "dist"], "compilerOptions": { "typeRoots": ["./node_modules/@types"], - "target": "ESNext" + "target": "ESNext", + "esModuleInterop": true, } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 18912389d..b52145b11 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -372,9 +372,6 @@ importers: threads: specifier: 1.7.0 version: 1.7.0 - ts-node: - specifier: ^10.9.1 - version: 10.9.1(@types/node@18.15.13)(typescript@5.1.6) tslib: specifier: ^2.4.0 version: 2.4.0 @@ -383,7 +380,7 @@ importers: version: 2.2.2 tsup: specifier: ^7.2.0 - version: 7.2.0(ts-node@10.9.1)(typescript@5.1.6) + version: 7.2.0(typescript@5.1.6) packages/engine-multi: dependencies: @@ -4229,7 +4226,7 @@ packages: requiresBuild: true dependencies: bindings: 1.5.0 - nan: 2.18.0 + nan: 2.20.0 dev: true optional: true @@ -5650,8 +5647,8 @@ packages: thenify-all: 1.6.0 dev: true - /nan@2.18.0: - resolution: {integrity: sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==} + /nan@2.20.0: + resolution: {integrity: sha512-bk3gXBZDGILuuo/6sKtr0DQmSThYHLtNCdSdXk9YkxD/jK6X2vmCyyXBBxyqZ4XcnzTyYEAThfX3DCEnLf6igw==} requiresBuild: true dev: true optional: true @@ -6247,6 +6244,22 @@ packages: yaml: 1.10.2 dev: true + /postcss-load-config@4.0.1: + resolution: {integrity: sha512-vEJIc8RdiBRu3oRAI0ymerOn+7rPuMvRXslTvZUKZonDHFIczxztIyJ1urxM1x9JXEikvpWWTUUqal5j/8QgvA==} + engines: {node: '>= 14'} + peerDependencies: + postcss: '>=8.0.9' + ts-node: '>=9.0.0' + peerDependenciesMeta: + postcss: + optional: true + ts-node: + optional: true + dependencies: + lilconfig: 2.1.0 + yaml: 2.3.1 + dev: true + /postcss-load-config@4.0.1(ts-node@10.8.1): resolution: {integrity: sha512-vEJIc8RdiBRu3oRAI0ymerOn+7rPuMvRXslTvZUKZonDHFIczxztIyJ1urxM1x9JXEikvpWWTUUqal5j/8QgvA==} engines: {node: '>= 14'} @@ -7586,6 +7599,42 @@ packages: - ts-node dev: true + /tsup@7.2.0(typescript@5.1.6): + resolution: {integrity: sha512-vDHlczXbgUvY3rWvqFEbSqmC1L7woozbzngMqTtL2PGBODTtWlRwGDDawhvWzr5c1QjKe4OAKqJGfE1xeXUvtQ==} + engines: {node: '>=16.14'} + hasBin: true + peerDependencies: + '@swc/core': ^1 + postcss: ^8.4.12 + typescript: '>=4.1.0' + peerDependenciesMeta: + '@swc/core': + optional: true + postcss: + optional: true + typescript: + optional: true + dependencies: + bundle-require: 4.0.1(esbuild@0.18.20) + cac: 6.7.14 + chokidar: 3.5.3 + debug: 4.3.4 + esbuild: 0.18.20 + execa: 5.1.1 + globby: 11.1.0 + joycon: 3.1.1 + postcss-load-config: 4.0.1 + resolve-from: 5.0.0 + rollup: 3.27.2 + source-map: 0.8.0-beta.0 + sucrase: 3.34.0 + tree-kill: 1.2.2 + typescript: 5.1.6 + transitivePeerDependencies: + - supports-color + - ts-node + dev: true + /tty-table@4.1.6: resolution: {integrity: sha512-kRj5CBzOrakV4VRRY5kUWbNYvo/FpOsz65DzI5op9P+cHov3+IqPbo1JE1ZnQGkHdZgNFDsrEjrfqqy/Ply9fw==} engines: {node: '>=8.0.0'}