summaryrefslogtreecommitdiff
path: root/tools/doc/json.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2017-06-19 17:55:27 +0200
committerRefael Ackermann <refack@gmail.com>2017-07-02 19:26:50 -0400
commit461049f8e9acfa59d07f7ae22b4accc72bcdf51a (patch)
treec4d3143c32bc62a3c0e585eb5c43d43de8dc2c43 /tools/doc/json.js
parent0808989d938b53035fb858b0e21e2984e991e7a0 (diff)
downloadandroid-node-v8-461049f8e9acfa59d07f7ae22b4accc72bcdf51a.tar.gz
android-node-v8-461049f8e9acfa59d07f7ae22b4accc72bcdf51a.tar.bz2
android-node-v8-461049f8e9acfa59d07f7ae22b4accc72bcdf51a.zip
tools: change var to const in ./doc/json
PR-URL: https://github.com/nodejs/node/pull/13732 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'tools/doc/json.js')
-rw-r--r--tools/doc/json.js56
1 files changed, 28 insertions, 28 deletions
diff --git a/tools/doc/json.js b/tools/doc/json.js
index 0e205ed7cb..aad860f840 100644
--- a/tools/doc/json.js
+++ b/tools/doc/json.js
@@ -30,7 +30,7 @@ const common = require('./common.js');
const marked = require('marked');
// customized heading without id attribute
-var renderer = new marked.Renderer();
+const renderer = new marked.Renderer();
renderer.heading = function(text, level) {
return '<h' + level + '>' + text + '</h' + level + '>\n';
};
@@ -39,14 +39,14 @@ marked.setOptions({
});
function doJSON(input, filename, cb) {
- var root = {source: filename};
- var stack = [root];
+ const root = {source: filename};
+ const stack = [root];
var depth = 0;
var current = root;
var state = null;
- var lexed = marked.lexer(input);
+ const lexed = marked.lexer(input);
lexed.forEach(function(tok) {
- var type = tok.type;
+ const type = tok.type;
var text = tok.text;
// <!-- type = module -->
@@ -223,14 +223,14 @@ function doJSON(input, filename, cb) {
// default: 'false' } ] } ]
function processList(section) {
- var list = section.list;
- var values = [];
+ const list = section.list;
+ const values = [];
var current;
- var stack = [];
+ const stack = [];
// for now, *just* build the heirarchical list
list.forEach(function(tok) {
- var type = tok.type;
+ const type = tok.type;
if (type === 'space') return;
if (type === 'list_item_start' || type === 'loose_item_start') {
var n = {};
@@ -329,7 +329,7 @@ function parseSignature(text, sig) {
params = params[1];
params = params.split(/,/);
var optionalLevel = 0;
- var optionalCharDict = {'[': 1, ' ': 0, ']': -1};
+ const optionalCharDict = {'[': 1, ' ': 0, ']': -1};
params.forEach(function(p, i) {
p = p.trim();
if (!p) return;
@@ -351,7 +351,7 @@ function parseSignature(text, sig) {
}
p = p.substring(0, pos + 1);
- var eq = p.indexOf('=');
+ const eq = p.indexOf('=');
if (eq !== -1) {
def = p.substr(eq + 1);
p = p.substr(0, eq);
@@ -381,8 +381,8 @@ function parseListItem(item) {
// text = text.replace(/^(Argument|Param)s?\s*:?\s*/i, '');
text = text.replace(/^, /, '').trim();
- var retExpr = /^returns?\s*:?\s*/i;
- var ret = text.match(retExpr);
+ const retExpr = /^returns?\s*:?\s*/i;
+ const ret = text.match(retExpr);
if (ret) {
item.name = 'return';
text = text.replace(retExpr, '');
@@ -396,24 +396,24 @@ function parseListItem(item) {
}
text = text.trim();
- var defaultExpr = /\(default\s*[:=]?\s*['"`]?([^, '"`]*)['"`]?\)/i;
- var def = text.match(defaultExpr);
+ const defaultExpr = /\(default\s*[:=]?\s*['"`]?([^, '"`]*)['"`]?\)/i;
+ const def = text.match(defaultExpr);
if (def) {
item.default = def[1];
text = text.replace(defaultExpr, '');
}
text = text.trim();
- var typeExpr = /^\{([^}]+)\}/;
- var type = text.match(typeExpr);
+ const typeExpr = /^\{([^}]+)\}/;
+ const type = text.match(typeExpr);
if (type) {
item.type = type[1];
text = text.replace(typeExpr, '');
}
text = text.trim();
- var optExpr = /^Optional\.|(?:, )?Optional$/;
- var optional = text.match(optExpr);
+ const optExpr = /^Optional\.|(?:, )?Optional$/;
+ const optional = text.match(optExpr);
if (optional) {
item.optional = true;
text = text.replace(optExpr, '');
@@ -556,19 +556,19 @@ function deepCopy_(src) {
// these parse out the contents of an H# tag
-var eventExpr = /^Event(?::|\s)+['"]?([^"']+).*$/i;
-var classExpr = /^Class:\s*([^ ]+).*$/i;
-var propExpr = /^[^.]+\.([^ .()]+)\s*$/;
-var braceExpr = /^[^.[]+(\[[^\]]+\])\s*$/;
-var classMethExpr = /^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*$/i;
-var methExpr = /^(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*$/;
-var newExpr = /^new ([A-Z][a-zA-Z]+)\([^)]*\)\s*$/;
+const eventExpr = /^Event(?::|\s)+['"]?([^"']+).*$/i;
+const classExpr = /^Class:\s*([^ ]+).*$/i;
+const propExpr = /^[^.]+\.([^ .()]+)\s*$/;
+const braceExpr = /^[^.[]+(\[[^\]]+\])\s*$/;
+const classMethExpr = /^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*$/i;
+const methExpr = /^(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*$/;
+const newExpr = /^new ([A-Z][a-zA-Z]+)\([^)]*\)\s*$/;
var paramExpr = /\((.*)\);?$/;
function newSection(tok) {
- var section = {};
+ const section = {};
// infer the type from the text.
- var text = section.textRaw = tok.text;
+ const text = section.textRaw = tok.text;
if (text.match(eventExpr)) {
section.type = 'event';
section.name = text.replace(eventExpr, '$1');