tools: fix warning in doc parsing
authorShigeki Ohtsu <ohtsu@iij.ad.jp>
Tue, 5 Jan 2016 09:11:19 +0000 (18:11 +0900)
committerMyles Borins <mborins@us.ibm.com>
Wed, 2 Mar 2016 22:01:11 +0000 (14:01 -0800)
The description of "[start[, end]]" in the doc shows warning of
"invalid param" when parsing an optional parameter in the section.
This fixes insufficient trimming of right square brackets.

PR-URL: https://github.com/nodejs/node/pull/4537
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
tools/doc/json.js

index d6cbbb04dc10a23cee4a7317942eefc41d495622..299c8ed9fd84adbfe2cf4a6ede2abbb1c3b3844a 100644 (file)
@@ -284,7 +284,7 @@ function parseSignature(text, sig) {
     // [foo] -> optional
     if (p.charAt(p.length - 1) === ']') {
       optional = true;
-      p = p.substr(0, p.length - 1);
+      p = p.replace(/\]/g, '');
       p = p.trim();
     }
     var eq = p.indexOf('=');