Package: @tooling/zod2md-jsdocs
Plugin name: zod2md-jsdocs-nx-plugin
This Nx plugin automatically wires Zod → Markdown documentation generation
into your workspace by detecting zod2md.config.js files and configuring
projects accordingly.
Whenever a zod2md.config.js file is found, it:
- Registers a documentation generation target
- Ensures documentation is generated before build
- Adds a TypeScript patching target
- Registers a sync generator to keep the setup consistent
All of this happens automatically — no manual project.json editing required.
The plugin scans your workspace for:
**/zod2md.config.tsFor every match, it infers a project and adds the following targets.
Generates Markdown documentation from Zod schemas.
- Runs
zod2md - Formats output with
prettier - Fully cacheable
- Produces deterministic outputs
generate-docs: {
executor: 'nx:run-commands',
options: {
commands: [
'zod2md --config {projectRoot}/zod2md.config.ts --output {projectRoot}/docs/{projectName}-reference.md',
'prettier --write {projectRoot}/docs/{projectName}-reference.md'
],
parallel: false
},
cache: true,
inputs: ['production', '^production', '{projectRoot}/zod2md.config.ts'],
outputs: ['{projectRoot}/docs/{projectName}-reference.md']
}Ensures the TypeScript compiler is patched correctly.
- Runs
ts-patch install - Cached
- Uses a runtime check to avoid unnecessary work
patch-ts: {
command: 'ts-patch install',
cache: true,
inputs: [
'sharedGlobals',
{ runtime: 'ts-patch check' }
]
}The plugin automatically updates the build target so that:
- Documentation is generated before building
- The sync generator is registered
build: {
dependsOn: [
{ target: 'generate-docs', projects: 'self' }
],
syncGenerators: [
'./tools/zod2md-jsdocs/dist:sync-zod2md-setup'
]
}Each inferred project is automatically wired to use the
sync-zod2md-setup sync generator.
This ensures:
- TypeScript plugin configuration stays correct
- Required targets remain present
build.dependsOnstays consistent- The setup is safe to re-run and self-healing
libs/my-lib/
├── zod2md.config.ts 👈 detected by the plugin
├── project.json 👈 targets injected automatically
├── tsconfig.lib.json 👈 patched by the sync generator
├── docs/
│ └── my-lib-reference.md 👈 generated output
└── src/
└── index.tsSimply add a zod2md.config.ts file — the plugin handles the rest.