{"_id":"@apaleslimghost/zod2md","name":"@apaleslimghost/zod2md","dist-tags":{"next":"0.2.0-0","latest":"0.2.0-0"},"versions":{"0.2.0-0":{"name":"@apaleslimghost/zod2md","version":"0.2.0-0","description":"Generate Markdown docs from Zod schemas","license":"MIT","author":{"name":"Matěj Chalk","email":"matejchalk@gmail.com"},"keywords":["markdown","zod","cli"],"repository":{"type":"git","url":"git+ssh://git@github.com/matejchalk/zod2md.git"},"homepage":"https://github.com/matejchalk/zod2md#readme","bugs":{"url":"https://github.com/matejchalk/zod2md/issues"},"type":"module","bin":{"zod2md":"dist/bin.js"},"types":"dist/index.d.ts","main":"dist/index.cjs","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"prepublishOnly":"npm run build","build":"tsup","test":"vitest run","test:watch":"vitest watch","test:update":"vitest run -u","e2e":"vitest run --config e2e/vitest.config.ts","e2e:update":"vitest run --config e2e/vitest.config.ts -u","verdaccio:serve":"verdaccio --config .verdaccio/config.yml","verdaccio:publish":"npm unpublish --registry http://localhost:4873 --force && npm publish --registry http://localhost:4873 --force","release":"release-it","release:dry-run":"release-it --dry-run"},"dependencies":{"@commander-js/extra-typings":"^12.0.0","bundle-require":"^4.0.2","commander":"^12.0.0","esbuild":"^0.19.11"},"peerDependencies":{"zod":"^3.22.0"},"devDependencies":{"@types/node":"^20.11.0","npm-cli-login":"^1.0.0","release-it":"^17.0.3","tsup":"^8.0.1","typescript":"^5.3.3","verdaccio":"^5.29.0","vitest":"^1.2.2","zod":"^3.22.4"},"publishConfig":{"access":"public"},"gitHead":"29bed0a8b58d8f35cec3b8988692a26ac05263fb","_id":"@apaleslimghost/zod2md@0.2.0-0","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-+RIBBMQzMwW4mY8SSYcVjTXKxWqWKTX8jKQnRLBCxDa4oon2nMWYbUczBZvmof8TYgybnDstspTv6XwkkRv4qQ==","shasum":"1b54b041b8aba01f8c7e0e3d8614fd42e95794d4","tarball":"https://registry.npmjs.org/@apaleslimghost/zod2md/-/zod2md-0.2.0-0.tgz","fileCount":11,"unpackedSize":159648,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB7whpouVk3UJkkzTKkDtvlKhnuT6ErSFVFlwYchZUq5AiEA1QBHZkF61oDuEroU8lQ1OHbqFBwdb1XITkkZopmMOtc="}]},"_npmUser":{"name":"quarterto","email":"kara@153.io"},"directories":{},"maintainers":[{"name":"quarterto","email":"kara@153.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zod2md_0.2.0-0_1713872145409_0.26291163920032035"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-23T11:35:45.304Z","0.2.0-0":"2024-04-23T11:35:45.570Z","modified":"2024-04-23T11:35:45.892Z"},"maintainers":[{"name":"quarterto","email":"kara@153.io"}],"description":"Generate Markdown docs from Zod schemas","homepage":"https://github.com/matejchalk/zod2md#readme","keywords":["markdown","zod","cli"],"repository":{"type":"git","url":"git+ssh://git@github.com/matejchalk/zod2md.git"},"author":{"name":"Matěj Chalk","email":"matejchalk@gmail.com"},"bugs":{"url":"https://github.com/matejchalk/zod2md/issues"},"license":"MIT","readme":"# zod2md\n\n[![NPM package version](https://img.shields.io/npm/v/zod2md)](https://www.npmjs.com/package/zod2md)\n[![MIT license](https://img.shields.io/npm/l/zod2md)](https://opensource.org/license/mit/)\n[![Zod peer dependency version](https://img.shields.io/npm/dependency-version/zod2md/peer/zod)](https://www.npmjs.com/package/zod)\n[![CI status](https://img.shields.io/github/actions/workflow/status/matejchalk/zod2md/ci.yml)](https://github.com/matejchalk/zod2md/actions/workflows/ci.yml)\n\n**Generate Markdown docs from [Zod](https://zod.dev/) schemas.**\n\n![image](./images/zod2md.png)\n\n## Setup\n\nInstall the `zod2md` package (optional):\n\n```sh\nnpm install --save-dev zod2md\n```\n\nRun the CLI. The following arguments are required:\n\n- `entry` - path to file which exports Zod schemas,\n- `title` - heading text for Markdown document,\n- `output` - path where output Markdown file will be generated.\n\n```sh\nnpx zod2md --entry src/schemas.ts --title \"Models reference\" --output docs/models.md\n```\n\n## Configuration\n\nAlthough most arguments may be provided directly to the CLI, it may be more convenient to use a configuration file.\n\nFor example, create the following `zod2md.config.ts` and then you can simply run `npx zod2md`:\n\n```ts\nimport type { Config } from 'zod2md';\n\nconst config: Config = {\n  entry: 'src/schemas.ts',\n  title: 'Models reference',\n  output: 'docs/models.md',\n};\n\nexport default config;\n```\n\nCLI arguments take precedence over configuration file values.\n\n### CLI arguments\n\n| Option           | Type             | Required | Description                                                         |\n| :--------------- | :--------------- | :------: | :------------------------------------------------------------------ |\n| `-e`, `--entry`  | `string[]` (\\*)  |   yes    | Entry point(s), i.e. paths to modules with Zod schema exports       |\n| `-t`, `--title`  | `string`         |   yes    | Heading text for Markdown document                                  |\n| `-o`, `--output` | `string`         |   yes    | Output file path where Markdown document will be generared          |\n| `--tsconfig`     | `string`         |    no    | Path to `tsconfig.json` to be used when importing entry point(s)    |\n| `-f`, `--format` | `'esm' \\| 'cjs'` |    no    | Module type to assume when importing entry point(s)                 |\n| `-c`, `--config` | `string`         |    no    | Path to configuration file (default is `zod2md.config.{ts,mjs,js}`) |\n| `-h`, `--help`   | `boolean`        |    no    | Display CLI help and exit                                           |\n\n(\\*) Use `--entry PATH_1 --entry PATH_2` to provide multiple paths.\n\n### Configuration file reference\n\n| Property        | Type                                                  | Required | Description                                                                                |\n| :-------------- | :---------------------------------------------------- | :------: | :----------------------------------------------------------------------------------------- |\n| `entry`         | `string \\| string[]`                                  |   yes    | Entry point(s), i.e. paths to modules with Zod schema exports                              |\n| `tsconfig`      | `string`                                              |    no    | Path to `tsconfig.json` to be used when importing entry point(s)                           |\n| `format`        | `'esm' \\| 'cjs'`                                      |    no    | Module type to assume when importing entry point(s)                                        |\n| `title`         | `string`                                              |   yes    | Heading text for Markdown document                                                         |\n| `transformName` | `(name: string \\| undefined, path: string) => string` |    no    | Custom function for convert exported variable `name` and file `path` to display title (\\*) |\n\n(\\*) Default is to strip `Schema`-suffix and convert to _PascalCase_ (e.g. `userSchema` becomes `User`). In case of a default export, the file path is used.\n\n## Programmatic usage\n\nIt's also possible to import the core `zod2md` function to generate the Markdown string in your own code:\n\n```ts\nimport { zod2md } from 'zod2md';\n\nconst markdown = await zod2md({\n  entry: 'src/schemas.ts',\n  title: 'Models reference',\n});\n```\n\n## Examples\n\nA few examples of inputs and outputs are provided (used in E2E tests):\n\n| Example                                                | Source files                                                | Generated docs                                                                                 |\n| :----------------------------------------------------- | :---------------------------------------------------------- | :--------------------------------------------------------------------------------------------- |\n| [Prettier](https://prettier.io/) config file           | [e2e/fixtures/prettier](./e2e/fixtures/prettier/)           | [e2e/\\_\\_snapshots\\_\\_/prettier-example.md](./e2e/__snapshots__/prettier-example.md)           |\n| [Commitlint](https://commitlint.js.org/) config object | [e2e/fixtures/commitlint](./e2e/fixtures/commitlint/)       | [e2e/\\_\\_snapshots\\_\\_/commitlint-example.md](./e2e/__snapshots__/commitlint-example.md)       |\n| User REST API                                          | [e2e/fixtures/user-rest-api](./e2e/fixtures/user-rest-api/) | [e2e/\\_\\_snapshots\\_\\_/user-rest-api-example.md](./e2e/__snapshots__/user-rest-api-example.md) |\n\n## Contributing\n\n- Install dependencies with `npm install`.\n- Run unit tests with `npm test` (uses [Vitest](https://vitest.dev/)).\n- Run E2E tests with `npm run e2e` (uses [Vitest](https://vitest.dev/) and [Verdaccio](https://verdaccio.org/)).\n- Build library with `npm run build` (uses [tsup](https://tsup.egoist.dev/)).\n- Release new version with `npm run release` (uses [release-it](https://github.com/release-it/release-it?tab=readme-ov-file)).\n","readmeFilename":"README.md"}