0.0.1 • Published 1 year ago

heading-doc-parser v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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',
    }
  }  
*/
0.0.1

1 year ago