comment-parser 0.3.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ node_modules/*
package/.eslintrc ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "standard",
3
+ "env": {
4
+ "browser": true,
5
+ "node": true,
6
+ "mocha": true
7
+ },
8
+ "rules": {
9
+ "camelcase": "off"
10
+ }
11
+ }
package/.travis.yml CHANGED
@@ -1,8 +1,6 @@
1
1
  language: node_js
2
2
  node_js:
3
+ - "8.5"
4
+ - "6.11"
3
5
  - "4.1"
4
6
  - "4.0"
5
- - "0.12"
6
- - "0.11"
7
- - "0.10"
8
- - "iojs"
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # v0.5.0
2
+ - line wrapping control with `opts.join`
3
+
4
+ # v0.4.2
5
+ - tolerate inconsistent lines alignment within block
6
+
7
+ # v0.4.1
8
+ - refactored parsing, allow to not start lines with "* " inside block
9
+
1
10
  # v0.3.2
2
11
  - fix RegExp for `description` extraction to allow $ char
3
12
 
package/README.md CHANGED
@@ -66,7 +66,29 @@ this would be parsed into following
66
66
 
67
67
  By default dotted names like `name.subname.subsubname` will be expanded into nested sections, this can be prevented by passing `opts.dotted_names = false`.
68
68
 
69
- Invalid comment blocks are skipped. Comments starting with `/*` and `/***` are considered not valid.
69
+ Below are examples of acceptable comment formats
70
+
71
+ ```
72
+ /** online comment */
73
+
74
+ /** first line
75
+ * second line */
76
+
77
+ /**
78
+ No *s on middle lines is acceptable too
79
+ which might be convenient for writing big
80
+ chunks of text.
81
+
82
+ * keeping *s on some lines
83
+ * would work either
84
+
85
+ left bound is dermined by opening marker position
86
+ and white space will be trimmed as there was '* '
87
+ */
88
+
89
+ ```
90
+
91
+ Comments starting with `/***` and `/*` are ignored.
70
92
 
71
93
  Also you can parse entire file with `parse.file('path/to/file', callback)` or acquire an instance of [Transform](http://nodejs.org/api/stream.html#stream_class_stream_transform) stream with `parse.stream()`.
72
94
 
@@ -134,11 +156,8 @@ This would produce following:
134
156
 
135
157
  ## Contributors
136
158
 
137
-
138
159
  - [Alexej Yaroshevich](https://github.com/zxqfox)
139
160
  - [Evgeny Reznichenko](https://github.com/zxcabs)
140
161
  - [Jordan Harband](https://github.com/ljharb)
141
162
  - [Sergii Iavorskyi](https://github.com/yavorskiy)
142
-
143
-
144
- Happy coding :)
163
+ - [tengattack](https://github.com/tengattack)
package/index.js CHANGED
@@ -1,64 +1,61 @@
1
1
 
2
- 'use strict';
2
+ 'use strict'
3
3
 
4
- var fs = require('fs');
5
- var stream = require('readable-stream');
6
- var util = require('util');
4
+ var fs = require('fs')
5
+ var stream = require('readable-stream')
6
+ var util = require('util')
7
7
 
8
- var parse = require('./parser.js');
8
+ var parse = require('./parser')
9
9
 
10
- module.exports = parse;
10
+ module.exports = parse
11
11
 
12
12
  /* ------- Transform stream ------- */
13
13
 
14
- function Parser(opts) {
15
- opts = opts || {};
16
- stream.Transform.call(this, {objectMode: true});
17
- this._extract = parse.mkextract(opts);
14
+ function Parser (opts) {
15
+ opts = opts || {}
16
+ stream.Transform.call(this, {objectMode: true})
17
+ this._extract = parse.mkextract(opts)
18
18
  }
19
19
 
20
- util.inherits(Parser, stream.Transform);
20
+ util.inherits(Parser, stream.Transform)
21
21
 
22
- Parser.prototype._transform = function transform(data, encoding, done) {
23
-
24
- var block;
25
- var lines = data.toString().split(/\n/);
22
+ Parser.prototype._transform = function transform (data, encoding, done) {
23
+ var block
24
+ var lines = data.toString().split(/\n/)
26
25
 
27
26
  while (lines.length) {
28
- block = this._extract(lines.shift());
27
+ block = this._extract(lines.shift())
29
28
  if (block) {
30
- this.push(block);
29
+ this.push(block)
31
30
  }
32
31
  }
33
32
 
34
- done();
35
- };
33
+ done()
34
+ }
36
35
 
37
- module.exports.stream = function stream(opts) {
38
- return new Parser(opts);
39
- };
36
+ module.exports.stream = function stream (opts) {
37
+ return new Parser(opts)
38
+ }
40
39
 
41
40
  /* ------- File parser ------- */
42
41
 
43
- module.exports.file = function file(file_path, done) {
44
-
45
- var opts = {};
46
- var collected = [];
42
+ module.exports.file = function file (file_path, done) {
43
+ var opts = {}
44
+ var collected = []
47
45
 
48
46
  if (arguments.length === 3) {
49
- opts = done;
50
- done = arguments[2];
47
+ opts = done
48
+ done = arguments[2]
51
49
  }
52
50
 
53
51
  return fs.createReadStream(file_path, {encoding: 'utf8'})
54
52
  .on('error', done)
55
53
  .pipe(new Parser(opts))
56
54
  .on('error', done)
57
- .on('data', function(data) {
58
- collected.push(data);
55
+ .on('data', function (data) {
56
+ collected.push(data)
59
57
  })
60
58
  .on('finish', function () {
61
- done(null, collected);
62
- });
63
- };
64
-
59
+ done(null, collected)
60
+ })
61
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comment-parser",
3
- "version": "0.3.2",
3
+ "version": "0.5.0",
4
4
  "description": "Generic JSDoc-like comment parser. ",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -11,14 +11,19 @@
11
11
  },
12
12
  "devDependencies": {
13
13
  "chai": "~1.9.0",
14
- "jshint": "^2.5.10",
15
- "jshint-stylish": "^1.0.0",
16
- "mocha": "~1.17.1",
14
+ "eslint": "^4.7.1",
15
+ "eslint-config-standard": "^10.2.1",
16
+ "eslint-plugin-import": "^2.7.0",
17
+ "eslint-plugin-node": "^5.1.1",
18
+ "eslint-plugin-promise": "^3.5.0",
19
+ "eslint-plugin-standard": "^3.0.1",
20
+ "mocha": "^3.5.3",
17
21
  "nodemon": "^1.2.1"
18
22
  },
19
23
  "scripts": {
20
- "test": "jshint --reporter node_modules/jshint-stylish/stylish.js index.js && mocha tests/*",
21
- "watch": "nodemon -q -w index.js -w parser.js -w tests/ -x npm test"
24
+ "pretest": "eslint .",
25
+ "test": "mocha tests",
26
+ "watch": "nodemon -q -i node_modules -x npm test"
22
27
  },
23
28
  "repository": {
24
29
  "type": "git",