npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jackdbd/zod-to-doc

v1.1.2

Published

Inject your [Zod](https://github.com/colinhacks/zod) schemas into your docs.

Downloads

174

Readme

Zod to Doc

npm package badge install size CI CodeCov badge CodeFactor badge Socket Badge Conventional Commits

Inject your Zod schemas into your docs.

About

I was looking for a way to keep my documentation updated with my Zod schemas. To my surprise, I couldn't find any tool that would output a string representation of a Zod schema. So I decided to write my own. You can use this tool either as a library or as a CLI.

Installation

npm install --save-dev @jackdbd/zod-to-doc

Docs

Docs generated by TypeDoc

📖 API Docs

This project uses API Extractor and api-documenter markdown to generate a bunch of markdown files and a .d.ts rollup file containing all type definitions consolidated into a single file. I don't find this .d.ts rollup file particularly useful. On the other hand, the markdown files that api-documenter generates are quite handy when reviewing the public API of this project.

See Generating API docs if you want to know more.

Examples

Here are some tables generated using a couple of Zod schemas exported by fixtures/schemas.mjs.

Usage as a CLI

Zod to Doc can be used as a CLI. For example, if you run this command and have the correct placeholder in your document (see this README.md in raw mode):

ztd --module ./fixtures/schemas.mjs \
  --schema car \
  --placeholder car-table \
  --title '#### Car table'

You get this output:

Car table

| Key | Default | Description | |---|---|---| | manufacturer | undefined | Car manufacturer | | model | undefined | Car model | | tires | undefined | Array of 4 elements | | year | undefined | Year in which the car was manufactured |

Usage as a library

Zod to Doc can also be used as a library. For example, the readme.ts file in this repository uses markdownTableFromZodSchema to replace a mustache-style placeholder with this markdown table:

Car tire table

| Key | Default | Description | |---|---|---| | manufacturer | undefined | Car tire manufacturer | | pressure | 30 | Car tire pressure in PSI |

Troubleshooting

This package uses the debug library for logging. You can control what's logged using the DEBUG environment variable.

For example, if you set your environment variables in a .envrc file, you can do:

# print all logging statements
export DEBUG=ztd:*

Dependencies

| Package | Version | |---|---| | ansi-colors | ^4.1.3 | | debug | ^4.3.4 | | yargs | ^17.7.2 | | zod | ^3.23.4 |

License

© 2024 Giacomo Debidda // MIT License