A hand-written jsdoc parser.
- AST format similar to estree.
- Nodes locations included.
- Typed with typescript.
npm install --save some-jsdoc-parser
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 ]
// }