extract-comments
Advanced tools
Comparing version 0.7.0 to 0.7.1
{ | ||
"name": "extract-comments", | ||
"description": "Extract code comments from string or from a glob of files.", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"homepage": "https://github.com/jonschlinkert/extract-comments", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -5,2 +5,4 @@ # extract-comments [![NPM version](https://badge.fury.io/js/extract-comments.svg)](http://badge.fury.io/js/extract-comments) | ||
**Heads up!** As of v0.7.0 this no longer has a `.fromFile()` method to read from the file system. See [extracting from files]. | ||
This goes well with [code-context](https://github.com/jonschlinkert/code-context). | ||
@@ -84,3 +86,24 @@ | ||
## Extracting from files | ||
Prior to v0.7.0, there was a method to extract code comments from files. Here is the equivalent code to accomplish the same thing: | ||
```js | ||
var fs = require('fs'); | ||
var extract = require('extract-comments'); | ||
var mapFiles = require('map-files'); | ||
function extractComments(patterns, opts) { | ||
opts = opts || {}; | ||
opts.name = opts.rename || function(fp) { | ||
return fp; | ||
}; | ||
opts.read = opts.read || function(fp, options) { | ||
var code = fs.readFileSync(fp, 'utf8'); | ||
return extract(code, options); | ||
}; | ||
return mapFiles(patterns, opts); | ||
} | ||
``` | ||
## Related | ||
@@ -87,0 +110,0 @@ * [parse-comments](https://github.com/jonschlinkert/parse-comments): Parse code comments from JavaScript or any language that uses the same format. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8426
137