@ts-ast-parser/comment
v0.2.0
Published
Parses documentation comments
Downloads
22
Maintainers
Readme
@ts-ast-parser/comment
General purpose parser for documentation comments that tries to follow as much as possible the JSDoc 3 spec and the TSDoc spec.
Install
npm i @ts-ast-parser/comment
Usage
import { parse } from '@ts-ast-parser/comment';
const comment = `/** This is a simple description */`;
const parserResult = parse(comment);
if (parserResult.error) {
// Handle the errors accordingly
process.exit(1);
}
// This is an array of `CommentPart`
const parts = parserResult.parts;
// This would log "This is a simple description"
console.log(parts.find(p => p.kind === 'description')?.text ?? '');