Error found when generating JSON doc

  • Version: master b1c0587
  • Platform: Darwin firedfox-mbp.local 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
  • Subsystem: tools

When I run tools/doc/generate.js to build JSON format docs, I see this error:

Input file = fs.markdown
/Users/firedfox/git/node/tools/doc/json.js:207
        throw new Error('invalid list - text without current item\n' +
        ^

Error: invalid list - text without current item
{"type":"text","text":"`callback` {Function}"}
[{"type":"list_start","ordered":false},{"type":"list_item_start"},{"type":"text","text":"`path` {String | Buffer}"},{"type":"list_item_end"},{"type":"list_item_start"},{"type":"text","text":"`options` {String | Object}"},{"type":"list_start","ordered":false},{"type":"list_item_start"},{"type":"text","text":"`encoding` {String} default = `'utf8'`"},{"type":"list_item_end"},{"type":"list_end"},{"type":"list_item_end"},{"type":"loose_item_start"},{"type":"text","text":"`callback` {Function}"},{"type":"list_item_end"},{"type":"loose_item_start"},{"type":"text","text":"`path` {String}"},{"type":"list_item_end"},{"type":"list_item_start"},{"type":"text","text":"`callback` {Function}"},{"type":"space"},{"type":"list_item_end"},{"type":"list_end"}]
    at /Users/firedfox/git/node/tools/doc/json.js:207:15
    at Array.forEach (native)
    at processList (/Users/firedfox/git/node/tools/doc/json.js:183:8)
    at /Users/firedfox/git/node/tools/doc/json.js:115:9
    at Array.forEach (native)
    at doJSON (/Users/firedfox/git/node/tools/doc/json.js:17:9)
    at next (/Users/firedfox/git/node/tools/doc/generate.js:42:27)
    at /Users/firedfox/git/node/tools/doc/preprocess.js:16:5
    at processIncludes (/Users/firedfox/git/node/tools/doc/preprocess.js:26:33)
    at preprocess (/Users/firedfox/git/node/tools/doc/preprocess.js:13:3)

It's caused by the following content in fs.markdown:

## fs.readdir(path[, options], callback)

* `path` {String | Buffer}
* `options` {String | Object}
  * `encoding` {String} default = `'utf8'`
* `callback` {Function}

* `path` {String}
* `callback` {Function}

Current processList function in tools/doc/json.js does not recognise the second path and callback's {"type":"loose_item_start"}. I'll make a PR to fix it.