Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

3 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # babel-extract-comments [![NPM version](https://img.shields.io/npm/v/babel-extract-comments.svg?style=flat)](https://www.npmjs.com/package/babel-extract-comments) [![NPM monthly downloads](https://img.shields.io/npm/dm/babel-extract-comments.svg?style=flat)](https://npmjs.org/package/babel-extract-comments) [![NPM total downloads](https://img.shields.io/npm/dt/babel-extract-comments.svg?style=flat)](https://npmjs.org/package/babel-extract-comments) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/babel-extract-comments.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/babel-extract-comments)
  2. > Uses babel (babylon) to extract JavaScript code comments from a JavaScript string or file.
  3. Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
  4. ## Install
  5. Install with [npm](https://www.npmjs.com/):
  6. ```sh
  7. $ npm install --save babel-extract-comments
  8. ```
  9. ## Usage
  10. Add to your Node.js/JavaScript project with the following line of code:
  11. ```js
  12. const extract = require('babel-extract-comments');
  13. ```
  14. ## API
  15. ### [extract](index.js#L32)
  16. Extract code comments from the given `string`.
  17. **Params**
  18. * `string` **{String}**: String of javascript
  19. * `returns` **{Array}**: Array of code comment objects.
  20. **Example**
  21. ```js
  22. var extract = require('babel-extract-comments');
  23. console.log(extract('// this is a code comment'));
  24. // [{ type: 'CommentBlock',
  25. // value: '!\n * babel-extract-comments <https://github.com/jonschlinkert/babel-extract-comments>\n *\n *
  26. // Copyright (c) 2014-2018, Jon Schlinkert.\n * Released under the MIT License.\n ',
  27. // start: 0,
  28. // end: 173,
  29. // loc: SourceLocation { start: [Position], end: [Position] } }]
  30. ```
  31. ### [.file](index.js#L53)
  32. Extract code comments from a JavaScript file.
  33. **Params**
  34. * `file` **{String}**: Filepath to the file to parse.
  35. * `options` **{Object}**: Options to pass to [esprima](http://esprima.org).
  36. * `returns` **{Array}**: Array of code comment objects.
  37. **Example**
  38. ```js
  39. console.log(extract.file('some-file.js'), { cwd: 'some/path' });
  40. // [ { type: 'Line',
  41. // value: ' this is a line comment',
  42. // range: [ 0, 25 ],
  43. // loc: { start: { line: 1, column: 0 }, end: { line: 1, column: 25 } } } ]
  44. ```
  45. ## About
  46. <details>
  47. <summary><strong>Contributing</strong></summary>
  48. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  49. </details>
  50. <details>
  51. <summary><strong>Running Tests</strong></summary>
  52. Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
  53. ```sh
  54. $ npm install && npm test
  55. ```
  56. </details>
  57. <details>
  58. <summary><strong>Building docs</strong></summary>
  59. _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
  60. To generate the readme, run the following command:
  61. ```sh
  62. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  63. ```
  64. </details>
  65. ### Related projects
  66. You might also be interested in these projects:
  67. * [esprima-extract-comments](https://www.npmjs.com/package/esprima-extract-comments): Extract code comments from string or from a glob of files using esprima. | [homepage](https://github.com/jonschlinkert/esprima-extract-comments "Extract code comments from string or from a glob of files using esprima.")
  68. * [extract-comments](https://www.npmjs.com/package/extract-comments): Uses esprima to extract line and block comments from a string of JavaScript. Also optionally… [more](https://github.com/jonschlinkert/extract-comments) | [homepage](https://github.com/jonschlinkert/extract-comments "Uses esprima to extract line and block comments from a string of JavaScript. Also optionally parses code context (the next line of code after a comment).")
  69. * [js-comments](https://www.npmjs.com/package/js-comments): Parse JavaScript code comments and generate API documentation. | [homepage](https://github.com/jonschlinkert/js-comments "Parse JavaScript code comments and generate API documentation.")
  70. * [parse-comments](https://www.npmjs.com/package/parse-comments): Parse code comments from JavaScript or any language that uses the same format. | [homepage](https://github.com/jonschlinkert/parse-comments "Parse code comments from JavaScript or any language that uses the same format.")
  71. ### Contributors
  72. | **Commits** | **Contributor** |
  73. | --- | --- |
  74. | 4 | [jonschlinkert](https://github.com/jonschlinkert) |
  75. | 1 | [eventualbuddha](https://github.com/eventualbuddha) |
  76. ### Author
  77. **Jon Schlinkert**
  78. * [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert)
  79. * [github/jonschlinkert](https://github.com/jonschlinkert)
  80. * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
  81. ### License
  82. Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
  83. Released under the [MIT License](LICENSE).
  84. ***
  85. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on February 12, 2018._