Documentation generator for TypeScript Declaration Files inspired by godoc.
Documentation generator for TypeScript Declaration Files inspired by godoc.
This repo contains two packages:
Hat tip to Guido D’Orsi for the name idea (vitepress, typejuice).
npm i typejuice --save
TypeScript Declaration Files have become a common addition to libraries, even those written in standard JavaScript, as a means of enhancing autocomplete behaviour of the exposed APIs.
There’s a lot of overlap between documentation and these declaration files. This project attempts to bridge the gap by providing godoc-like comment extraction from .d.ts files while also inferring on types and signatures so you don’t have to maintain the same information in two different places. It’s a radically stripped down, minimalist analogue to typedoc.
undefinedInstead of using tags like @param, just have one function parameter per lineundefined
|
TypeScript Declaration File
|
|
Generated Markdown
|
undefinedMulti-line comments on interface propsundefined
|
TypeScript Declaration File
|
|
Generated Markdown
|
string, number, booleannull and undefinedtype[], Array<type>)import TypeJuice from 'typejuice'
const tj = new TypeJuice('./sample.d.ts')
console.log(tj.toMarkdown())
In vite.config.js:
import { dirname } from 'path'
import { fileURLToPath } from 'url'
import TypeJuice from 'vite-plugin-typejuice'
export default {
plugins: [
TypeJuice({
// Defaults to process.cwd()
typeRoot: resolve(dirname(fileURLToPath(import.meta.url)), 'types'),
// Defaults to only 'md'
extensions: ['md'],
})
],
}
In your Markdown files:
<<< typejuice:client.d.ts
This will insert the autogenerated markdown for client.d.ts under typeRoot.
Sponsored by NearForm.
MIT
We use cookies
We use cookies to analyze traffic and improve your experience. You can accept or reject analytics cookies.