tools: change var to const in ./doc/html
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
bce27c2cf3
commit
0808989d93
@ -33,7 +33,7 @@ module.exports = toHTML;
|
|||||||
const STABILITY_TEXT_REG_EXP = /(.*:)\s*(\d)([\s\S]*)/;
|
const STABILITY_TEXT_REG_EXP = /(.*:)\s*(\d)([\s\S]*)/;
|
||||||
|
|
||||||
// customized heading without id attribute
|
// customized heading without id attribute
|
||||||
var renderer = new marked.Renderer();
|
const renderer = new marked.Renderer();
|
||||||
renderer.heading = function(text, level) {
|
renderer.heading = function(text, level) {
|
||||||
return '<h' + level + '>' + text + '</h' + level + '>\n';
|
return '<h' + level + '>' + text + '</h' + level + '>\n';
|
||||||
};
|
};
|
||||||
@ -42,7 +42,7 @@ marked.setOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TODO(chrisdickinson): never stop vomitting / fix this.
|
// TODO(chrisdickinson): never stop vomitting / fix this.
|
||||||
var gtocPath = path.resolve(path.join(
|
const gtocPath = path.resolve(path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
'..',
|
'..',
|
||||||
'..',
|
'..',
|
||||||
@ -57,8 +57,8 @@ var gtocData = null;
|
|||||||
* opts: input, filename, template, nodeVersion.
|
* opts: input, filename, template, nodeVersion.
|
||||||
*/
|
*/
|
||||||
function toHTML(opts, cb) {
|
function toHTML(opts, cb) {
|
||||||
var template = opts.template;
|
const template = opts.template;
|
||||||
var nodeVersion = opts.nodeVersion || process.version;
|
const nodeVersion = opts.nodeVersion || process.version;
|
||||||
|
|
||||||
if (gtocData) {
|
if (gtocData) {
|
||||||
return onGtocLoaded();
|
return onGtocLoaded();
|
||||||
@ -80,7 +80,7 @@ function toHTML(opts, cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onGtocLoaded() {
|
function onGtocLoaded() {
|
||||||
var lexed = marked.lexer(opts.input);
|
const lexed = marked.lexer(opts.input);
|
||||||
fs.readFile(template, 'utf8', function(er, template) {
|
fs.readFile(template, 'utf8', function(er, template) {
|
||||||
if (er) return cb(er);
|
if (er) return cb(er);
|
||||||
render({
|
render({
|
||||||
@ -123,10 +123,10 @@ function render(opts, cb) {
|
|||||||
var lexed = opts.lexed;
|
var lexed = opts.lexed;
|
||||||
var filename = opts.filename;
|
var filename = opts.filename;
|
||||||
var template = opts.template;
|
var template = opts.template;
|
||||||
var nodeVersion = opts.nodeVersion || process.version;
|
const nodeVersion = opts.nodeVersion || process.version;
|
||||||
|
|
||||||
// get the section
|
// get the section
|
||||||
var section = getSection(lexed);
|
const section = getSection(lexed);
|
||||||
|
|
||||||
filename = path.basename(filename, '.md');
|
filename = path.basename(filename, '.md');
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ function render(opts, cb) {
|
|||||||
buildToc(lexed, filename, function(er, toc) {
|
buildToc(lexed, filename, function(er, toc) {
|
||||||
if (er) return cb(er);
|
if (er) return cb(er);
|
||||||
|
|
||||||
var id = toID(path.basename(filename));
|
const id = toID(path.basename(filename));
|
||||||
|
|
||||||
template = template.replace(/__ID__/g, id);
|
template = template.replace(/__ID__/g, id);
|
||||||
template = template.replace(/__FILENAME__/g, filename);
|
template = template.replace(/__FILENAME__/g, filename);
|
||||||
@ -220,9 +220,9 @@ function parseText(lexed) {
|
|||||||
// lists that come right after a heading are what we're after.
|
// lists that come right after a heading are what we're after.
|
||||||
function parseLists(input) {
|
function parseLists(input) {
|
||||||
var state = null;
|
var state = null;
|
||||||
var savedState = [];
|
const savedState = [];
|
||||||
var depth = 0;
|
var depth = 0;
|
||||||
var output = [];
|
const output = [];
|
||||||
let headingIndex = -1;
|
let headingIndex = -1;
|
||||||
let heading = null;
|
let heading = null;
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ function parseYAML(text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Syscalls which appear in the docs, but which only exist in BSD / OSX
|
// Syscalls which appear in the docs, but which only exist in BSD / OSX
|
||||||
var BSD_ONLY_SYSCALLS = new Set(['lchmod']);
|
const BSD_ONLY_SYSCALLS = new Set(['lchmod']);
|
||||||
|
|
||||||
// Handle references to man pages, eg "open(2)" or "lchmod(2)"
|
// Handle references to man pages, eg "open(2)" or "lchmod(2)"
|
||||||
// Returns modified text, with such refs replace with HTML links, for example
|
// Returns modified text, with such refs replace with HTML links, for example
|
||||||
@ -363,7 +363,7 @@ function linkManPages(text) {
|
|||||||
/ ([a-z.]+)\((\d)([a-z]?)\)/gm,
|
/ ([a-z.]+)\((\d)([a-z]?)\)/gm,
|
||||||
(match, name, number, optionalCharacter) => {
|
(match, name, number, optionalCharacter) => {
|
||||||
// name consists of lowercase letters, number is a single digit
|
// name consists of lowercase letters, number is a single digit
|
||||||
var displayAs = `${name}(${number}${optionalCharacter})`;
|
const displayAs = `${name}(${number}${optionalCharacter})`;
|
||||||
if (BSD_ONLY_SYSCALLS.has(name)) {
|
if (BSD_ONLY_SYSCALLS.has(name)) {
|
||||||
return ` <a href="https://www.freebsd.org/cgi/man.cgi?query=${name}` +
|
return ` <a href="https://www.freebsd.org/cgi/man.cgi?query=${name}` +
|
||||||
`&sektion=${number}">${displayAs}</a>`;
|
`&sektion=${number}">${displayAs}</a>`;
|
||||||
@ -375,7 +375,7 @@ function linkManPages(text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function linkJsTypeDocs(text) {
|
function linkJsTypeDocs(text) {
|
||||||
var parts = text.split('`');
|
const parts = text.split('`');
|
||||||
var i;
|
var i;
|
||||||
var typeMatches;
|
var typeMatches;
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ function buildToc(lexed, filename, cb) {
|
|||||||
cb(null, toc);
|
cb(null, toc);
|
||||||
}
|
}
|
||||||
|
|
||||||
var idCounters = {};
|
const idCounters = {};
|
||||||
function getId(text) {
|
function getId(text) {
|
||||||
text = text.toLowerCase();
|
text = text.toLowerCase();
|
||||||
text = text.replace(/[^a-z0-9]+/g, '_');
|
text = text.replace(/[^a-z0-9]+/g, '_');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user