some-jsdoc-parser
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i some-jsdoc-parser

Weekly Downloads

1

Version

0.1.2

License

MIT

Unpacked Size

13.2 kB

Total Files

6

Last publish

Collaborators

  • golopot