Base (github @node-base) application plugin for extracting code comments using `acorn-extract-comments`.
npm install base-extract-comments> Base (github @node-base) application plugin for extracting code comments using acorn-extract-comments.
[![code climate][codeclimate-img]][codeclimate-url] [![standard code style][standard-img]][standard-url] [![travis build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![dependency status][david-img]][david-url]
npm i base-extract-comments --save
`Usage
> For more use-cases see the tests`js
const baseExtractComments = require('base-extract-comments')
`$3
> Plugin that adds .extractComments method to your [base][] application, that extracts JSDoc-style code comments using [acorn-extract-comments][] lib.Params
*
opts {Object}: merged with app.options and passed to [acorn-extract-comments][]
* returns {Function}: the actual plugin Example
`js
var extract = require('base-extract-comments')
var Base = require('base')
var app = new Base({ isApp: true })app.use(extract({ foo: 'option' }))
console.log(app.extractComments) // => [Function: extractComments]
`$3
> Extract code comments from input string and returns an array of comment objects or pass it to done callback. Notice that .extractComments have sync and async mode, so if you do not pass done callback it will throw or return an Array. You also can pass input to the constructor of your app to the this.cache object such as { cache: { input: 'some str' } }Params
*
input {String|Object|Function}: input string, options or done callback
* options {Object|Function}: merged with app.options and passed to [acorn-extract-comments][] or done callback
* done {Function}: callback function (optional)
* returns {Array}: an Array of comment objects or done(null, comments) Example
`js
// sync modeapp.use(extract())
var comments = app.extractComments('some string')
// => array of comment objects
// or
var app = new Base({ cache: { input: 'foo bar baz' } })
app.use(extract())
var comments = app.extractComments()
// => array of comment objects
// or in async mode
app.use(extract())
app.extractComments('foo bar', function done (err, comments) {
// =>
comments is array of comment objects
})
`Related
- acorn-extract-comments: Extract JavaScript code comments from a string, using acorn. Optionally returns the… more | acorn. Optionally returns the AST and first line of code after comment - useful for parsing code context and api docs."" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">homepage
- base-data: adds a data method to base-methods. | data method to base-methods."" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">homepage
- base-plugins-enhanced: Error handling and extras for .use and .run methods of your Base… more | .use and .run methods of your Base apps. Modifies .use method to be able to 1" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">homepage accept array of functions, 2) options object as second argument. Emits error event if some plugin fails.")
- base-plugins: Upgrade's plugin support in base applications to allow plugins to be called… more | homepage
- base: base is the foundation for creating modular, unit testable and highly pluggable… more | set, get, del and use`."" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">homepage
- extract-comments: Uses esprima to extract line and block comments from a string of… more | homepage.")
- postcore: Processor engine for Post family like PostCSS, PostHTML and PostJSON. | family like PostCSS, PostHTML and PostJSON."" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">homepage
- use-ware: Adds sync plugin support to your application. Kinda fork of use… [more | homepage
- use: Easily add plugin support to your node.js application. | homepageContributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.Charlike Make Reagent [![new message to charlike][new-message-img]][new-message-url] [![freenode #charlike][freenode-img]][freenode-url]
[![tunnckoCore.tk][author-www-img]][author-www-url] [![keybase tunnckoCore][keybase-img]][keybase-url] [![tunnckoCore npm][author-npm-img]][author-npm-url] [![tunnckoCore twitter][author-twitter-img]][author-twitter-url] [![tunnckoCore github][author-github-img]][author-github-url]
[acorn-extract-comments]: https://github.com/tunnckocore/acorn-extract-comments
[base]: https://github.com/node-base/base
[use]: https://github.com/jonschlinkert/use
[ware]: https://github.com/segmentio/ware
[npmjs-url]: https://www.npmjs.com/package/base-extract-comments
[npmjs-img]: https://img.shields.io/npm/v/base-extract-comments.svg?label=base-extract-comments
[license-url]: https://github.com/tunnckoCore/base-extract-comments/blob/master/LICENSE
[license-img]: https://img.shields.io/npm/l/base-extract-comments.svg
[downloads-url]: https://www.npmjs.com/package/base-extract-comments
[downloads-img]: https://img.shields.io/npm/dm/base-extract-comments.svg
[codeclimate-url]: https://codeclimate.com/github/tunnckoCore/base-extract-comments
[codeclimate-img]: https://img.shields.io/codeclimate/github/tunnckoCore/base-extract-comments.svg
[travis-url]: https://travis-ci.org/tunnckoCore/base-extract-comments
[travis-img]: https://img.shields.io/travis/tunnckoCore/base-extract-comments/master.svg
[coveralls-url]: https://coveralls.io/r/tunnckoCore/base-extract-comments
[coveralls-img]: https://img.shields.io/coveralls/tunnckoCore/base-extract-comments.svg
[david-url]: https://david-dm.org/tunnckoCore/base-extract-comments
[david-img]: https://img.shields.io/david/tunnckoCore/base-extract-comments.svg
[standard-url]: https://github.com/feross/standard
[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[author-www-url]: http://www.tunnckocore.tk
[author-www-img]: https://img.shields.io/badge/www-tunnckocore.tk-fe7d37.svg
[keybase-url]: https://keybase.io/tunnckocore
[keybase-img]: https://img.shields.io/badge/keybase-tunnckocore-8a7967.svg
[author-npm-url]: https://www.npmjs.com/~tunnckocore
[author-npm-img]: https://img.shields.io/badge/npm-~tunnckocore-cb3837.svg
[author-twitter-url]: https://twitter.com/tunnckoCore
[author-twitter-img]: https://img.shields.io/badge/twitter-@tunnckoCore-55acee.svg
[author-github-url]: https://github.com/tunnckoCore
[author-github-img]: https://img.shields.io/badge/github-@tunnckoCore-4183c4.svg
[freenode-url]: http://webchat.freenode.net/?channels=charlike
[freenode-img]: https://img.shields.io/badge/freenode-%23charlike-5654a4.svg
[new-message-url]: https://github.com/tunnckoCore/ama
[new-message-img]: https://img.shields.io/badge/ask%20me-anything-green.svg