heading-doc-parser
v0.0.1
Published
Simple doc parser for heading comment.
Downloads
8
Maintainers
Readme
heading-doc-parser
A simple parser for doc generation.
feature
- Lightweight - less than 2kb before gzip
- Type Support - friendly with typescript
Install
npm install heading-doc-parser
Usage
simple usage
import parseDoc from 'heading-doc-parser'
const code = `
/**
* description
* @title - 1
* @desc
* hello
* world
*/
export function Demo() {
return <button>demo</button>
}
`
console.log(parseDoc(code))
/*
{
description: "description",
data: {
title: '1',
desc: 'hello\nworld',
}
}
*/
Type Support
import parseDoc from 'heading-doc-parser'
const code = `
/**
* description
* @title - 1
* @desc
* hello
* world
*/
export function Demo() {
return <button>demo</button>
}
`
type Key = 'title' | 'desc'
console.log(parseDoc<Key>(code))
/*
{
description: "description",
data: {
title: '1',
desc: 'hello\nworld',
}
}
*/