diff options
author | Trevor Norris <trev.norris@gmail.com> | 2014-09-29 16:32:34 -0700 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2014-09-29 16:32:34 -0700 |
commit | f2a78de6ec134f4050531ba6a52dee47e0aee165 (patch) | |
tree | 7fa7669e8e451f1ec3ec8ca2a83b933af469bd4e /tools | |
parent | 734fb49a2af580f2d9c97a0bdd82ad3e6a1f64a2 (diff) | |
download | node-new-f2a78de6ec134f4050531ba6a52dee47e0aee165.tar.gz |
doc: fix optional parameter parsing
The parameter parser specifically looked for the old bracket syntax.
This generated a lot of warnings when building the docs. Those warnings
have been fixed by changing the parsing logic.
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/doc/json.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/doc/json.js b/tools/doc/json.js index 2459bc26ae..9fdc3bc1b4 100644 --- a/tools/doc/json.js +++ b/tools/doc/json.js @@ -287,13 +287,13 @@ function processList(section) { } -// textRaw = "someobject.someMethod(a, [b=100], [c])" +// textRaw = "someobject.someMethod(a[, b=100][, c])" function parseSignature(text, sig) { var params = text.match(paramExpr); if (!params) return; params = params[1]; - // the ] is irrelevant. [ indicates optionalness. - params = params.replace(/\]/g, ''); + // the [ is irrelevant. ] indicates optionalness. + params = params.replace(/\[/g, ''); params = params.split(/,/) params.forEach(function(p, i, _) { p = p.trim(); @@ -302,9 +302,10 @@ function parseSignature(text, sig) { var optional = false; var def; // [foo] -> optional - if (p.charAt(0) === '[') { + if (p.charAt(p.length - 1) === ']') { optional = true; - p = p.substr(1); + p = p.substr(0, p.length - 1); + p = p.trim(); } var eq = p.indexOf('='); if (eq !== -1) { |