Skip to content

Latest commit

 

History

History
80 lines (57 loc) · 2.02 KB

File metadata and controls

80 lines (57 loc) · 2.02 KB

@code-pushup/zod2md-jsdocs-nx-plugin

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.ts file and you're good to go.
  • Automatic target generation
  • Minimal configuration
  • Automated caching and dependency tracking

Usage

// nx.json
{
  //...
  "plugins": ["./tools/zod2md-jsdocs-nx-plugin/src/lib/plugin.ts"],
}

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:

  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:

# 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

Configuration

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.