diff --git a/source/Ox/js/JavaScript.js b/source/Ox/js/JavaScript.js index 5de1eb5c..93b1bdb9 100644 --- a/source/Ox/js/JavaScript.js +++ b/source/Ox/js/JavaScript.js @@ -61,13 +61,13 @@ Ox.doc = (function() { function encodeLinebreaks(match, submatch) { return '\n' + (submatch || match).replace(/\n/g, '\u21A9'); } - function getIndent(str) { + function getIndent(string) { var indent = -1; - while (str[++indent] == ' ') {} + while (string[++indent] == ' ') {} return indent; } - function parseItem(str) { - var matches = re.item.exec(str); + function parseItem(string) { + var matches = re.item.exec(string); // to tell a variable with default value, like // name foo'> summary // from a line of description with tags, like @@ -82,9 +82,9 @@ Ox.doc = (function() { summary: matches[3].trim() }, parseType(matches[2])) : null; } - function parseName(str) { - var matches = re.usage.exec(str); - return matches ? matches[0] : str; + function parseName(string) { + var matches = re.usage.exec(string); + return matches ? matches[0] : string; } function parseNode(node) { var item = parseItem(node.line), subitem; @@ -117,9 +117,9 @@ Ox.doc = (function() { }); return item; } - function parseScript(str) { + function parseScript(string) { // remove script tags and extra indentation - var lines = decodeLinebreaks(str).split('\n'), + var lines = decodeLinebreaks(string).split('\n'), indent = getIndent(lines[1]); return { statement: lines.slice(1, -1).map(function(line, i) { @@ -182,9 +182,9 @@ Ox.doc = (function() { }); return items; } - function parseTest(str) { + function parseTest(string) { // fixme: we cannot properly handle tests where a string contains '\n ' - var lines = decodeLinebreaks(str).split('\n '); + var lines = decodeLinebreaks(string).split('\n '); return { statement: lines[0].slice(2), result: lines[1].trim() @@ -249,24 +249,24 @@ Ox.doc = (function() { } return node; } - function parseType(str) { + function parseType(string) { // returns {types: [""]} // or {types: [""], default: ""} // or {types: [""], super: ""} - var isArray, + var array, + isArray, ret = {types: []}, - split, type; // only split by ':' if there is no default string value - if ('\'"'.indexOf(str.slice(-2, -1)) == -1) { - split = str.split(':'); - str = split[0]; - if (split.length == 2) { - ret.super = split[1]; + if ('\'"'.indexOf(string.slice(-2, -1)) == -1) { + array = string.split(':'); + string = array[0]; + if (array.length == 2) { + ret.super = array[1]; } } - str.split('|').forEach(function(str) { - var unwrapped = unwrap(str); + string.split('|').forEach(function(string) { + var unwrapped = unwrap(string); if (unwrapped in types) { ret.types.push(wrap(types[unwrapped])) } else if ( @@ -276,14 +276,15 @@ Ox.doc = (function() { ) { ret.types.push(wrap(type[0])); } else { - ret['default'] = str; + ret['default'] = string; } }); - function unwrap(str) { - return (isArray = /^\[.+\]$/.test(str)) ? str.slice(1, -1) : str; + function unwrap(string) { + return (isArray = /^\[.+\]$/.test(string)) + ? string.slice(1, -1) : string; } - function wrap(str) { - return isArray ? '[' + str + 's' + ']' : str; + function wrap(string) { + return isArray ? '[' + string + 's' + ']' : string; } return ret; }