Skip to content

Commit

Permalink
tools: change var to const in ./doc/json
Browse files Browse the repository at this point in the history
PR-URL: #13732
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
  • Loading branch information
BridgeAR authored and addaleax committed Jul 18, 2017
1 parent b89c27d commit 148f49f
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions tools/doc/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
};
Expand All @@ -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 -->
Expand Down Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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, '');
Expand All @@ -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, '');
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 148f49f

Please sign in to comment.