comments-extractor
v1.0.10
Published
Extract comments from glob of files, annotated or not
Downloads
43
Maintainers
Readme
comments-extractor
Extract comments from glob of files, annotated or not.
Quick Start
Install
npm install comments-extractorUse
const CommentsExtractor = require('comments-extractor');
const extractor = new CommentsExtractor('./**/*.js', 'todo');
const todos = extractor.extract();
console.log(todos);
// Output:
// Map {
// './example-block.js' => [ { type: 'Block', value: '*\n * @TODO: Write this block.\n ' } ],
// './example-line.js' => [ { type: 'Line', value: ' @TODO: Write this line.' } ]
// }API
CommentsExtractor
Comments Extractor class.
Kind: global class
new CommentsExtractor(pattern, [annotation], [options], [esprimaClass], [fsClass], [globClass])
Comments Extractor constructor.
| Parameter | Type | Default | Description |
| -------------- | -------- | --------- | ------------ |
| pattern | string | | Glob pattern |
| [annotation] | string | '' | Annotation |
| [options] | Object | {} | Glob options |
| [esprimaClass] | * | esprima | |
| [fsClass] | * | fs | |
| [globClass] | * | glob | |
extract() ⇒ Map.<string, Array>
Extract comments.
Kind: instance method of CommentsExtractor
Returns: Map.<string, Array>, where key is a filepath and value is an array of comments
