0.1.2 • Published 3 years ago

some-jsdoc-parser v0.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

npm build status codecov.io

some-jsdoc-parser

A hand-written jsdoc parser.

  • AST format similar to estree.
  • Nodes locations included.
  • Typed with typescript.

Install

npm install --save some-jsdoc-parser

Usage

const SomeJsdocParser = require('some-jsdoc-parser');

const ast = SomeJsdocParser.parse(`
/**
 * @param {string} foo - some parameter.
 * @returns {string} 
 */
`);

console.log(ast);

// {
//   type: 'JSDocComment',
//   description: null,
//   blocks: [
//     {
//       type: 'JSDocBlock',
//       tag: { type: 'JSDocTag', name: 'param', range: [ 8, 14 ] },
//       typeAnnotation: {
//         type: 'JSDocTypeAnnotation',
//         value: 'string',
//         range: [ 15, 23 ]
//       },
//       name: {
//         type: 'JSDocName',
//         name: 'foo',
//         optional: false,
//         range: [ 24, 27 ]
//       },
//       description: {
//         type: 'JSDocDescription',
//         value: '- some parameter.',
//         range: [ 28, 45 ]
//       },
//       range: [ 8, 45 ]
//     },
//     {
//       type: 'JSDocBlock',
//       tag: { type: 'JSDocTag', name: 'returns', range: [ 49, 57 ] },
//       typeAnnotation: {
//         type: 'JSDocTypeAnnotation',
//         value: 'string',
//         range: [ 58, 66 ]
//       },
//       name: null,
//       description: null,
//       range: [ 49, 66 ]
//     }
//   ],
//   range: [ 0, 71 ]
// }

License

MIT License

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago