1
+ 'use strict' ;
2
+
1
3
module . exports = doJSON ;
2
4
3
5
// Take the lexed input, and return a JSON-encoded object
@@ -12,7 +14,7 @@ function doJSON(input, filename, cb) {
12
14
var current = root ;
13
15
var state = null ;
14
16
var lexed = marked . lexer ( input ) ;
15
- lexed . forEach ( function ( tok ) {
17
+ lexed . forEach ( function ( tok ) {
16
18
var type = tok . type ;
17
19
var text = tok . text ;
18
20
@@ -31,7 +33,7 @@ function doJSON(input, filename, cb) {
31
33
if ( type === 'heading' &&
32
34
! text . trim ( ) . match ( / ^ e x a m p l e / i) ) {
33
35
if ( tok . depth - depth > 1 ) {
34
- return cb ( new Error ( 'Inappropriate heading level\n' +
36
+ return cb ( new Error ( 'Inappropriate heading level\n' +
35
37
JSON . stringify ( tok ) ) ) ;
36
38
}
37
39
@@ -77,7 +79,7 @@ function doJSON(input, filename, cb) {
77
79
//
78
80
// If one of these isnt' found, then anything that comes between
79
81
// here and the next heading should be parsed as the desc.
80
- var stability
82
+ var stability ;
81
83
if ( state === 'AFTERHEADING' ) {
82
84
if ( type === 'code' &&
83
85
( stability = text . match ( / ^ S t a b i l i t y : ( [ 0 - 5 ] ) (?: \s * - \s * ) ? ( .* ) $ / ) ) ) {
@@ -125,7 +127,7 @@ function doJSON(input, filename, cb) {
125
127
finishSection ( current , stack [ stack . length - 1 ] ) ;
126
128
}
127
129
128
- return cb ( null , root )
130
+ return cb ( null , root ) ;
129
131
}
130
132
131
133
@@ -146,7 +148,7 @@ function doJSON(input, filename, cb) {
146
148
// { type: 'list_item_end' },
147
149
// { type: 'list_item_start' },
148
150
// { type: 'text',
149
- // text: 'silent: Boolean, whether or not to send output to parent\'s stdio.' },
151
+ // text: 'silent: Boolean, whether to send output to parent\'s stdio.' },
150
152
// { type: 'text', text: 'Default: `false`' },
151
153
// { type: 'space' },
152
154
// { type: 'list_item_end' },
@@ -168,7 +170,7 @@ function doJSON(input, filename, cb) {
168
170
// desc: 'string arguments passed to worker.' },
169
171
// { name: 'silent',
170
172
// type: 'boolean',
171
- // desc: 'whether or not to send output to parent\'s stdio.',
173
+ // desc: 'whether to send output to parent\'s stdio.',
172
174
// default: 'false' } ] } ]
173
175
174
176
function processList ( section ) {
@@ -231,7 +233,7 @@ function processList(section) {
231
233
// each item is an argument, unless the name is 'return',
232
234
// in which case it's the return value.
233
235
section . signatures = section . signatures || [ ] ;
234
- var sig = { }
236
+ var sig = { } ;
235
237
section . signatures . push ( sig ) ;
236
238
sig . params = values . filter ( function ( v ) {
237
239
if ( v . name === 'return' ) {
@@ -273,7 +275,7 @@ function parseSignature(text, sig) {
273
275
params = params [ 1 ] ;
274
276
// the [ is irrelevant. ] indicates optionalness.
275
277
params = params . replace ( / \[ / g, '' ) ;
276
- params = params . split ( / , / )
278
+ params = params . split ( / , / ) ;
277
279
params . forEach ( function ( p , i , _ ) {
278
280
p = p . trim ( ) ;
279
281
if ( ! p ) return ;
@@ -362,7 +364,7 @@ function parseListItem(item) {
362
364
363
365
function finishSection ( section , parent ) {
364
366
if ( ! section || ! parent ) {
365
- throw new Error ( 'Invalid finishSection call\n' +
367
+ throw new Error ( 'Invalid finishSection call\n' +
366
368
JSON . stringify ( section ) + '\n' +
367
369
JSON . stringify ( parent ) ) ;
368
370
}
@@ -405,7 +407,7 @@ function finishSection(section, parent) {
405
407
// properties are a bit special.
406
408
// their "type" is the type of object, not "property"
407
409
if ( section . properties ) {
408
- section . properties . forEach ( function ( p ) {
410
+ section . properties . forEach ( function ( p ) {
409
411
if ( p . typeof ) p . type = p . typeof ;
410
412
else delete p . type ;
411
413
delete p . typeof ;
0 commit comments