Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Latest commit

 

History

History

comment

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@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 ?? '');