The Nx Plugin for zod2md, a tool for generating documentation from Zod schemas.
Why should you use this plugin?
- Zero setup cost. Just add a
zod2md.config.tsfile and you're good to go. - Automatic target generation
- Minimal configuration
- Automated caching and dependency tracking
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.
Root/
├── project-name/
│ ├── zod2md.config.ts
│ ├── docs/
│ │ └── project-name-reference.md 👈 generated
│ └── ...
└── ...
The generated target:
- Runs
zod2mdwith the project's configuration - Formats the generated markdown with Prettier
- Caches the result for better performance
You can override the config and output paths when running the target:
# 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.mdDefault values:
config:{projectRoot}/zod2md.config.tsoutput:{projectRoot}/docs/{projectName}-reference.md
Create a zod2md.config.ts file in your project:
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.