Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
867c80d
refactor: move models-transformers into tools
Dec 2, 2025
594f451
refactor: add zod2md-nx-plugin
Dec 2, 2025
00256ee
refactor: wip
Dec 2, 2025
9112bf0
refactor: adjust plugin code
Dec 2, 2025
c7882cb
refactor: wip
Dec 2, 2025
1cf9a7a
refactor: wip
Dec 2, 2025
12a12d5
refactor: wip
Dec 2, 2025
4d629f4
refactor: wip
Dec 2, 2025
fb004e1
refactor: wip
Dec 2, 2025
8253323
Update tools/zod2md-nx-plugin/eslint.config.js
BioPhoton Dec 3, 2025
670b232
Update tools/zod2md-nx-plugin/README.md
BioPhoton Dec 3, 2025
a4cf4b9
refactor: wip
Dec 3, 2025
b02a6a0
refactor: wip
Dec 3, 2025
4d6c335
refactor: wip
Dec 3, 2025
ce500c7
refactor: wip
Dec 3, 2025
1a158f1
Merge branch 'main' into chore/add-zod2md-nx-plugin
Dec 3, 2025
25c79f4
Merge remote-tracking branch 'origin/main' into chore/add-zod2md-nx-p…
Dec 4, 2025
1daa238
Merge branch 'main' into chore/add-zod2md-nx-plugin
Dec 5, 2025
9068301
refactor: wip
Dec 5, 2025
c0385c4
refactor: wip
Dec 5, 2025
df9cdd2
refactor: wip
Dec 5, 2025
765ff26
refactor: wip
Dec 5, 2025
c332127
refactor: wip
Dec 5, 2025
551b791
refactor: wip
Dec 5, 2025
7f32330
refactor: wip
Dec 5, 2025
3598f8a
refactor: wip
Dec 5, 2025
8d90f87
refactor: wip
Dec 5, 2025
0180436
Update eslint.config.js
BioPhoton Dec 11, 2025
e4a4864
Update tools/zod2md-jsdocs/docs/zod2md-jsdocs-ts-transformer.md
BioPhoton Dec 11, 2025
880e997
refactor: remove disabled rules
Dec 11, 2025
8db0605
refactor: use esm syntax
Dec 11, 2025
0afd552
Merge branch 'refs/heads/main' into chore/add-zod2md-nx-plugin
Dec 15, 2025
c022da1
refactor: add back input rule for zod2md config
Dec 15, 2025
3fc4b33
refactor: fix README.md
Dec 15, 2025
806c743
refactor: remove deps
Dec 15, 2025
c0f0423
refactor: move ts-patch target to zod2md-jsdocs
Dec 15, 2025
df99141
refactor: adjust exports
Dec 15, 2025
a5e0547
refactor: fix plugin in ts format npm issues
Dec 15, 2025
35df593
refactor: fix typing
Dec 15, 2025
b2c3729
refactor: fix docs
Dec 15, 2025
14649d8
refactor: fix docs
Dec 15, 2025
3b16810
Merge branch 'main' into chore/add-zod2md-nx-plugin
Dec 15, 2025
0064e04
refactor: wip
Dec 15, 2025
f918b5c
refactor: wip
Dec 15, 2025
918fa8d
refactor: lock versions
Dec 15, 2025
e5b8c2c
refactor: revert lock versions
Dec 15, 2025
34eed75
refactor: update nx versions
Dec 15, 2025
c9d546d
refactor: update nx versions 2
Dec 15, 2025
3fc54f6
refactor: update nx versions 2
Dec 15, 2025
ff6c610
refactor: fix Nx update
Dec 16, 2025
fa94f93
refactor: fix Nx update unit tests
Dec 16, 2025
e88d62d
refactor: fix Nx update lint
Dec 16, 2025
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
1 change: 1 addition & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@
"releaseTagPattern": "v{version}"
},
"plugins": [
"./tools/zod2md-nx-plugin/src/lib/plugin.js",
{
"plugin": "@push-based/nx-verdaccio",
"options": {
Expand Down
13 changes: 0 additions & 13 deletions packages/models/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@
"sourceRoot": "packages/models/src",
"projectType": "library",
"targets": {
"generate-docs": {
"executor": "nx:run-commands",
"options": {
"commands": [
"zod2md --config {projectRoot}/zod2md.config.ts",
"prettier --write {projectRoot}/docs/models-reference.md"
],
"parallel": false
},
"cache": true,
"inputs": ["production", "^production", "{projectRoot}/zod2md.config.ts"],
"outputs": ["{projectRoot}/docs/models-reference.md"]
},
"build": {
"dependsOn": [
"^build",
Expand Down
120 changes: 120 additions & 0 deletions tools/zod2md-nx-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# @code-pushup/zod2md-nx-plugin

The Nx Plugin for [zod2md](https://github.com/matejchalk/zod2md), a tool for generating documentation from Zod schemas.

Why should you use this plugin?

- Zero setup cost. Just add a `zod2md.config.ts` file and you're good to go.
- Automatic target generation
- Minimal configuration
- Automated caching and dependency tracking

## Usage

```jsonc
// nx.json
{
//...
"plugins": ["./tools/zod2md-nx-plugin/src/lib/plugin.js"],
}
```

or with options:

```jsonc
// nx.json
{
//...
"plugins": [
{
"plugin": "./tools/zod2md-nx-plugin/src/lib/plugin.js",
"options": {
"targetName": "zod-docs",
},
},
],
}
```

Now every project with a `zod2md.config.ts` file will have a `generate-docs` target automatically created.

- `nx run <project-name>:generate-docs`

Run it and the project will automatically generate documentation from your Zod schemas.

```text
Root/
├── project-name/
│ ├── zod2md.config.ts
│ ├── docs/
│ │ └── project-name-reference.md 👈 generated
│ └── ...
└── ...
```

The generated target:

1. Runs `zod2md` with the project's configuration
2. Formats the generated markdown with Prettier
3. Caches the result for better performance

### Passing zod2md options

You can override the config and output paths when running the target:

```bash
# Use custom output file
nx generate-docs my-project --output=docs/custom-api.md

# Use custom config file
nx generate-docs my-project --config=custom-zod2md.config.ts

# Use both
nx generate-docs my-project --config=custom.config.ts --output=docs/api.md
```

Default values:

- `config`: `{projectRoot}/zod2md.config.ts`
- `output`: `{projectRoot}/docs/{projectName}-reference.md`

## Options

| Name | type | description |
| -------------- | ---------------------------------- | ------------------------------------------------------ |
| **targetName** | `string` (DEFAULT 'generate-docs') | The id used to identify a target in your project.json. |

All options are optional and provided in the `nx.json` file.

```jsonc
// nx.json
{
//...
"plugins": [
{
"plugin": "./tools/zod2md-nx-plugin/src/lib/plugin.js",
"options": {
"targetName": "docs",
},
},
],
}
```

## Configuration

Create a `zod2md.config.ts` file in your project:

```ts
import type { Config } from 'zod2md';

export default {
entry: 'packages/models/src/index.ts',
tsconfig: 'packages/models/tsconfig.lib.json',
format: 'esm',
title: 'Models reference',
output: 'packages/models/docs/models-reference.md',
} satisfies Config;
```

For a full list of configuration options visit the [zod2md documentation](https://github.com/matejchalk/zod2md?tab=readme-ov-file#configuration).
12 changes: 12 additions & 0 deletions tools/zod2md-nx-plugin/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import tseslint from 'typescript-eslint';
import baseConfig from '../../eslint.config.js';

export default tseslint.config(...baseConfig, {
files: ['**/*.ts'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
});
10 changes: 10 additions & 0 deletions tools/zod2md-nx-plugin/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "zod2md-nx-plugin",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "tools/zod2md-nx-plugin/src",
"projectType": "library",
"targets": {
"lint": {}
},
"tags": ["scope:shared", "type:util"]
}
53 changes: 53 additions & 0 deletions tools/zod2md-nx-plugin/src/lib/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import path from 'node:path';

export const createNodesV2 = [
`**/zod2md.config.ts`,
async (zod2MdConfigurationFiles, createNodesOptions) => {
const options = createNodesOptions ?? {};
const targetName = options.targetName ?? 'generate-docs';

return Promise.all(
zod2MdConfigurationFiles.map(async zod2MdConfigurationFile => {
const projectRoot = path.dirname(zod2MdConfigurationFile);
const normalizedProjectRoot = projectRoot === '.' ? '' : projectRoot;
const result = {
projects: {
[normalizedProjectRoot]: {
targets: {
[targetName]: {
executor: 'nx:run-commands',
options: {
commands: [
'zod2md --config {args.config} --output {args.output}',
'prettier --write {args.output}',
],
parallel: false,
config: '{projectRoot}/zod2md.config.ts',
output: '{projectRoot}/docs/{projectName}-reference.md',
},
cache: true,
inputs: [
'production',
'^production',
'{projectRoot}/zod2md.config.ts',
],
outputs: ['{projectRoot}/docs/{projectName}-reference.md'],
},
},
},
},
};

return [zod2MdConfigurationFile, result];
}),
);
},
];

// default export for nx.json#plugins
const plugin = {
name: 'zod2md-nx-plugin',
createNodesV2,
};

export default plugin;
Loading