-
Notifications
You must be signed in to change notification settings - Fork 15
chore: move transformers to new project #1163
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
867c80d
refactor: move models-transformers into tools
594f451
refactor: add zod2md-nx-plugin
00256ee
refactor: wip
9112bf0
refactor: adjust plugin code
9f83837
refactor: wip
83dd2d8
refactor: wip
ee32341
refactor: wip
f8a89f8
Update tools/jsdoc-annotation-transformer/README.md
BioPhoton 7221e42
refactor: wip
9b12e0f
Merge branch 'main' into chore/move-transformers-project
d2fd736
refactor: add baseUrl options
33971a7
Merge remote-tracking branch 'origin/main' into chore/move-transforme…
96a763d
refactor: rename
e751c3f
refactor: rename
2a94cd8
refactor: wip
c40f9b1
refactor: wip
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # @code-pushup/zod2md-jsdocs | ||
|
|
||
| TypeScript transformer plugin that automatically enhances type definitions with JSDoc comments and schema metadata. | ||
|
|
||
| ## Purpose | ||
|
|
||
| This package provides a TypeScript compiler transformer that automatically adds JSDoc documentation to type aliases and interfaces during compilation. It's designed to improve developer experience by injecting helpful metadata and documentation links directly into generated type definitions. | ||
|
|
||
| ## How It Works | ||
|
|
||
| The [TS transformer](https://github.com/itsdouges/typescript-transformer-handbook) hooks into the TypeScript compilation process using `ts-patch` and automatically adds JSDoc comments above type definitions. Each comment includes: | ||
|
|
||
| - The type name | ||
| - A description explaining the type is derived from a Zod schema | ||
| - A link to the type reference documentation | ||
|
|
||
| ## Example | ||
|
|
||
| Given a type definition like: | ||
|
|
||
| ```typescript | ||
| export type Report = { | ||
| // ... type properties | ||
| }; | ||
| ``` | ||
|
|
||
| The transformer automatically generates: | ||
|
|
||
| ```typescript | ||
| /** | ||
| * Type Definition: `Report` | ||
| * | ||
| * This type is derived from a Zod schema and represents | ||
| * the validated structure of `Report` used within the application. | ||
| * | ||
| * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#report} | ||
| */ | ||
| export type Report = { | ||
| // ... type properties | ||
| }; | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| 1. `ts-patch install` | ||
|
|
||
| 2. Add the transformer to your `tsconfig.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "compilerOptions": { | ||
| "plugins": [ | ||
| { | ||
| "transform": "./path/to/transformer/dist", | ||
| "afterDeclarations": true, | ||
| "baseUrl": "https://example.com/docs/api-reference.md" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| 3. Build your TypeScript project. The transformer will run automatically and add JSDoc comments to your type definitions. | ||
|
|
||
| ### Options | ||
|
|
||
| | Option | Type | Required | Description | | ||
| | ------------------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | `transform` | `string` | Yes | Path to the transformer module | | ||
| | `afterDeclarations` | `boolean` | No | Set to `true` to run the transformer after TypeScript generates declaration files (`.d.ts`). This ensures JSDoc comments are added to the emitted type definitions. | | ||
| | `baseUrl` | `string` | Yes | Base URL for documentation links (e.g., `https://example.com/docs/api-reference.md`) | |
2 changes: 1 addition & 1 deletion
2
...ges/models/transformers/eslint.config.cjs → tools/zod2md-jsdocs/eslint.config.cjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/models/transformers/package.json → tools/zod2md-jsdocs/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
packages/models/transformers/project.json → tools/zod2md-jsdocs/project.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/models/transformers/tsconfig.json → tools/zod2md-jsdocs/tsconfig.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| "extends": "./tsconfig.json", | ||
| "compilerOptions": { | ||
| "outDir": "../../dist/out-tsc", | ||
| "types": [ | ||
| "vitest/globals", | ||
| "vitest/importMeta", | ||
| "vite/client", | ||
| "node", | ||
| "vitest" | ||
| ] | ||
| }, | ||
| "include": [ | ||
| "vite.config.ts", | ||
| "vite.config.mts", | ||
| "vitest.config.ts", | ||
| "vitest.config.mts", | ||
| "vitest.unit.config.ts", | ||
| "src/**/*.test.ts", | ||
| "src/**/*.spec.ts", | ||
| "src/**/*.test.tsx", | ||
| "src/**/*.spec.tsx", | ||
| "src/**/*.test.js", | ||
| "src/**/*.spec.js", | ||
| "src/**/*.test.jsx", | ||
| "src/**/*.spec.jsx", | ||
| "src/**/*.d.ts" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { createUnitTestConfig } from '../../testing/test-setup-config/src/index.js'; | ||
|
|
||
| export default createUnitTestConfig('zod2md-jsdocs'); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.