comment-parser 0.7.4 → 0.7.5
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/CHANGELOG.md +3 -0
- package/package.json +3 -2
- package/parsers.js +18 -15
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comment-parser",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Generic JSDoc-like comment parser. ",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
"Evgeny Reznichenko (https://github.com/zxcabs)",
|
|
62
62
|
"Javier \"Ciberma\" Mora (https://github.com/jhm-ciberman)",
|
|
63
63
|
"Jordan Harband (https://github.com/ljharb)",
|
|
64
|
-
"tengattack (https://github.com/tengattack)"
|
|
64
|
+
"tengattack (https://github.com/tengattack)",
|
|
65
|
+
"Jayden Seric (https://github.com/jaydenseric)"
|
|
65
66
|
],
|
|
66
67
|
"license": "MIT",
|
|
67
68
|
"bugs": {
|
package/parsers.js
CHANGED
|
@@ -13,12 +13,12 @@ function skipws (str) {
|
|
|
13
13
|
const PARSERS = {}
|
|
14
14
|
|
|
15
15
|
PARSERS.parse_tag = function parse_tag (str) {
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
16
|
+
const match = str.match(/^\s*@(\S+)/)
|
|
17
|
+
if (!match) { throw new SyntaxError('Invalid `@tag`, missing @ symbol') }
|
|
18
18
|
|
|
19
19
|
return {
|
|
20
|
-
source:
|
|
21
|
-
data: { tag:
|
|
20
|
+
source: match[0],
|
|
21
|
+
data: { tag: match[1] }
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -38,7 +38,7 @@ PARSERS.parse_type = function parse_type (str, data) {
|
|
|
38
38
|
if (curlies === 0) { break }
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
if (curlies !== 0) { throw new
|
|
41
|
+
if (curlies !== 0) { throw new SyntaxError('Invalid `{type}`, unpaired curlies') }
|
|
42
42
|
|
|
43
43
|
return {
|
|
44
44
|
source: str.slice(0, pos),
|
|
@@ -68,7 +68,7 @@ PARSERS.parse_name = function parse_name (str, data) {
|
|
|
68
68
|
if (brackets === 0 && /\s/.test(str[pos])) { break }
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
if (brackets !== 0) { throw new
|
|
71
|
+
if (brackets !== 0) { throw new SyntaxError('Invalid `name`, unpaired brackets') }
|
|
72
72
|
|
|
73
73
|
res = { name, optional: false }
|
|
74
74
|
|
|
@@ -76,11 +76,14 @@ PARSERS.parse_name = function parse_name (str, data) {
|
|
|
76
76
|
res.optional = true
|
|
77
77
|
name = name.slice(1, -1)
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
const match = name.match(
|
|
80
|
+
/^\s*([^=]+?)(?:\s*=\s*(.+?))?\s*(?=$)/
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
if (!match) throw new SyntaxError('Invalid `name`, bad syntax')
|
|
84
|
+
|
|
85
|
+
name = match[1]
|
|
86
|
+
if (match[2]) res.default = match[2]
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
|
|
@@ -95,12 +98,12 @@ PARSERS.parse_name = function parse_name (str, data) {
|
|
|
95
98
|
PARSERS.parse_description = function parse_description (str, data) {
|
|
96
99
|
if (data.errors && data.errors.length) { return null }
|
|
97
100
|
|
|
98
|
-
const
|
|
101
|
+
const match = str.match(/^\s+((.|\s)+)?/)
|
|
99
102
|
|
|
100
|
-
if (
|
|
103
|
+
if (match) {
|
|
101
104
|
return {
|
|
102
|
-
source:
|
|
103
|
-
data: { description:
|
|
105
|
+
source: match[0],
|
|
106
|
+
data: { description: match[1] === undefined ? '' : match[1] }
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
|