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>
This commit is contained in:
parent
0808989d93
commit
461049f8e9
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user