tools: create HTML docs with unified/remark/rehype
PR-URL: https://github.com/nodejs/node/pull/21490 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
1ffd35310a
commit
946686521d
51
LICENSE
51
LICENSE
@ -1197,6 +1197,57 @@ The externally maintained libraries used by Node.js are:
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
|
||||
- unified, located at deps/unified, is licensed as follows:
|
||||
"""
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
"""
|
||||
|
||||
- remark-rehype, located at deps/remark-rehype, is licensed as follows:
|
||||
"""
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2016 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
|
||||
- remark-cli, located at tools/remark-cli, is licensed as follows:
|
||||
"""
|
||||
(The MIT License)
|
||||
|
9
Makefile
9
Makefile
@ -266,7 +266,6 @@ test: all ## Runs default tests, linters, and builds docs.
|
||||
# can be displayed together
|
||||
$(MAKE) -s build-addons
|
||||
$(MAKE) -s build-addons-napi
|
||||
$(MAKE) -s test-doc
|
||||
$(MAKE) -s cctest
|
||||
$(MAKE) -s jstest
|
||||
|
||||
@ -611,7 +610,8 @@ apidocs_json = $(addprefix out/,$(apidoc_sources:.md=.json))
|
||||
apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
|
||||
|
||||
.PHONY: doc-only
|
||||
doc-only: $(apidoc_dirs) $(apiassets) ## Builds the docs with the local or the global Node.js binary.
|
||||
doc-only: tools/doc/node_modules \
|
||||
$(apidoc_dirs) $(apiassets) ## Builds the docs with the local or the global Node.js binary.
|
||||
# If it's a source tarball, assets are already in doc/api/assets,
|
||||
# no need to install anything, we have already copied the docs over
|
||||
if [ ! -d doc/api/assets ]; then \
|
||||
@ -1082,8 +1082,13 @@ tools/remark-preset-lint-node/node_modules: \
|
||||
|
||||
.PHONY: lint-md-build
|
||||
lint-md-build: tools/remark-cli/node_modules \
|
||||
tools/doc/node_modules \
|
||||
tools/remark-preset-lint-node/node_modules
|
||||
|
||||
.PHONY: tools/doc/node_modules
|
||||
tools/doc/node_modules:
|
||||
@cd tools/doc && $(call available-node,$(run-npm-install))
|
||||
|
||||
.PHONY: lint-md
|
||||
ifneq ("","$(wildcard tools/remark-cli/node_modules/)")
|
||||
|
||||
|
@ -21,8 +21,8 @@ const toHTML = require('../../tools/doc/html.js');
|
||||
const testData = [
|
||||
{
|
||||
file: fixtures.path('sample_document.md'),
|
||||
html: '<ol><li>fish</li><li><p>fish</p></li><li><p>Redfish</p></li>' +
|
||||
'<li>Bluefish</li></ol>'
|
||||
html: '<ol><li>fish</li><li>fish</li></ol>' +
|
||||
'<ul><li>Redfish</li><li>Bluefish</li></ul>'
|
||||
},
|
||||
{
|
||||
file: fixtures.path('order_of_end_tags_5873.md'),
|
||||
@ -31,7 +31,7 @@ const testData = [
|
||||
'id="foo_class_method_buffer_from_array">#</a> </span> </h3>' +
|
||||
'<ul><li><code>array</code><a ' +
|
||||
'href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/' +
|
||||
'Reference/Global_Objects/Array" class="type"><Array></a></li></ul>'
|
||||
'Reference/Global_Objects/Array" class="type"><Array></a></li></ul>'
|
||||
},
|
||||
{
|
||||
file: fixtures.path('doc_with_yaml.md'),
|
||||
@ -45,11 +45,11 @@ const testData = [
|
||||
'<h2>Foobar II<span><a class="mark" href="#foo_foobar_ii" ' +
|
||||
'id="foo_foobar_ii">#</a></span></h2><div class="api_metadata">' +
|
||||
'<details class="changelog"><summary>History</summary>' +
|
||||
'<table><tr><th>Version</th><th>Changes</th></tr>' +
|
||||
'<table><tbody><tr><th>Version</th><th>Changes</th></tr>' +
|
||||
'<tr><td>v5.3.0, v4.2.0</td>' +
|
||||
'<td><p><span>Added in: v5.3.0, v4.2.0</span></p></td></tr>' +
|
||||
'<tr><td>v4.2.0</td><td><p>The <code>error</code> parameter can now be' +
|
||||
'an arrow function.</p></td></tr></table></details></div> ' +
|
||||
'an arrow function.</p></td></tr></tbody></table></details></div> ' +
|
||||
'<p>Describe <code>Foobar II</code> in more detail here.' +
|
||||
'<a href="http://man7.org/linux/man-pages/man1/fg.1.html"><code>fg(1)' +
|
||||
'</code></a></p><h2>Deprecated thingy<span><a class="mark" ' +
|
||||
@ -65,8 +65,8 @@ const testData = [
|
||||
},
|
||||
{
|
||||
file: fixtures.path('sample_document.md'),
|
||||
html: '<ol><li>fish</li><li><p>fish</p></li><li><p>Redfish</p></li>' +
|
||||
'<li>Bluefish</li></ol>',
|
||||
html: '<ol><li>fish</li><li>fish</li></ol>' +
|
||||
'<ul><li>Red fish</li><li>Blue fish</li></ul>',
|
||||
analyticsId: 'UA-67020396-1'
|
||||
},
|
||||
];
|
||||
|
@ -23,26 +23,39 @@
|
||||
|
||||
const common = require('./common.js');
|
||||
const fs = require('fs');
|
||||
const marked = require('marked');
|
||||
const unified = require('unified');
|
||||
const find = require('unist-util-find');
|
||||
const visit = require('unist-util-visit');
|
||||
const markdown = require('remark-parse');
|
||||
const remark2rehype = require('remark-rehype');
|
||||
const raw = require('rehype-raw');
|
||||
const html = require('rehype-stringify');
|
||||
const path = require('path');
|
||||
const typeParser = require('./type-parser.js');
|
||||
|
||||
module.exports = toHTML;
|
||||
|
||||
// Make `marked` to not automatically insert id attributes in headings.
|
||||
const renderer = new marked.Renderer();
|
||||
renderer.heading = (text, level) => `<h${level}>${text}</h${level}>\n`;
|
||||
marked.setOptions({ renderer });
|
||||
|
||||
const docPath = path.resolve(__dirname, '..', '..', 'doc');
|
||||
|
||||
// Add class attributes to index navigation links.
|
||||
function navClasses() {
|
||||
return (tree) => {
|
||||
visit(tree, { type: 'element', tagName: 'a' }, (node) => {
|
||||
node.properties.class = 'nav-' +
|
||||
node.properties.href.replace('.html', '').replace(/\W+/g, '-');
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const gtocPath = path.join(docPath, 'api', 'index.md');
|
||||
const gtocMD = fs.readFileSync(gtocPath, 'utf8').replace(/^<!--.*?-->/gms, '');
|
||||
const gtocHTML = marked(gtocMD).replace(
|
||||
/<a href="(.*?)"/g,
|
||||
(all, href) => `<a class="nav-${href.replace('.html', '')
|
||||
.replace(/\W+/g, '-')}" href="${href}"`
|
||||
);
|
||||
const gtocHTML = unified()
|
||||
.use(markdown)
|
||||
.use(remark2rehype, { allowDangerousHTML: true })
|
||||
.use(raw)
|
||||
.use(navClasses)
|
||||
.use(html)
|
||||
.processSync(gtocMD).toString();
|
||||
|
||||
const templatePath = path.join(docPath, 'template.html');
|
||||
const template = fs.readFileSync(templatePath, 'utf8');
|
||||
@ -50,26 +63,28 @@ const template = fs.readFileSync(templatePath, 'utf8');
|
||||
function toHTML({ input, filename, nodeVersion, analytics }, cb) {
|
||||
filename = path.basename(filename, '.md');
|
||||
|
||||
const lexed = marked.lexer(input);
|
||||
|
||||
const firstHeading = lexed.find(({ type }) => type === 'heading');
|
||||
const section = firstHeading ? firstHeading.text : 'Index';
|
||||
|
||||
preprocessText(lexed);
|
||||
preprocessElements(lexed, filename);
|
||||
|
||||
// Generate the table of contents. This mutates the lexed contents in-place.
|
||||
const toc = buildToc(lexed, filename);
|
||||
const content = unified()
|
||||
.use(markdown)
|
||||
.use(firstHeader)
|
||||
.use(preprocessText)
|
||||
.use(preprocessElements, { filename })
|
||||
.use(buildToc, { filename })
|
||||
.use(remark2rehype, { allowDangerousHTML: true })
|
||||
.use(raw)
|
||||
.use(html)
|
||||
.processSync(input);
|
||||
|
||||
const id = filename.replace(/\W+/g, '-');
|
||||
|
||||
let HTML = template.replace('__ID__', id)
|
||||
.replace(/__FILENAME__/g, filename)
|
||||
.replace('__SECTION__', section)
|
||||
.replace('__SECTION__', content.section)
|
||||
.replace(/__VERSION__/g, nodeVersion)
|
||||
.replace('__TOC__', toc)
|
||||
.replace('__TOC__', content.toc)
|
||||
.replace('__GTOC__', gtocHTML.replace(
|
||||
`class="nav-${id}`, `class="nav-${id} active`));
|
||||
`class="nav-${id}`, `class="nav-${id} active`))
|
||||
.replace('__EDIT_ON_GITHUB__', editOnGitHub(filename))
|
||||
.replace('__CONTENT__', content.toString());
|
||||
|
||||
if (analytics) {
|
||||
HTML = HTML.replace('<!-- __TRACKING__ -->', `
|
||||
@ -96,39 +111,36 @@ function toHTML({ input, filename, nodeVersion, analytics }, cb) {
|
||||
HTML = HTML.replace('__ALTDOCS__', '');
|
||||
}
|
||||
|
||||
HTML = HTML.replace('__EDIT_ON_GITHUB__', editOnGitHub(filename));
|
||||
|
||||
// Content insertion has to be the last thing we do with the lexed tokens,
|
||||
// because it's destructive.
|
||||
HTML = HTML.replace('__CONTENT__', marked.parser(lexed));
|
||||
|
||||
cb(null, HTML);
|
||||
}
|
||||
|
||||
// Set the section name based on the first header. Default to 'Index'.
|
||||
function firstHeader() {
|
||||
return (tree, file) => {
|
||||
file.section = 'Index';
|
||||
|
||||
const heading = find(tree, { type: 'heading' });
|
||||
if (heading) {
|
||||
const text = find(heading, { type: 'text' });
|
||||
if (text) file.section = text.value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Handle general body-text replacements.
|
||||
// For example, link man page references to the actual page.
|
||||
function preprocessText(lexed) {
|
||||
lexed.forEach((token) => {
|
||||
if (token.type === 'table') {
|
||||
if (token.header) {
|
||||
token.header = token.header.map(replaceInText);
|
||||
function preprocessText() {
|
||||
return (tree) => {
|
||||
visit(tree, null, (node) => {
|
||||
if (node.type === 'text' && node.value) {
|
||||
const value = linkJsTypeDocs(linkManPages(node.value));
|
||||
if (value !== node.value) {
|
||||
node.type = 'html';
|
||||
node.value = value;
|
||||
}
|
||||
|
||||
if (token.cells) {
|
||||
token.cells.forEach((row, i) => {
|
||||
token.cells[i] = row.map(replaceInText);
|
||||
});
|
||||
}
|
||||
} else if (token.text && token.type !== 'code') {
|
||||
token.text = replaceInText(token.text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Replace placeholders in text tokens.
|
||||
function replaceInText(text) {
|
||||
if (text === '') return text;
|
||||
return linkJsTypeDocs(linkManPages(text));
|
||||
};
|
||||
}
|
||||
|
||||
// Syscalls which appear in the docs, but which only exist in BSD / macOS.
|
||||
@ -172,32 +184,30 @@ function linkJsTypeDocs(text) {
|
||||
return parts.join('`');
|
||||
}
|
||||
|
||||
// Preprocess stability blockquotes and YAML blocks.
|
||||
function preprocessElements(lexed, filename) {
|
||||
// Preprocess stability blockquotes and YAML blocks
|
||||
function preprocessElements({ filename }) {
|
||||
return (tree) => {
|
||||
const STABILITY_RE = /(.*:)\s*(\d)([\s\S]*)/;
|
||||
let state = null;
|
||||
let headingIndex = -1;
|
||||
let heading = null;
|
||||
|
||||
lexed.forEach((token, index) => {
|
||||
if (token.type === 'heading') {
|
||||
visit(tree, null, (node, index) => {
|
||||
if (node.type === 'heading') {
|
||||
headingIndex = index;
|
||||
heading = token;
|
||||
}
|
||||
if (token.type === 'html' && common.isYAMLBlock(token.text)) {
|
||||
token.text = parseYAML(token.text);
|
||||
}
|
||||
if (token.type === 'blockquote_start') {
|
||||
state = 'MAYBE_STABILITY_BQ';
|
||||
lexed[index] = { type: 'space' };
|
||||
}
|
||||
if (token.type === 'blockquote_end' && state === 'MAYBE_STABILITY_BQ') {
|
||||
state = null;
|
||||
lexed[index] = { type: 'space' };
|
||||
}
|
||||
if (token.type === 'paragraph' && state === 'MAYBE_STABILITY_BQ') {
|
||||
if (token.text.includes('Stability:')) {
|
||||
const [, prefix, number, explication] = token.text.match(STABILITY_RE);
|
||||
heading = node;
|
||||
|
||||
} else if (node.type === 'html' && common.isYAMLBlock(node.value)) {
|
||||
node.value = parseYAML(node.value);
|
||||
|
||||
} else if (node.type === 'blockquote') {
|
||||
const paragraph = node.children[0].type === 'paragraph' &&
|
||||
node.children[0];
|
||||
const text = paragraph && paragraph.children[0].type === 'text' &&
|
||||
paragraph.children[0];
|
||||
if (text && text.value.includes('Stability:')) {
|
||||
const [, prefix, number, explication] =
|
||||
text.value.match(STABILITY_RE);
|
||||
|
||||
const isStabilityIndex =
|
||||
index - 2 === headingIndex || // General.
|
||||
index - 3 === headingIndex; // With api_metadata block.
|
||||
@ -210,25 +220,37 @@ function preprocessElements(lexed, filename) {
|
||||
|
||||
// Do not link to the section we are already in.
|
||||
const noLinking = filename === 'documentation' &&
|
||||
heading !== null && heading.text === 'Stability Index';
|
||||
token.text = `<div class="api_stability api_stability_${number}">` +
|
||||
heading !== null && heading.value === 'Stability Index';
|
||||
|
||||
// collapse blockquote and paragraph into a single node
|
||||
node.type = 'paragraph';
|
||||
node.children.shift();
|
||||
node.children.unshift(...paragraph.children);
|
||||
|
||||
// insert div with prefix and number
|
||||
node.children.unshift({
|
||||
type: 'html',
|
||||
value: `<div class="api_stability api_stability_${number}">` +
|
||||
(noLinking ? '' :
|
||||
'<a href="documentation.html#documentation_stability_index">') +
|
||||
`${prefix} ${number}${noLinking ? '' : '</a>'}${explication}</div>`
|
||||
.replace(/\n/g, ' ');
|
||||
`${prefix} ${number}${noLinking ? '' : '</a>'}`
|
||||
.replace(/\n/g, ' ')
|
||||
});
|
||||
|
||||
lexed[index] = { type: 'html', text: token.text };
|
||||
} else if (state === 'MAYBE_STABILITY_BQ') {
|
||||
state = null;
|
||||
lexed[index - 1] = { type: 'blockquote_start' };
|
||||
// remove prefix and number from text
|
||||
text.value = explication;
|
||||
|
||||
// close div
|
||||
node.children.push({ type: 'html', value: '</div>' });
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function parseYAML(text) {
|
||||
const meta = common.extractAndParseYAML(text);
|
||||
let html = '<div class="api_metadata">\n';
|
||||
let result = '<div class="api_metadata">\n';
|
||||
|
||||
const added = { description: '' };
|
||||
const deprecated = { description: '' };
|
||||
@ -250,25 +272,32 @@ function parseYAML(text) {
|
||||
|
||||
meta.changes.sort((a, b) => versionSort(a.version, b.version));
|
||||
|
||||
html += '<details class="changelog"><summary>History</summary>\n' +
|
||||
result += '<details class="changelog"><summary>History</summary>\n' +
|
||||
'<table>\n<tr><th>Version</th><th>Changes</th></tr>\n';
|
||||
|
||||
meta.changes.forEach((change) => {
|
||||
html += `<tr><td>${change.version}</td>\n` +
|
||||
`<td>${marked(change.description)}</td></tr>\n`;
|
||||
const description = unified()
|
||||
.use(markdown)
|
||||
.use(remark2rehype, { allowDangerousHTML: true })
|
||||
.use(raw)
|
||||
.use(html)
|
||||
.processSync(change.description).toString();
|
||||
|
||||
result += `<tr><td>${change.version}</td>\n` +
|
||||
`<td>${description}</td></tr>\n`;
|
||||
});
|
||||
|
||||
html += '</table>\n</details>\n';
|
||||
result += '</table>\n</details>\n';
|
||||
} else {
|
||||
html += `${added.description}${deprecated.description}\n`;
|
||||
result += `${added.description}${deprecated.description}\n`;
|
||||
}
|
||||
|
||||
if (meta.napiVersion) {
|
||||
html += `<span>N-API version: ${meta.napiVersion.join(', ')}</span>\n`;
|
||||
result += `<span>N-API version: ${meta.napiVersion.join(', ')}</span>\n`;
|
||||
}
|
||||
|
||||
html += '</div>';
|
||||
return html;
|
||||
result += '</div>';
|
||||
return result;
|
||||
}
|
||||
|
||||
const numberRe = /^\d*/;
|
||||
@ -282,7 +311,8 @@ function versionSort(a, b) {
|
||||
return +b.match(numberRe)[0] - +a.match(numberRe)[0];
|
||||
}
|
||||
|
||||
function buildToc(lexed, filename) {
|
||||
function buildToc({ filename }) {
|
||||
return (tree, file) => {
|
||||
const startIncludeRefRE = /^\s*<!-- \[start-include:(.+)\] -->\s*$/;
|
||||
const endIncludeRefRE = /^\s*<!-- \[end-include:.+\] -->\s*$/;
|
||||
const realFilenames = [filename];
|
||||
@ -290,40 +320,53 @@ function buildToc(lexed, filename) {
|
||||
let toc = '';
|
||||
let depth = 0;
|
||||
|
||||
lexed.forEach((token) => {
|
||||
// Keep track of the current filename along comment wrappers of inclusions.
|
||||
if (token.type === 'html') {
|
||||
const [, includedFileName] = token.text.match(startIncludeRefRE) || [];
|
||||
visit(tree, null, (node) => {
|
||||
// Keep track of the current filename for comment wrappers of inclusions.
|
||||
if (node.type === 'html') {
|
||||
const [, includedFileName] = node.value.match(startIncludeRefRE) || [];
|
||||
if (includedFileName !== undefined)
|
||||
realFilenames.unshift(includedFileName);
|
||||
else if (endIncludeRefRE.test(token.text))
|
||||
else if (endIncludeRefRE.test(node.value))
|
||||
realFilenames.shift();
|
||||
}
|
||||
|
||||
if (token.type !== 'heading') return;
|
||||
if (node.type !== 'heading') return;
|
||||
|
||||
if (token.depth - depth > 1) {
|
||||
throw new Error(`Inappropriate heading level:\n${JSON.stringify(token)}`);
|
||||
if (node.depth - depth > 1) {
|
||||
throw new Error(
|
||||
`Inappropriate heading level:\n${JSON.stringify(node)}`
|
||||
);
|
||||
}
|
||||
|
||||
depth = token.depth;
|
||||
depth = node.depth;
|
||||
const realFilename = path.basename(realFilenames[0], '.md');
|
||||
const headingText = token.text.trim();
|
||||
const headingText = node.children.map((child) => child.value)
|
||||
.join().trim();
|
||||
const id = getId(`${realFilename}_${headingText}`, idCounters);
|
||||
|
||||
const hasStability = token.stability !== undefined;
|
||||
const hasStability = node.stability !== undefined;
|
||||
toc += ' '.repeat((depth - 1) * 2) +
|
||||
(hasStability ? `* <span class="stability_${token.stability}">` : '* ') +
|
||||
`<a href="#${id}">${token.text}</a>${hasStability ? '</span>' : ''}\n`;
|
||||
(hasStability ? `* <span class="stability_${node.stability}">` : '* ') +
|
||||
`<a href="#${id}">${headingText}</a>${hasStability ? '</span>' : ''}\n`;
|
||||
|
||||
let anchor =
|
||||
`<span><a class="mark" href="#${id}" id="${id}">#</a></span>`;
|
||||
|
||||
token.text += `<span><a class="mark" href="#${id}" id="${id}">#</a></span>`;
|
||||
if (realFilename === 'errors' && headingText.startsWith('ERR_')) {
|
||||
token.text += `<span><a class="mark" href="#${headingText}" ` +
|
||||
anchor += `<span><a class="mark" href="#${headingText}" ` +
|
||||
`id="${headingText}">#</a></span>`;
|
||||
}
|
||||
|
||||
node.children.push({ type: 'html', value: anchor });
|
||||
});
|
||||
|
||||
return marked(toc);
|
||||
file.toc = unified()
|
||||
.use(markdown)
|
||||
.use(remark2rehype, { allowDangerousHTML: true })
|
||||
.use(raw)
|
||||
.use(html)
|
||||
.processSync(toc).toString();
|
||||
};
|
||||
}
|
||||
|
||||
const notAlphaNumerics = /[^a-z0-9]+/g;
|
||||
|
1
tools/doc/node_modules/.bin/esparse
generated
vendored
Symbolic link
1
tools/doc/node_modules/.bin/esparse
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../esprima/bin/esparse.js
|
1
tools/doc/node_modules/.bin/esvalidate
generated
vendored
Symbolic link
1
tools/doc/node_modules/.bin/esvalidate
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../esprima/bin/esvalidate.js
|
1
tools/doc/node_modules/.bin/js-yaml
generated
vendored
Symbolic link
1
tools/doc/node_modules/.bin/js-yaml
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../js-yaml/bin/js-yaml.js
|
21
tools/doc/node_modules/argparse/LICENSE
generated
vendored
Normal file
21
tools/doc/node_modules/argparse/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (C) 2012 by Vitaly Puzrin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
255
tools/doc/node_modules/argparse/README.md
generated
vendored
Normal file
255
tools/doc/node_modules/argparse/README.md
generated
vendored
Normal file
@ -0,0 +1,255 @@
|
||||
argparse
|
||||
========
|
||||
|
||||
[](http://travis-ci.org/nodeca/argparse)
|
||||
[](https://www.npmjs.org/package/argparse)
|
||||
|
||||
CLI arguments parser for node.js. Javascript port of python's
|
||||
[argparse](http://docs.python.org/dev/library/argparse.html) module
|
||||
(original version 3.2). That's a full port, except some very rare options,
|
||||
recorded in issue tracker.
|
||||
|
||||
**NB. Difference with original.**
|
||||
|
||||
- Method names changed to camelCase. See [generated docs](http://nodeca.github.com/argparse/).
|
||||
- Use `defaultValue` instead of `default`.
|
||||
- Use `argparse.Const.REMAINDER` instead of `argparse.REMAINDER`, and
|
||||
similarly for constant values `OPTIONAL`, `ZERO_OR_MORE`, and `ONE_OR_MORE`
|
||||
(aliases for `nargs` values `'?'`, `'*'`, `'+'`, respectively), and
|
||||
`SUPPRESS`.
|
||||
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
test.js file:
|
||||
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse example'
|
||||
});
|
||||
parser.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
help: 'foo bar'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
help: 'bar foo'
|
||||
}
|
||||
);
|
||||
parser.addArgument(
|
||||
'--baz',
|
||||
{
|
||||
help: 'baz bar'
|
||||
}
|
||||
);
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
```
|
||||
|
||||
Display help:
|
||||
|
||||
```
|
||||
$ ./test.js -h
|
||||
usage: example.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ]
|
||||
|
||||
Argparse example
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-v, --version Show program's version number and exit.
|
||||
-f FOO, --foo FOO foo bar
|
||||
-b BAR, --bar BAR bar foo
|
||||
--baz BAZ baz bar
|
||||
```
|
||||
|
||||
Parse arguments:
|
||||
|
||||
```
|
||||
$ ./test.js -f=3 --bar=4 --baz 5
|
||||
{ foo: '3', bar: '4', baz: '5' }
|
||||
```
|
||||
|
||||
More [examples](https://github.com/nodeca/argparse/tree/master/examples).
|
||||
|
||||
|
||||
ArgumentParser objects
|
||||
======================
|
||||
|
||||
```
|
||||
new ArgumentParser({parameters hash});
|
||||
```
|
||||
|
||||
Creates a new ArgumentParser object.
|
||||
|
||||
**Supported params:**
|
||||
|
||||
- ```description``` - Text to display before the argument help.
|
||||
- ```epilog``` - Text to display after the argument help.
|
||||
- ```addHelp``` - Add a -h/–help option to the parser. (default: true)
|
||||
- ```argumentDefault``` - Set the global default value for arguments. (default: null)
|
||||
- ```parents``` - A list of ArgumentParser objects whose arguments should also be included.
|
||||
- ```prefixChars``` - The set of characters that prefix optional arguments. (default: ‘-‘)
|
||||
- ```formatterClass``` - A class for customizing the help output.
|
||||
- ```prog``` - The name of the program (default: `path.basename(process.argv[1])`)
|
||||
- ```usage``` - The string describing the program usage (default: generated)
|
||||
- ```conflictHandler``` - Usually unnecessary, defines strategy for resolving conflicting optionals.
|
||||
|
||||
**Not supported yet**
|
||||
|
||||
- ```fromfilePrefixChars``` - The set of characters that prefix files from which additional arguments should be read.
|
||||
|
||||
|
||||
Details in [original ArgumentParser guide](http://docs.python.org/dev/library/argparse.html#argumentparser-objects)
|
||||
|
||||
|
||||
addArgument() method
|
||||
====================
|
||||
|
||||
```
|
||||
ArgumentParser.addArgument(name or flag or [name] or [flags...], {options})
|
||||
```
|
||||
|
||||
Defines how a single command-line argument should be parsed.
|
||||
|
||||
- ```name or flag or [name] or [flags...]``` - Either a positional name
|
||||
(e.g., `'foo'`), a single option (e.g., `'-f'` or `'--foo'`), an array
|
||||
of a single positional name (e.g., `['foo']`), or an array of options
|
||||
(e.g., `['-f', '--foo']`).
|
||||
|
||||
Options:
|
||||
|
||||
- ```action``` - The basic type of action to be taken when this argument is encountered at the command line.
|
||||
- ```nargs```- The number of command-line arguments that should be consumed.
|
||||
- ```constant``` - A constant value required by some action and nargs selections.
|
||||
- ```defaultValue``` - The value produced if the argument is absent from the command line.
|
||||
- ```type``` - The type to which the command-line argument should be converted.
|
||||
- ```choices``` - A container of the allowable values for the argument.
|
||||
- ```required``` - Whether or not the command-line option may be omitted (optionals only).
|
||||
- ```help``` - A brief description of what the argument does.
|
||||
- ```metavar``` - A name for the argument in usage messages.
|
||||
- ```dest``` - The name of the attribute to be added to the object returned by parseArgs().
|
||||
|
||||
Details in [original add_argument guide](http://docs.python.org/dev/library/argparse.html#the-add-argument-method)
|
||||
|
||||
|
||||
Action (some details)
|
||||
================
|
||||
|
||||
ArgumentParser objects associate command-line arguments with actions.
|
||||
These actions can do just about anything with the command-line arguments associated
|
||||
with them, though most actions simply add an attribute to the object returned by
|
||||
parseArgs(). The action keyword argument specifies how the command-line arguments
|
||||
should be handled. The supported actions are:
|
||||
|
||||
- ```store``` - Just stores the argument’s value. This is the default action.
|
||||
- ```storeConst``` - Stores value, specified by the const keyword argument.
|
||||
(Note that the const keyword argument defaults to the rather unhelpful None.)
|
||||
The 'storeConst' action is most commonly used with optional arguments, that
|
||||
specify some sort of flag.
|
||||
- ```storeTrue``` and ```storeFalse``` - Stores values True and False
|
||||
respectively. These are special cases of 'storeConst'.
|
||||
- ```append``` - Stores a list, and appends each argument value to the list.
|
||||
This is useful to allow an option to be specified multiple times.
|
||||
- ```appendConst``` - Stores a list, and appends value, specified by the
|
||||
const keyword argument to the list. (Note, that the const keyword argument defaults
|
||||
is None.) The 'appendConst' action is typically used when multiple arguments need
|
||||
to store constants to the same list.
|
||||
- ```count``` - Counts the number of times a keyword argument occurs. For example,
|
||||
used for increasing verbosity levels.
|
||||
- ```help``` - Prints a complete help message for all the options in the current
|
||||
parser and then exits. By default a help action is automatically added to the parser.
|
||||
See ArgumentParser for details of how the output is created.
|
||||
- ```version``` - Prints version information and exit. Expects a `version=`
|
||||
keyword argument in the addArgument() call.
|
||||
|
||||
Details in [original action guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||
|
||||
|
||||
Sub-commands
|
||||
============
|
||||
|
||||
ArgumentParser.addSubparsers()
|
||||
|
||||
Many programs split their functionality into a number of sub-commands, for
|
||||
example, the svn program can invoke sub-commands like `svn checkout`, `svn update`,
|
||||
and `svn commit`. Splitting up functionality this way can be a particularly good
|
||||
idea when a program performs several different functions which require different
|
||||
kinds of command-line arguments. `ArgumentParser` supports creation of such
|
||||
sub-commands with `addSubparsers()` method. The `addSubparsers()` method is
|
||||
normally called with no arguments and returns an special action object.
|
||||
This object has a single method `addParser()`, which takes a command name and
|
||||
any `ArgumentParser` constructor arguments, and returns an `ArgumentParser` object
|
||||
that can be modified as usual.
|
||||
|
||||
Example:
|
||||
|
||||
sub_commands.js
|
||||
```javascript
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var ArgumentParser = require('../lib/argparse').ArgumentParser;
|
||||
var parser = new ArgumentParser({
|
||||
version: '0.0.1',
|
||||
addHelp:true,
|
||||
description: 'Argparse examples: sub-commands',
|
||||
});
|
||||
|
||||
var subparsers = parser.addSubparsers({
|
||||
title:'subcommands',
|
||||
dest:"subcommand_name"
|
||||
});
|
||||
|
||||
var bar = subparsers.addParser('c1', {addHelp:true});
|
||||
bar.addArgument(
|
||||
[ '-f', '--foo' ],
|
||||
{
|
||||
action: 'store',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
var bar = subparsers.addParser(
|
||||
'c2',
|
||||
{aliases:['co'], addHelp:true}
|
||||
);
|
||||
bar.addArgument(
|
||||
[ '-b', '--bar' ],
|
||||
{
|
||||
action: 'store',
|
||||
type: 'int',
|
||||
help: 'foo3 bar3'
|
||||
}
|
||||
);
|
||||
|
||||
var args = parser.parseArgs();
|
||||
console.dir(args);
|
||||
|
||||
```
|
||||
|
||||
Details in [original sub-commands guide](http://docs.python.org/dev/library/argparse.html#sub-commands)
|
||||
|
||||
|
||||
Contributors
|
||||
============
|
||||
|
||||
- [Eugene Shkuropat](https://github.com/shkuropat)
|
||||
- [Paul Jacobson](https://github.com/hpaulj)
|
||||
|
||||
[others](https://github.com/nodeca/argparse/graphs/contributors)
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
Copyright (c) 2012 [Vitaly Puzrin](https://github.com/puzrin).
|
||||
Released under the MIT license. See
|
||||
[LICENSE](https://github.com/nodeca/argparse/blob/master/LICENSE) for details.
|
3
tools/doc/node_modules/argparse/index.js
generated
vendored
Normal file
3
tools/doc/node_modules/argparse/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./lib/argparse');
|
146
tools/doc/node_modules/argparse/lib/action.js
generated
vendored
Normal file
146
tools/doc/node_modules/argparse/lib/action.js
generated
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
/**
|
||||
* class Action
|
||||
*
|
||||
* Base class for all actions
|
||||
* Do not call in your code, use this class only for inherits your own action
|
||||
*
|
||||
* Information about how to convert command line strings to Javascript objects.
|
||||
* Action objects are used by an ArgumentParser to represent the information
|
||||
* needed to parse a single argument from one or more strings from the command
|
||||
* line. The keyword arguments to the Action constructor are also all attributes
|
||||
* of Action instances.
|
||||
*
|
||||
* ##### Allowed keywords:
|
||||
*
|
||||
* - `store`
|
||||
* - `storeConstant`
|
||||
* - `storeTrue`
|
||||
* - `storeFalse`
|
||||
* - `append`
|
||||
* - `appendConstant`
|
||||
* - `count`
|
||||
* - `help`
|
||||
* - `version`
|
||||
*
|
||||
* Information about action options see [[Action.new]]
|
||||
*
|
||||
* See also [original guide](http://docs.python.org/dev/library/argparse.html#action)
|
||||
*
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
// Constants
|
||||
var c = require('./const');
|
||||
|
||||
|
||||
/**
|
||||
* new Action(options)
|
||||
*
|
||||
* Base class for all actions. Used only for inherits
|
||||
*
|
||||
*
|
||||
* ##### Options:
|
||||
*
|
||||
* - `optionStrings` A list of command-line option strings for the action.
|
||||
* - `dest` Attribute to hold the created object(s)
|
||||
* - `nargs` The number of command-line arguments that should be consumed.
|
||||
* By default, one argument will be consumed and a single value will be
|
||||
* produced.
|
||||
* - `constant` Default value for an action with no value.
|
||||
* - `defaultValue` The value to be produced if the option is not specified.
|
||||
* - `type` Cast to 'string'|'int'|'float'|'complex'|function (string). If
|
||||
* None, 'string'.
|
||||
* - `choices` The choices available.
|
||||
* - `required` True if the action must always be specified at the command
|
||||
* line.
|
||||
* - `help` The help describing the argument.
|
||||
* - `metavar` The name to be used for the option's argument with the help
|
||||
* string. If None, the 'dest' value will be used as the name.
|
||||
*
|
||||
* ##### nargs supported values:
|
||||
*
|
||||
* - `N` (an integer) consumes N arguments (and produces a list)
|
||||
* - `?` consumes zero or one arguments
|
||||
* - `*` consumes zero or more arguments (and produces a list)
|
||||
* - `+` consumes one or more arguments (and produces a list)
|
||||
*
|
||||
* Note: that the difference between the default and nargs=1 is that with the
|
||||
* default, a single value will be produced, while with nargs=1, a list
|
||||
* containing a single value will be produced.
|
||||
**/
|
||||
var Action = module.exports = function Action(options) {
|
||||
options = options || {};
|
||||
this.optionStrings = options.optionStrings || [];
|
||||
this.dest = options.dest;
|
||||
this.nargs = typeof options.nargs !== 'undefined' ? options.nargs : null;
|
||||
this.constant = typeof options.constant !== 'undefined' ? options.constant : null;
|
||||
this.defaultValue = options.defaultValue;
|
||||
this.type = typeof options.type !== 'undefined' ? options.type : null;
|
||||
this.choices = typeof options.choices !== 'undefined' ? options.choices : null;
|
||||
this.required = typeof options.required !== 'undefined' ? options.required : false;
|
||||
this.help = typeof options.help !== 'undefined' ? options.help : null;
|
||||
this.metavar = typeof options.metavar !== 'undefined' ? options.metavar : null;
|
||||
|
||||
if (!(this.optionStrings instanceof Array)) {
|
||||
throw new Error('optionStrings should be an array');
|
||||
}
|
||||
if (typeof this.required !== 'undefined' && typeof this.required !== 'boolean') {
|
||||
throw new Error('required should be a boolean');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#getName -> String
|
||||
*
|
||||
* Tells action name
|
||||
**/
|
||||
Action.prototype.getName = function () {
|
||||
if (this.optionStrings.length > 0) {
|
||||
return this.optionStrings.join('/');
|
||||
} else if (this.metavar !== null && this.metavar !== c.SUPPRESS) {
|
||||
return this.metavar;
|
||||
} else if (typeof this.dest !== 'undefined' && this.dest !== c.SUPPRESS) {
|
||||
return this.dest;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#isOptional -> Boolean
|
||||
*
|
||||
* Return true if optional
|
||||
**/
|
||||
Action.prototype.isOptional = function () {
|
||||
return !this.isPositional();
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#isPositional -> Boolean
|
||||
*
|
||||
* Return true if positional
|
||||
**/
|
||||
Action.prototype.isPositional = function () {
|
||||
return (this.optionStrings.length === 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Action#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Should be implemented in inherited classes
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* ActionCount.prototype.call = function (parser, namespace, values, optionString) {
|
||||
* namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
|
||||
* };
|
||||
*
|
||||
**/
|
||||
Action.prototype.call = function () {
|
||||
throw new Error('.call() not defined');// Not Implemented error
|
||||
};
|
53
tools/doc/node_modules/argparse/lib/action/append.js
generated
vendored
Normal file
53
tools/doc/node_modules/argparse/lib/action/append.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/*:nodoc:*
|
||||
* class ActionAppend
|
||||
*
|
||||
* This action stores a list, and appends each argument value to the list.
|
||||
* This is useful to allow an option to be specified multiple times.
|
||||
* This class inherided from [[Action]]
|
||||
*
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionAppend(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
* Note: options.nargs should be optional for constants
|
||||
* and more then zero for other
|
||||
**/
|
||||
var ActionAppend = module.exports = function ActionAppend(options) {
|
||||
options = options || {};
|
||||
if (this.nargs <= 0) {
|
||||
throw new Error('nargs for append actions must be > 0; if arg ' +
|
||||
'strings are not supplying the value to append, ' +
|
||||
'the append const action may be more appropriate');
|
||||
}
|
||||
if (!!this.constant && this.nargs !== c.OPTIONAL) {
|
||||
throw new Error('nargs must be OPTIONAL to supply const');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionAppend, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionAppend#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionAppend.prototype.call = function (parser, namespace, values) {
|
||||
var items = (namespace[this.dest] || []).slice();
|
||||
items.push(values);
|
||||
namespace.set(this.dest, items);
|
||||
};
|
47
tools/doc/node_modules/argparse/lib/action/append/constant.js
generated
vendored
Normal file
47
tools/doc/node_modules/argparse/lib/action/append/constant.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/*:nodoc:*
|
||||
* class ActionAppendConstant
|
||||
*
|
||||
* This stores a list, and appends the value specified by
|
||||
* the const keyword argument to the list.
|
||||
* (Note that the const keyword argument defaults to null.)
|
||||
* The 'appendConst' action is typically useful when multiple
|
||||
* arguments need to store constants to the same list.
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../../action');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionAppendConstant(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionAppendConstant = module.exports = function ActionAppendConstant(options) {
|
||||
options = options || {};
|
||||
options.nargs = 0;
|
||||
if (typeof options.constant === 'undefined') {
|
||||
throw new Error('constant option is required for appendAction');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionAppendConstant, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionAppendConstant#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionAppendConstant.prototype.call = function (parser, namespace) {
|
||||
var items = [].concat(namespace[this.dest] || []);
|
||||
items.push(this.constant);
|
||||
namespace.set(this.dest, items);
|
||||
};
|
40
tools/doc/node_modules/argparse/lib/action/count.js
generated
vendored
Normal file
40
tools/doc/node_modules/argparse/lib/action/count.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
/*:nodoc:*
|
||||
* class ActionCount
|
||||
*
|
||||
* This counts the number of times a keyword argument occurs.
|
||||
* For example, this is useful for increasing verbosity levels
|
||||
*
|
||||
* This class inherided from [[Action]]
|
||||
*
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionCount(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionCount = module.exports = function ActionCount(options) {
|
||||
options = options || {};
|
||||
options.nargs = 0;
|
||||
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionCount, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionCount#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionCount.prototype.call = function (parser, namespace) {
|
||||
namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
|
||||
};
|
47
tools/doc/node_modules/argparse/lib/action/help.js
generated
vendored
Normal file
47
tools/doc/node_modules/argparse/lib/action/help.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/*:nodoc:*
|
||||
* class ActionHelp
|
||||
*
|
||||
* Support action for printing help
|
||||
* This class inherided from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionHelp(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionHelp = module.exports = function ActionHelp(options) {
|
||||
options = options || {};
|
||||
if (options.defaultValue !== null) {
|
||||
options.defaultValue = options.defaultValue;
|
||||
} else {
|
||||
options.defaultValue = c.SUPPRESS;
|
||||
}
|
||||
options.dest = (options.dest !== null ? options.dest : c.SUPPRESS);
|
||||
options.nargs = 0;
|
||||
Action.call(this, options);
|
||||
|
||||
};
|
||||
util.inherits(ActionHelp, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionHelp#call(parser, namespace, values, optionString)
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Print help and exit
|
||||
**/
|
||||
ActionHelp.prototype.call = function (parser) {
|
||||
parser.printHelp();
|
||||
parser.exit();
|
||||
};
|
50
tools/doc/node_modules/argparse/lib/action/store.js
generated
vendored
Normal file
50
tools/doc/node_modules/argparse/lib/action/store.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
/*:nodoc:*
|
||||
* class ActionStore
|
||||
*
|
||||
* This action just stores the argument’s value. This is the default action.
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
*
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStore(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStore = module.exports = function ActionStore(options) {
|
||||
options = options || {};
|
||||
if (this.nargs <= 0) {
|
||||
throw new Error('nargs for store actions must be > 0; if you ' +
|
||||
'have nothing to store, actions such as store ' +
|
||||
'true or store const may be more appropriate');
|
||||
|
||||
}
|
||||
if (typeof this.constant !== 'undefined' && this.nargs !== c.OPTIONAL) {
|
||||
throw new Error('nargs must be OPTIONAL to supply const');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStore, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionStore#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionStore.prototype.call = function (parser, namespace, values) {
|
||||
namespace.set(this.dest, values);
|
||||
};
|
43
tools/doc/node_modules/argparse/lib/action/store/constant.js
generated
vendored
Normal file
43
tools/doc/node_modules/argparse/lib/action/store/constant.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
/*:nodoc:*
|
||||
* class ActionStoreConstant
|
||||
*
|
||||
* This action stores the value specified by the const keyword argument.
|
||||
* (Note that the const keyword argument defaults to the rather unhelpful null.)
|
||||
* The 'store_const' action is most commonly used with optional
|
||||
* arguments that specify some sort of flag.
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../../action');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStoreConstant(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStoreConstant = module.exports = function ActionStoreConstant(options) {
|
||||
options = options || {};
|
||||
options.nargs = 0;
|
||||
if (typeof options.constant === 'undefined') {
|
||||
throw new Error('constant option is required for storeAction');
|
||||
}
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStoreConstant, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionStoreConstant#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Save result in namespace object
|
||||
**/
|
||||
ActionStoreConstant.prototype.call = function (parser, namespace) {
|
||||
namespace.set(this.dest, this.constant);
|
||||
};
|
27
tools/doc/node_modules/argparse/lib/action/store/false.js
generated
vendored
Normal file
27
tools/doc/node_modules/argparse/lib/action/store/false.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/*:nodoc:*
|
||||
* class ActionStoreFalse
|
||||
*
|
||||
* This action store the values False respectively.
|
||||
* This is special cases of 'storeConst'
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ActionStoreConstant = require('./constant');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStoreFalse(options)
|
||||
* - options (object): hash of options see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStoreFalse = module.exports = function ActionStoreFalse(options) {
|
||||
options = options || {};
|
||||
options.constant = false;
|
||||
options.defaultValue = options.defaultValue !== null ? options.defaultValue : true;
|
||||
ActionStoreConstant.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStoreFalse, ActionStoreConstant);
|
26
tools/doc/node_modules/argparse/lib/action/store/true.js
generated
vendored
Normal file
26
tools/doc/node_modules/argparse/lib/action/store/true.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
/*:nodoc:*
|
||||
* class ActionStoreTrue
|
||||
*
|
||||
* This action store the values True respectively.
|
||||
* This isspecial cases of 'storeConst'
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ActionStoreConstant = require('./constant');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionStoreTrue(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionStoreTrue = module.exports = function ActionStoreTrue(options) {
|
||||
options = options || {};
|
||||
options.constant = true;
|
||||
options.defaultValue = options.defaultValue !== null ? options.defaultValue : false;
|
||||
ActionStoreConstant.call(this, options);
|
||||
};
|
||||
util.inherits(ActionStoreTrue, ActionStoreConstant);
|
149
tools/doc/node_modules/argparse/lib/action/subparsers.js
generated
vendored
Normal file
149
tools/doc/node_modules/argparse/lib/action/subparsers.js
generated
vendored
Normal file
@ -0,0 +1,149 @@
|
||||
/** internal
|
||||
* class ActionSubparsers
|
||||
*
|
||||
* Support the creation of such sub-commands with the addSubparsers()
|
||||
*
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var format = require('util').format;
|
||||
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
// Errors
|
||||
var argumentErrorHelper = require('../argument/error');
|
||||
|
||||
|
||||
/*:nodoc:*
|
||||
* new ChoicesPseudoAction(name, help)
|
||||
*
|
||||
* Create pseudo action for correct help text
|
||||
*
|
||||
**/
|
||||
function ChoicesPseudoAction(name, help) {
|
||||
var options = {
|
||||
optionStrings: [],
|
||||
dest: name,
|
||||
help: help
|
||||
};
|
||||
|
||||
Action.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(ChoicesPseudoAction, Action);
|
||||
|
||||
/**
|
||||
* new ActionSubparsers(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
function ActionSubparsers(options) {
|
||||
options = options || {};
|
||||
options.dest = options.dest || c.SUPPRESS;
|
||||
options.nargs = c.PARSER;
|
||||
|
||||
this.debug = (options.debug === true);
|
||||
|
||||
this._progPrefix = options.prog;
|
||||
this._parserClass = options.parserClass;
|
||||
this._nameParserMap = {};
|
||||
this._choicesActions = [];
|
||||
|
||||
options.choices = this._nameParserMap;
|
||||
Action.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(ActionSubparsers, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionSubparsers#addParser(name, options) -> ArgumentParser
|
||||
* - name (string): sub-command name
|
||||
* - options (object): see [[ArgumentParser.new]]
|
||||
*
|
||||
* Note:
|
||||
* addParser supports an additional aliases option,
|
||||
* which allows multiple strings to refer to the same subparser.
|
||||
* This example, like svn, aliases co as a shorthand for checkout
|
||||
*
|
||||
**/
|
||||
ActionSubparsers.prototype.addParser = function (name, options) {
|
||||
var parser;
|
||||
|
||||
var self = this;
|
||||
|
||||
options = options || {};
|
||||
|
||||
options.debug = (this.debug === true);
|
||||
|
||||
// set program from the existing prefix
|
||||
if (!options.prog) {
|
||||
options.prog = this._progPrefix + ' ' + name;
|
||||
}
|
||||
|
||||
var aliases = options.aliases || [];
|
||||
|
||||
// create a pseudo-action to hold the choice help
|
||||
if (!!options.help || typeof options.help === 'string') {
|
||||
var help = options.help;
|
||||
delete options.help;
|
||||
|
||||
var choiceAction = new ChoicesPseudoAction(name, help);
|
||||
this._choicesActions.push(choiceAction);
|
||||
}
|
||||
|
||||
// create the parser and add it to the map
|
||||
parser = new this._parserClass(options);
|
||||
this._nameParserMap[name] = parser;
|
||||
|
||||
// make parser available under aliases also
|
||||
aliases.forEach(function (alias) {
|
||||
self._nameParserMap[alias] = parser;
|
||||
});
|
||||
|
||||
return parser;
|
||||
};
|
||||
|
||||
ActionSubparsers.prototype._getSubactions = function () {
|
||||
return this._choicesActions;
|
||||
};
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionSubparsers#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Call the action. Parse input aguments
|
||||
**/
|
||||
ActionSubparsers.prototype.call = function (parser, namespace, values) {
|
||||
var parserName = values[0];
|
||||
var argStrings = values.slice(1);
|
||||
|
||||
// set the parser name if requested
|
||||
if (this.dest !== c.SUPPRESS) {
|
||||
namespace[this.dest] = parserName;
|
||||
}
|
||||
|
||||
// select the parser
|
||||
if (this._nameParserMap[parserName]) {
|
||||
parser = this._nameParserMap[parserName];
|
||||
} else {
|
||||
throw argumentErrorHelper(format(
|
||||
'Unknown parser "%s" (choices: [%s]).',
|
||||
parserName,
|
||||
Object.keys(this._nameParserMap).join(', ')
|
||||
));
|
||||
}
|
||||
|
||||
// parse all the remaining options into the namespace
|
||||
parser.parseArgs(argStrings, namespace);
|
||||
};
|
||||
|
||||
module.exports = ActionSubparsers;
|
47
tools/doc/node_modules/argparse/lib/action/version.js
generated
vendored
Normal file
47
tools/doc/node_modules/argparse/lib/action/version.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/*:nodoc:*
|
||||
* class ActionVersion
|
||||
*
|
||||
* Support action for printing program version
|
||||
* This class inherited from [[Action]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var Action = require('../action');
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
var c = require('../const');
|
||||
|
||||
/*:nodoc:*
|
||||
* new ActionVersion(options)
|
||||
* - options (object): options hash see [[Action.new]]
|
||||
*
|
||||
**/
|
||||
var ActionVersion = module.exports = function ActionVersion(options) {
|
||||
options = options || {};
|
||||
options.defaultValue = (options.defaultValue ? options.defaultValue : c.SUPPRESS);
|
||||
options.dest = (options.dest || c.SUPPRESS);
|
||||
options.nargs = 0;
|
||||
this.version = options.version;
|
||||
Action.call(this, options);
|
||||
};
|
||||
util.inherits(ActionVersion, Action);
|
||||
|
||||
/*:nodoc:*
|
||||
* ActionVersion#call(parser, namespace, values, optionString) -> Void
|
||||
* - parser (ArgumentParser): current parser
|
||||
* - namespace (Namespace): namespace for output data
|
||||
* - values (Array): parsed values
|
||||
* - optionString (Array): input option string(not parsed)
|
||||
*
|
||||
* Print version and exit
|
||||
**/
|
||||
ActionVersion.prototype.call = function (parser) {
|
||||
var version = this.version || parser.version;
|
||||
var formatter = parser._getFormatter();
|
||||
formatter.addText(version);
|
||||
parser.exit(0, formatter.formatHelp());
|
||||
};
|
482
tools/doc/node_modules/argparse/lib/action_container.js
generated
vendored
Normal file
482
tools/doc/node_modules/argparse/lib/action_container.js
generated
vendored
Normal file
@ -0,0 +1,482 @@
|
||||
/** internal
|
||||
* class ActionContainer
|
||||
*
|
||||
* Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]]
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
var format = require('util').format;
|
||||
|
||||
// Constants
|
||||
var c = require('./const');
|
||||
|
||||
var $$ = require('./utils');
|
||||
|
||||
//Actions
|
||||
var ActionHelp = require('./action/help');
|
||||
var ActionAppend = require('./action/append');
|
||||
var ActionAppendConstant = require('./action/append/constant');
|
||||
var ActionCount = require('./action/count');
|
||||
var ActionStore = require('./action/store');
|
||||
var ActionStoreConstant = require('./action/store/constant');
|
||||
var ActionStoreTrue = require('./action/store/true');
|
||||
var ActionStoreFalse = require('./action/store/false');
|
||||
var ActionVersion = require('./action/version');
|
||||
var ActionSubparsers = require('./action/subparsers');
|
||||
|
||||
// Errors
|
||||
var argumentErrorHelper = require('./argument/error');
|
||||
|
||||
/**
|
||||
* new ActionContainer(options)
|
||||
*
|
||||
* Action container. Parent for [[ArgumentParser]] and [[ArgumentGroup]]
|
||||
*
|
||||
* ##### Options:
|
||||
*
|
||||
* - `description` -- A description of what the program does
|
||||
* - `prefixChars` -- Characters that prefix optional arguments
|
||||
* - `argumentDefault` -- The default value for all arguments
|
||||
* - `conflictHandler` -- The conflict handler to use for duplicate arguments
|
||||
**/
|
||||
var ActionContainer = module.exports = function ActionContainer(options) {
|
||||
options = options || {};
|
||||
|
||||
this.description = options.description;
|
||||
this.argumentDefault = options.argumentDefault;
|
||||
this.prefixChars = options.prefixChars || '';
|
||||
this.conflictHandler = options.conflictHandler;
|
||||
|
||||
// set up registries
|
||||
this._registries = {};
|
||||
|
||||
// register actions
|
||||
this.register('action', null, ActionStore);
|
||||
this.register('action', 'store', ActionStore);
|
||||
this.register('action', 'storeConst', ActionStoreConstant);
|
||||
this.register('action', 'storeTrue', ActionStoreTrue);
|
||||
this.register('action', 'storeFalse', ActionStoreFalse);
|
||||
this.register('action', 'append', ActionAppend);
|
||||
this.register('action', 'appendConst', ActionAppendConstant);
|
||||
this.register('action', 'count', ActionCount);
|
||||
this.register('action', 'help', ActionHelp);
|
||||
this.register('action', 'version', ActionVersion);
|
||||
this.register('action', 'parsers', ActionSubparsers);
|
||||
|
||||
// raise an exception if the conflict handler is invalid
|
||||
this._getHandler();
|
||||
|
||||
// action storage
|
||||
this._actions = [];
|
||||
this._optionStringActions = {};
|
||||
|
||||
// groups
|
||||
this._actionGroups = [];
|
||||
this._mutuallyExclusiveGroups = [];
|
||||
|
||||
// defaults storage
|
||||
this._defaults = {};
|
||||
|
||||
// determines whether an "option" looks like a negative number
|
||||
// -1, -1.5 -5e+4
|
||||
this._regexpNegativeNumber = new RegExp('^[-]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$');
|
||||
|
||||
// whether or not there are any optionals that look like negative
|
||||
// numbers -- uses a list so it can be shared and edited
|
||||
this._hasNegativeNumberOptionals = [];
|
||||
};
|
||||
|
||||
// Groups must be required, then ActionContainer already defined
|
||||
var ArgumentGroup = require('./argument/group');
|
||||
var MutuallyExclusiveGroup = require('./argument/exclusive');
|
||||
|
||||
//
|
||||
// Registration methods
|
||||
//
|
||||
|
||||
/**
|
||||
* ActionContainer#register(registryName, value, object) -> Void
|
||||
* - registryName (String) : object type action|type
|
||||
* - value (string) : keyword
|
||||
* - object (Object|Function) : handler
|
||||
*
|
||||
* Register handlers
|
||||
**/
|
||||
ActionContainer.prototype.register = function (registryName, value, object) {
|
||||
this._registries[registryName] = this._registries[registryName] || {};
|
||||
this._registries[registryName][value] = object;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._registryGet = function (registryName, value, defaultValue) {
|
||||
if (arguments.length < 3) {
|
||||
defaultValue = null;
|
||||
}
|
||||
return this._registries[registryName][value] || defaultValue;
|
||||
};
|
||||
|
||||
//
|
||||
// Namespace default accessor methods
|
||||
//
|
||||
|
||||
/**
|
||||
* ActionContainer#setDefaults(options) -> Void
|
||||
* - options (object):hash of options see [[Action.new]]
|
||||
*
|
||||
* Set defaults
|
||||
**/
|
||||
ActionContainer.prototype.setDefaults = function (options) {
|
||||
options = options || {};
|
||||
for (var property in options) {
|
||||
if ($$.has(options, property)) {
|
||||
this._defaults[property] = options[property];
|
||||
}
|
||||
}
|
||||
|
||||
// if these defaults match any existing arguments, replace the previous
|
||||
// default on the object with the new one
|
||||
this._actions.forEach(function (action) {
|
||||
if ($$.has(options, action.dest)) {
|
||||
action.defaultValue = options[action.dest];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* ActionContainer#getDefault(dest) -> Mixed
|
||||
* - dest (string): action destination
|
||||
*
|
||||
* Return action default value
|
||||
**/
|
||||
ActionContainer.prototype.getDefault = function (dest) {
|
||||
var result = $$.has(this._defaults, dest) ? this._defaults[dest] : null;
|
||||
|
||||
this._actions.forEach(function (action) {
|
||||
if (action.dest === dest && $$.has(action, 'defaultValue')) {
|
||||
result = action.defaultValue;
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
//
|
||||
// Adding argument actions
|
||||
//
|
||||
|
||||
/**
|
||||
* ActionContainer#addArgument(args, options) -> Object
|
||||
* - args (String|Array): argument key, or array of argument keys
|
||||
* - options (Object): action objects see [[Action.new]]
|
||||
*
|
||||
* #### Examples
|
||||
* - addArgument([ '-f', '--foo' ], { action: 'store', defaultValue: 1, ... })
|
||||
* - addArgument([ 'bar' ], { action: 'store', nargs: 1, ... })
|
||||
* - addArgument('--baz', { action: 'store', nargs: 1, ... })
|
||||
**/
|
||||
ActionContainer.prototype.addArgument = function (args, options) {
|
||||
args = args;
|
||||
options = options || {};
|
||||
|
||||
if (typeof args === 'string') {
|
||||
args = [ args ];
|
||||
}
|
||||
if (!Array.isArray(args)) {
|
||||
throw new TypeError('addArgument first argument should be a string or an array');
|
||||
}
|
||||
if (typeof options !== 'object' || Array.isArray(options)) {
|
||||
throw new TypeError('addArgument second argument should be a hash');
|
||||
}
|
||||
|
||||
// if no positional args are supplied or only one is supplied and
|
||||
// it doesn't look like an option string, parse a positional argument
|
||||
if (!args || args.length === 1 && this.prefixChars.indexOf(args[0][0]) < 0) {
|
||||
if (args && !!options.dest) {
|
||||
throw new Error('dest supplied twice for positional argument');
|
||||
}
|
||||
options = this._getPositional(args, options);
|
||||
|
||||
// otherwise, we're adding an optional argument
|
||||
} else {
|
||||
options = this._getOptional(args, options);
|
||||
}
|
||||
|
||||
// if no default was supplied, use the parser-level default
|
||||
if (typeof options.defaultValue === 'undefined') {
|
||||
var dest = options.dest;
|
||||
if ($$.has(this._defaults, dest)) {
|
||||
options.defaultValue = this._defaults[dest];
|
||||
} else if (typeof this.argumentDefault !== 'undefined') {
|
||||
options.defaultValue = this.argumentDefault;
|
||||
}
|
||||
}
|
||||
|
||||
// create the action object, and add it to the parser
|
||||
var ActionClass = this._popActionClass(options);
|
||||
if (typeof ActionClass !== 'function') {
|
||||
throw new Error(format('Unknown action "%s".', ActionClass));
|
||||
}
|
||||
var action = new ActionClass(options);
|
||||
|
||||
// throw an error if the action type is not callable
|
||||
var typeFunction = this._registryGet('type', action.type, action.type);
|
||||
if (typeof typeFunction !== 'function') {
|
||||
throw new Error(format('"%s" is not callable', typeFunction));
|
||||
}
|
||||
|
||||
return this._addAction(action);
|
||||
};
|
||||
|
||||
/**
|
||||
* ActionContainer#addArgumentGroup(options) -> ArgumentGroup
|
||||
* - options (Object): hash of options see [[ArgumentGroup.new]]
|
||||
*
|
||||
* Create new arguments groups
|
||||
**/
|
||||
ActionContainer.prototype.addArgumentGroup = function (options) {
|
||||
var group = new ArgumentGroup(this, options);
|
||||
this._actionGroups.push(group);
|
||||
return group;
|
||||
};
|
||||
|
||||
/**
|
||||
* ActionContainer#addMutuallyExclusiveGroup(options) -> ArgumentGroup
|
||||
* - options (Object): {required: false}
|
||||
*
|
||||
* Create new mutual exclusive groups
|
||||
**/
|
||||
ActionContainer.prototype.addMutuallyExclusiveGroup = function (options) {
|
||||
var group = new MutuallyExclusiveGroup(this, options);
|
||||
this._mutuallyExclusiveGroups.push(group);
|
||||
return group;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._addAction = function (action) {
|
||||
var self = this;
|
||||
|
||||
// resolve any conflicts
|
||||
this._checkConflict(action);
|
||||
|
||||
// add to actions list
|
||||
this._actions.push(action);
|
||||
action.container = this;
|
||||
|
||||
// index the action by any option strings it has
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
self._optionStringActions[optionString] = action;
|
||||
});
|
||||
|
||||
// set the flag if any option strings look like negative numbers
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
if (optionString.match(self._regexpNegativeNumber)) {
|
||||
if (!self._hasNegativeNumberOptionals.some(Boolean)) {
|
||||
self._hasNegativeNumberOptionals.push(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// return the created action
|
||||
return action;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._removeAction = function (action) {
|
||||
var actionIndex = this._actions.indexOf(action);
|
||||
if (actionIndex >= 0) {
|
||||
this._actions.splice(actionIndex, 1);
|
||||
}
|
||||
};
|
||||
|
||||
ActionContainer.prototype._addContainerActions = function (container) {
|
||||
// collect groups by titles
|
||||
var titleGroupMap = {};
|
||||
this._actionGroups.forEach(function (group) {
|
||||
if (titleGroupMap[group.title]) {
|
||||
throw new Error(format('Cannot merge actions - two groups are named "%s".', group.title));
|
||||
}
|
||||
titleGroupMap[group.title] = group;
|
||||
});
|
||||
|
||||
// map each action to its group
|
||||
var groupMap = {};
|
||||
function actionHash(action) {
|
||||
// unique (hopefully?) string suitable as dictionary key
|
||||
return action.getName();
|
||||
}
|
||||
container._actionGroups.forEach(function (group) {
|
||||
// if a group with the title exists, use that, otherwise
|
||||
// create a new group matching the container's group
|
||||
if (!titleGroupMap[group.title]) {
|
||||
titleGroupMap[group.title] = this.addArgumentGroup({
|
||||
title: group.title,
|
||||
description: group.description
|
||||
});
|
||||
}
|
||||
|
||||
// map the actions to their new group
|
||||
group._groupActions.forEach(function (action) {
|
||||
groupMap[actionHash(action)] = titleGroupMap[group.title];
|
||||
});
|
||||
}, this);
|
||||
|
||||
// add container's mutually exclusive groups
|
||||
// NOTE: if add_mutually_exclusive_group ever gains title= and
|
||||
// description= then this code will need to be expanded as above
|
||||
var mutexGroup;
|
||||
container._mutuallyExclusiveGroups.forEach(function (group) {
|
||||
mutexGroup = this.addMutuallyExclusiveGroup({
|
||||
required: group.required
|
||||
});
|
||||
// map the actions to their new mutex group
|
||||
group._groupActions.forEach(function (action) {
|
||||
groupMap[actionHash(action)] = mutexGroup;
|
||||
});
|
||||
}, this); // forEach takes a 'this' argument
|
||||
|
||||
// add all actions to this container or their group
|
||||
container._actions.forEach(function (action) {
|
||||
var key = actionHash(action);
|
||||
if (groupMap[key]) {
|
||||
groupMap[key]._addAction(action);
|
||||
} else {
|
||||
this._addAction(action);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
ActionContainer.prototype._getPositional = function (dest, options) {
|
||||
if (Array.isArray(dest)) {
|
||||
dest = dest[0];
|
||||
}
|
||||
// make sure required is not specified
|
||||
if (options.required) {
|
||||
throw new Error('"required" is an invalid argument for positionals.');
|
||||
}
|
||||
|
||||
// mark positional arguments as required if at least one is
|
||||
// always required
|
||||
if (options.nargs !== c.OPTIONAL && options.nargs !== c.ZERO_OR_MORE) {
|
||||
options.required = true;
|
||||
}
|
||||
if (options.nargs === c.ZERO_OR_MORE && typeof options.defaultValue === 'undefined') {
|
||||
options.required = true;
|
||||
}
|
||||
|
||||
// return the keyword arguments with no option strings
|
||||
options.dest = dest;
|
||||
options.optionStrings = [];
|
||||
return options;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._getOptional = function (args, options) {
|
||||
var prefixChars = this.prefixChars;
|
||||
var optionStrings = [];
|
||||
var optionStringsLong = [];
|
||||
|
||||
// determine short and long option strings
|
||||
args.forEach(function (optionString) {
|
||||
// error on strings that don't start with an appropriate prefix
|
||||
if (prefixChars.indexOf(optionString[0]) < 0) {
|
||||
throw new Error(format('Invalid option string "%s": must start with a "%s".',
|
||||
optionString,
|
||||
prefixChars
|
||||
));
|
||||
}
|
||||
|
||||
// strings starting with two prefix characters are long options
|
||||
optionStrings.push(optionString);
|
||||
if (optionString.length > 1 && prefixChars.indexOf(optionString[1]) >= 0) {
|
||||
optionStringsLong.push(optionString);
|
||||
}
|
||||
});
|
||||
|
||||
// infer dest, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
|
||||
var dest = options.dest || null;
|
||||
delete options.dest;
|
||||
|
||||
if (!dest) {
|
||||
var optionStringDest = optionStringsLong.length ? optionStringsLong[0] : optionStrings[0];
|
||||
dest = $$.trimChars(optionStringDest, this.prefixChars);
|
||||
|
||||
if (dest.length === 0) {
|
||||
throw new Error(
|
||||
format('dest= is required for options like "%s"', optionStrings.join(', '))
|
||||
);
|
||||
}
|
||||
dest = dest.replace(/-/g, '_');
|
||||
}
|
||||
|
||||
// return the updated keyword arguments
|
||||
options.dest = dest;
|
||||
options.optionStrings = optionStrings;
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._popActionClass = function (options, defaultValue) {
|
||||
defaultValue = defaultValue || null;
|
||||
|
||||
var action = (options.action || defaultValue);
|
||||
delete options.action;
|
||||
|
||||
var actionClass = this._registryGet('action', action, action);
|
||||
return actionClass;
|
||||
};
|
||||
|
||||
ActionContainer.prototype._getHandler = function () {
|
||||
var handlerString = this.conflictHandler;
|
||||
var handlerFuncName = '_handleConflict' + $$.capitalize(handlerString);
|
||||
var func = this[handlerFuncName];
|
||||
if (typeof func === 'undefined') {
|
||||
var msg = 'invalid conflict resolution value: ' + handlerString;
|
||||
throw new Error(msg);
|
||||
} else {
|
||||
return func;
|
||||
}
|
||||
};
|
||||
|
||||
ActionContainer.prototype._checkConflict = function (action) {
|
||||
var optionStringActions = this._optionStringActions;
|
||||
var conflictOptionals = [];
|
||||
|
||||
// find all options that conflict with this option
|
||||
// collect pairs, the string, and an existing action that it conflicts with
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
var conflOptional = optionStringActions[optionString];
|
||||
if (typeof conflOptional !== 'undefined') {
|
||||
conflictOptionals.push([ optionString, conflOptional ]);
|
||||
}
|
||||
});
|
||||
|
||||
if (conflictOptionals.length > 0) {
|
||||
var conflictHandler = this._getHandler();
|
||||
conflictHandler.call(this, action, conflictOptionals);
|
||||
}
|
||||
};
|
||||
|
||||
ActionContainer.prototype._handleConflictError = function (action, conflOptionals) {
|
||||
var conflicts = conflOptionals.map(function (pair) { return pair[0]; });
|
||||
conflicts = conflicts.join(', ');
|
||||
throw argumentErrorHelper(
|
||||
action,
|
||||
format('Conflicting option string(s): %s', conflicts)
|
||||
);
|
||||
};
|
||||
|
||||
ActionContainer.prototype._handleConflictResolve = function (action, conflOptionals) {
|
||||
// remove all conflicting options
|
||||
var self = this;
|
||||
conflOptionals.forEach(function (pair) {
|
||||
var optionString = pair[0];
|
||||
var conflictingAction = pair[1];
|
||||
// remove the conflicting option string
|
||||
var i = conflictingAction.optionStrings.indexOf(optionString);
|
||||
if (i >= 0) {
|
||||
conflictingAction.optionStrings.splice(i, 1);
|
||||
}
|
||||
delete self._optionStringActions[optionString];
|
||||
// if the option now has no option string, remove it from the
|
||||
// container holding it
|
||||
if (conflictingAction.optionStrings.length === 0) {
|
||||
conflictingAction.container._removeAction(conflictingAction);
|
||||
}
|
||||
});
|
||||
};
|
14
tools/doc/node_modules/argparse/lib/argparse.js
generated
vendored
Normal file
14
tools/doc/node_modules/argparse/lib/argparse.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
module.exports.ArgumentParser = require('./argument_parser.js');
|
||||
module.exports.Namespace = require('./namespace');
|
||||
module.exports.Action = require('./action');
|
||||
module.exports.HelpFormatter = require('./help/formatter.js');
|
||||
module.exports.Const = require('./const.js');
|
||||
|
||||
module.exports.ArgumentDefaultsHelpFormatter =
|
||||
require('./help/added_formatters.js').ArgumentDefaultsHelpFormatter;
|
||||
module.exports.RawDescriptionHelpFormatter =
|
||||
require('./help/added_formatters.js').RawDescriptionHelpFormatter;
|
||||
module.exports.RawTextHelpFormatter =
|
||||
require('./help/added_formatters.js').RawTextHelpFormatter;
|
50
tools/doc/node_modules/argparse/lib/argument/error.js
generated
vendored
Normal file
50
tools/doc/node_modules/argparse/lib/argument/error.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
var format = require('util').format;
|
||||
|
||||
|
||||
var ERR_CODE = 'ARGError';
|
||||
|
||||
/*:nodoc:*
|
||||
* argumentError(argument, message) -> TypeError
|
||||
* - argument (Object): action with broken argument
|
||||
* - message (String): error message
|
||||
*
|
||||
* Error format helper. An error from creating or using an argument
|
||||
* (optional or positional). The string value of this exception
|
||||
* is the message, augmented with information
|
||||
* about the argument that caused it.
|
||||
*
|
||||
* #####Example
|
||||
*
|
||||
* var argumentErrorHelper = require('./argument/error');
|
||||
* if (conflictOptionals.length > 0) {
|
||||
* throw argumentErrorHelper(
|
||||
* action,
|
||||
* format('Conflicting option string(s): %s', conflictOptionals.join(', '))
|
||||
* );
|
||||
* }
|
||||
*
|
||||
**/
|
||||
module.exports = function (argument, message) {
|
||||
var argumentName = null;
|
||||
var errMessage;
|
||||
var err;
|
||||
|
||||
if (argument.getName) {
|
||||
argumentName = argument.getName();
|
||||
} else {
|
||||
argumentName = '' + argument;
|
||||
}
|
||||
|
||||
if (!argumentName) {
|
||||
errMessage = message;
|
||||
} else {
|
||||
errMessage = format('argument "%s": %s', argumentName, message);
|
||||
}
|
||||
|
||||
err = new TypeError(errMessage);
|
||||
err.code = ERR_CODE;
|
||||
return err;
|
||||
};
|
53
tools/doc/node_modules/argparse/lib/argument/exclusive.js
generated
vendored
Normal file
53
tools/doc/node_modules/argparse/lib/argument/exclusive.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/** internal
|
||||
* class MutuallyExclusiveGroup
|
||||
*
|
||||
* Group arguments.
|
||||
* By default, ArgumentParser groups command-line arguments
|
||||
* into “positional arguments” and “optional arguments”
|
||||
* when displaying help messages. When there is a better
|
||||
* conceptual grouping of arguments than this default one,
|
||||
* appropriate groups can be created using the addArgumentGroup() method
|
||||
*
|
||||
* This class inherited from [[ArgumentContainer]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ArgumentGroup = require('./group');
|
||||
|
||||
/**
|
||||
* new MutuallyExclusiveGroup(container, options)
|
||||
* - container (object): main container
|
||||
* - options (object): options.required -> true/false
|
||||
*
|
||||
* `required` could be an argument itself, but making it a property of
|
||||
* the options argument is more consistent with the JS adaptation of the Python)
|
||||
**/
|
||||
var MutuallyExclusiveGroup = module.exports = function MutuallyExclusiveGroup(container, options) {
|
||||
var required;
|
||||
options = options || {};
|
||||
required = options.required || false;
|
||||
ArgumentGroup.call(this, container);
|
||||
this.required = required;
|
||||
|
||||
};
|
||||
util.inherits(MutuallyExclusiveGroup, ArgumentGroup);
|
||||
|
||||
|
||||
MutuallyExclusiveGroup.prototype._addAction = function (action) {
|
||||
var msg;
|
||||
if (action.required) {
|
||||
msg = 'mutually exclusive arguments must be optional';
|
||||
throw new Error(msg);
|
||||
}
|
||||
action = this._container._addAction(action);
|
||||
this._groupActions.push(action);
|
||||
return action;
|
||||
};
|
||||
|
||||
|
||||
MutuallyExclusiveGroup.prototype._removeAction = function (action) {
|
||||
this._container._removeAction(action);
|
||||
this._groupActions.remove(action);
|
||||
};
|
74
tools/doc/node_modules/argparse/lib/argument/group.js
generated
vendored
Normal file
74
tools/doc/node_modules/argparse/lib/argument/group.js
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
/** internal
|
||||
* class ArgumentGroup
|
||||
*
|
||||
* Group arguments.
|
||||
* By default, ArgumentParser groups command-line arguments
|
||||
* into “positional arguments” and “optional arguments”
|
||||
* when displaying help messages. When there is a better
|
||||
* conceptual grouping of arguments than this default one,
|
||||
* appropriate groups can be created using the addArgumentGroup() method
|
||||
*
|
||||
* This class inherited from [[ArgumentContainer]]
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
var ActionContainer = require('../action_container');
|
||||
|
||||
|
||||
/**
|
||||
* new ArgumentGroup(container, options)
|
||||
* - container (object): main container
|
||||
* - options (object): hash of group options
|
||||
*
|
||||
* #### options
|
||||
* - **prefixChars** group name prefix
|
||||
* - **argumentDefault** default argument value
|
||||
* - **title** group title
|
||||
* - **description** group description
|
||||
*
|
||||
**/
|
||||
var ArgumentGroup = module.exports = function ArgumentGroup(container, options) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
// add any missing keyword arguments by checking the container
|
||||
options.conflictHandler = (options.conflictHandler || container.conflictHandler);
|
||||
options.prefixChars = (options.prefixChars || container.prefixChars);
|
||||
options.argumentDefault = (options.argumentDefault || container.argumentDefault);
|
||||
|
||||
ActionContainer.call(this, options);
|
||||
|
||||
// group attributes
|
||||
this.title = options.title;
|
||||
this._groupActions = [];
|
||||
|
||||
// share most attributes with the container
|
||||
this._container = container;
|
||||
this._registries = container._registries;
|
||||
this._actions = container._actions;
|
||||
this._optionStringActions = container._optionStringActions;
|
||||
this._defaults = container._defaults;
|
||||
this._hasNegativeNumberOptionals = container._hasNegativeNumberOptionals;
|
||||
this._mutuallyExclusiveGroups = container._mutuallyExclusiveGroups;
|
||||
};
|
||||
util.inherits(ArgumentGroup, ActionContainer);
|
||||
|
||||
|
||||
ArgumentGroup.prototype._addAction = function (action) {
|
||||
// Parent add action
|
||||
action = ActionContainer.prototype._addAction.call(this, action);
|
||||
this._groupActions.push(action);
|
||||
return action;
|
||||
};
|
||||
|
||||
|
||||
ArgumentGroup.prototype._removeAction = function (action) {
|
||||
// Parent remove action
|
||||
ActionContainer.prototype._removeAction.call(this, action);
|
||||
var actionIndex = this._groupActions.indexOf(action);
|
||||
if (actionIndex >= 0) {
|
||||
this._groupActions.splice(actionIndex, 1);
|
||||
}
|
||||
};
|
1161
tools/doc/node_modules/argparse/lib/argument_parser.js
generated
vendored
Normal file
1161
tools/doc/node_modules/argparse/lib/argument_parser.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
21
tools/doc/node_modules/argparse/lib/const.js
generated
vendored
Normal file
21
tools/doc/node_modules/argparse/lib/const.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports.EOL = '\n';
|
||||
|
||||
module.exports.SUPPRESS = '==SUPPRESS==';
|
||||
|
||||
module.exports.OPTIONAL = '?';
|
||||
|
||||
module.exports.ZERO_OR_MORE = '*';
|
||||
|
||||
module.exports.ONE_OR_MORE = '+';
|
||||
|
||||
module.exports.PARSER = 'A...';
|
||||
|
||||
module.exports.REMAINDER = '...';
|
||||
|
||||
module.exports._UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args';
|
87
tools/doc/node_modules/argparse/lib/help/added_formatters.js
generated
vendored
Normal file
87
tools/doc/node_modules/argparse/lib/help/added_formatters.js
generated
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
var $$ = require('../utils');
|
||||
var HelpFormatter = require('./formatter.js');
|
||||
|
||||
/**
|
||||
* new RawDescriptionHelpFormatter(options)
|
||||
* new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
|
||||
*
|
||||
* Help message formatter which adds default values to argument help.
|
||||
*
|
||||
* Only the name of this class is considered a public API. All the methods
|
||||
* provided by the class are considered an implementation detail.
|
||||
**/
|
||||
|
||||
function ArgumentDefaultsHelpFormatter(options) {
|
||||
HelpFormatter.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(ArgumentDefaultsHelpFormatter, HelpFormatter);
|
||||
|
||||
ArgumentDefaultsHelpFormatter.prototype._getHelpString = function (action) {
|
||||
var help = action.help;
|
||||
if (action.help.indexOf('%(defaultValue)s') === -1) {
|
||||
if (action.defaultValue !== c.SUPPRESS) {
|
||||
var defaulting_nargs = [ c.OPTIONAL, c.ZERO_OR_MORE ];
|
||||
if (action.isOptional() || (defaulting_nargs.indexOf(action.nargs) >= 0)) {
|
||||
help += ' (default: %(defaultValue)s)';
|
||||
}
|
||||
}
|
||||
}
|
||||
return help;
|
||||
};
|
||||
|
||||
module.exports.ArgumentDefaultsHelpFormatter = ArgumentDefaultsHelpFormatter;
|
||||
|
||||
/**
|
||||
* new RawDescriptionHelpFormatter(options)
|
||||
* new ArgumentParser({formatterClass: argparse.RawDescriptionHelpFormatter, ...})
|
||||
*
|
||||
* Help message formatter which retains any formatting in descriptions.
|
||||
*
|
||||
* Only the name of this class is considered a public API. All the methods
|
||||
* provided by the class are considered an implementation detail.
|
||||
**/
|
||||
|
||||
function RawDescriptionHelpFormatter(options) {
|
||||
HelpFormatter.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(RawDescriptionHelpFormatter, HelpFormatter);
|
||||
|
||||
RawDescriptionHelpFormatter.prototype._fillText = function (text, width, indent) {
|
||||
var lines = text.split('\n');
|
||||
lines = lines.map(function (line) {
|
||||
return $$.trimEnd(indent + line);
|
||||
});
|
||||
return lines.join('\n');
|
||||
};
|
||||
module.exports.RawDescriptionHelpFormatter = RawDescriptionHelpFormatter;
|
||||
|
||||
/**
|
||||
* new RawTextHelpFormatter(options)
|
||||
* new ArgumentParser({formatterClass: argparse.RawTextHelpFormatter, ...})
|
||||
*
|
||||
* Help message formatter which retains formatting of all help text.
|
||||
*
|
||||
* Only the name of this class is considered a public API. All the methods
|
||||
* provided by the class are considered an implementation detail.
|
||||
**/
|
||||
|
||||
function RawTextHelpFormatter(options) {
|
||||
RawDescriptionHelpFormatter.call(this, options);
|
||||
}
|
||||
|
||||
util.inherits(RawTextHelpFormatter, RawDescriptionHelpFormatter);
|
||||
|
||||
RawTextHelpFormatter.prototype._splitLines = function (text) {
|
||||
return text.split('\n');
|
||||
};
|
||||
|
||||
module.exports.RawTextHelpFormatter = RawTextHelpFormatter;
|
795
tools/doc/node_modules/argparse/lib/help/formatter.js
generated
vendored
Normal file
795
tools/doc/node_modules/argparse/lib/help/formatter.js
generated
vendored
Normal file
@ -0,0 +1,795 @@
|
||||
/**
|
||||
* class HelpFormatter
|
||||
*
|
||||
* Formatter for generating usage messages and argument help strings. Only the
|
||||
* name of this class is considered a public API. All the methods provided by
|
||||
* the class are considered an implementation detail.
|
||||
*
|
||||
* Do not call in your code, use this class only for inherits your own forvatter
|
||||
*
|
||||
* ToDo add [additonal formatters][1]
|
||||
*
|
||||
* [1]:http://docs.python.org/dev/library/argparse.html#formatter-class
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var sprintf = require('sprintf-js').sprintf;
|
||||
|
||||
// Constants
|
||||
var c = require('../const');
|
||||
|
||||
var $$ = require('../utils');
|
||||
|
||||
|
||||
/*:nodoc:* internal
|
||||
* new Support(parent, heding)
|
||||
* - parent (object): parent section
|
||||
* - heading (string): header string
|
||||
*
|
||||
**/
|
||||
function Section(parent, heading) {
|
||||
this._parent = parent;
|
||||
this._heading = heading;
|
||||
this._items = [];
|
||||
}
|
||||
|
||||
/*:nodoc:* internal
|
||||
* Section#addItem(callback) -> Void
|
||||
* - callback (array): tuple with function and args
|
||||
*
|
||||
* Add function for single element
|
||||
**/
|
||||
Section.prototype.addItem = function (callback) {
|
||||
this._items.push(callback);
|
||||
};
|
||||
|
||||
/*:nodoc:* internal
|
||||
* Section#formatHelp(formatter) -> string
|
||||
* - formatter (HelpFormatter): current formatter
|
||||
*
|
||||
* Form help section string
|
||||
*
|
||||
**/
|
||||
Section.prototype.formatHelp = function (formatter) {
|
||||
var itemHelp, heading;
|
||||
|
||||
// format the indented section
|
||||
if (this._parent) {
|
||||
formatter._indent();
|
||||
}
|
||||
|
||||
itemHelp = this._items.map(function (item) {
|
||||
var obj, func, args;
|
||||
|
||||
obj = formatter;
|
||||
func = item[0];
|
||||
args = item[1];
|
||||
return func.apply(obj, args);
|
||||
});
|
||||
itemHelp = formatter._joinParts(itemHelp);
|
||||
|
||||
if (this._parent) {
|
||||
formatter._dedent();
|
||||
}
|
||||
|
||||
// return nothing if the section was empty
|
||||
if (!itemHelp) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// add the heading if the section was non-empty
|
||||
heading = '';
|
||||
if (this._heading && this._heading !== c.SUPPRESS) {
|
||||
var currentIndent = formatter.currentIndent;
|
||||
heading = $$.repeat(' ', currentIndent) + this._heading + ':' + c.EOL;
|
||||
}
|
||||
|
||||
// join the section-initialize newline, the heading and the help
|
||||
return formatter._joinParts([ c.EOL, heading, itemHelp, c.EOL ]);
|
||||
};
|
||||
|
||||
/**
|
||||
* new HelpFormatter(options)
|
||||
*
|
||||
* #### Options:
|
||||
* - `prog`: program name
|
||||
* - `indentIncriment`: indent step, default value 2
|
||||
* - `maxHelpPosition`: max help position, default value = 24
|
||||
* - `width`: line width
|
||||
*
|
||||
**/
|
||||
var HelpFormatter = module.exports = function HelpFormatter(options) {
|
||||
options = options || {};
|
||||
|
||||
this._prog = options.prog;
|
||||
|
||||
this._maxHelpPosition = options.maxHelpPosition || 24;
|
||||
this._width = (options.width || ((process.env.COLUMNS || 80) - 2));
|
||||
|
||||
this._currentIndent = 0;
|
||||
this._indentIncriment = options.indentIncriment || 2;
|
||||
this._level = 0;
|
||||
this._actionMaxLength = 0;
|
||||
|
||||
this._rootSection = new Section(null);
|
||||
this._currentSection = this._rootSection;
|
||||
|
||||
this._whitespaceMatcher = new RegExp('\\s+', 'g');
|
||||
this._longBreakMatcher = new RegExp(c.EOL + c.EOL + c.EOL + '+', 'g');
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._indent = function () {
|
||||
this._currentIndent += this._indentIncriment;
|
||||
this._level += 1;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._dedent = function () {
|
||||
this._currentIndent -= this._indentIncriment;
|
||||
this._level -= 1;
|
||||
if (this._currentIndent < 0) {
|
||||
throw new Error('Indent decreased below 0.');
|
||||
}
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._addItem = function (func, args) {
|
||||
this._currentSection.addItem([ func, args ]);
|
||||
};
|
||||
|
||||
//
|
||||
// Message building methods
|
||||
//
|
||||
|
||||
/**
|
||||
* HelpFormatter#startSection(heading) -> Void
|
||||
* - heading (string): header string
|
||||
*
|
||||
* Start new help section
|
||||
*
|
||||
* See alse [code example][1]
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.startSection(actionGroup.title);
|
||||
* formatter.addText(actionGroup.description);
|
||||
* formatter.addArguments(actionGroup._groupActions);
|
||||
* formatter.endSection();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.startSection = function (heading) {
|
||||
this._indent();
|
||||
var section = new Section(this._currentSection, heading);
|
||||
var func = section.formatHelp.bind(section);
|
||||
this._addItem(func, [ this ]);
|
||||
this._currentSection = section;
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#endSection -> Void
|
||||
*
|
||||
* End help section
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.startSection(actionGroup.title);
|
||||
* formatter.addText(actionGroup.description);
|
||||
* formatter.addArguments(actionGroup._groupActions);
|
||||
* formatter.endSection();
|
||||
**/
|
||||
HelpFormatter.prototype.endSection = function () {
|
||||
this._currentSection = this._currentSection._parent;
|
||||
this._dedent();
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#addText(text) -> Void
|
||||
* - text (string): plain text
|
||||
*
|
||||
* Add plain text into current section
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.startSection(actionGroup.title);
|
||||
* formatter.addText(actionGroup.description);
|
||||
* formatter.addArguments(actionGroup._groupActions);
|
||||
* formatter.endSection();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.addText = function (text) {
|
||||
if (text && text !== c.SUPPRESS) {
|
||||
this._addItem(this._formatText, [ text ]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#addUsage(usage, actions, groups, prefix) -> Void
|
||||
* - usage (string): usage text
|
||||
* - actions (array): actions list
|
||||
* - groups (array): groups list
|
||||
* - prefix (string): usage prefix
|
||||
*
|
||||
* Add usage data into current section
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.addUsage(this.usage, this._actions, []);
|
||||
* return formatter.formatHelp();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.addUsage = function (usage, actions, groups, prefix) {
|
||||
if (usage !== c.SUPPRESS) {
|
||||
this._addItem(this._formatUsage, [ usage, actions, groups, prefix ]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#addArgument(action) -> Void
|
||||
* - action (object): action
|
||||
*
|
||||
* Add argument into current section
|
||||
*
|
||||
* Single variant of [[HelpFormatter#addArguments]]
|
||||
**/
|
||||
HelpFormatter.prototype.addArgument = function (action) {
|
||||
if (action.help !== c.SUPPRESS) {
|
||||
var self = this;
|
||||
|
||||
// find all invocations
|
||||
var invocations = [ this._formatActionInvocation(action) ];
|
||||
var invocationLength = invocations[0].length;
|
||||
|
||||
var actionLength;
|
||||
|
||||
if (action._getSubactions) {
|
||||
this._indent();
|
||||
action._getSubactions().forEach(function (subaction) {
|
||||
|
||||
var invocationNew = self._formatActionInvocation(subaction);
|
||||
invocations.push(invocationNew);
|
||||
invocationLength = Math.max(invocationLength, invocationNew.length);
|
||||
|
||||
});
|
||||
this._dedent();
|
||||
}
|
||||
|
||||
// update the maximum item length
|
||||
actionLength = invocationLength + this._currentIndent;
|
||||
this._actionMaxLength = Math.max(this._actionMaxLength, actionLength);
|
||||
|
||||
// add the item to the list
|
||||
this._addItem(this._formatAction, [ action ]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* HelpFormatter#addArguments(actions) -> Void
|
||||
* - actions (array): actions list
|
||||
*
|
||||
* Mass add arguments into current section
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.startSection(actionGroup.title);
|
||||
* formatter.addText(actionGroup.description);
|
||||
* formatter.addArguments(actionGroup._groupActions);
|
||||
* formatter.endSection();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.addArguments = function (actions) {
|
||||
var self = this;
|
||||
actions.forEach(function (action) {
|
||||
self.addArgument(action);
|
||||
});
|
||||
};
|
||||
|
||||
//
|
||||
// Help-formatting methods
|
||||
//
|
||||
|
||||
/**
|
||||
* HelpFormatter#formatHelp -> string
|
||||
*
|
||||
* Format help
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* formatter.addText(this.epilog);
|
||||
* return formatter.formatHelp();
|
||||
*
|
||||
**/
|
||||
HelpFormatter.prototype.formatHelp = function () {
|
||||
var help = this._rootSection.formatHelp(this);
|
||||
if (help) {
|
||||
help = help.replace(this._longBreakMatcher, c.EOL + c.EOL);
|
||||
help = $$.trimChars(help, c.EOL) + c.EOL;
|
||||
}
|
||||
return help;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._joinParts = function (partStrings) {
|
||||
return partStrings.filter(function (part) {
|
||||
return (part && part !== c.SUPPRESS);
|
||||
}).join('');
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatUsage = function (usage, actions, groups, prefix) {
|
||||
if (!prefix && typeof prefix !== 'string') {
|
||||
prefix = 'usage: ';
|
||||
}
|
||||
|
||||
actions = actions || [];
|
||||
groups = groups || [];
|
||||
|
||||
|
||||
// if usage is specified, use that
|
||||
if (usage) {
|
||||
usage = sprintf(usage, { prog: this._prog });
|
||||
|
||||
// if no optionals or positionals are available, usage is just prog
|
||||
} else if (!usage && actions.length === 0) {
|
||||
usage = this._prog;
|
||||
|
||||
// if optionals and positionals are available, calculate usage
|
||||
} else if (!usage) {
|
||||
var prog = this._prog;
|
||||
var optionals = [];
|
||||
var positionals = [];
|
||||
var actionUsage;
|
||||
var textWidth;
|
||||
|
||||
// split optionals from positionals
|
||||
actions.forEach(function (action) {
|
||||
if (action.isOptional()) {
|
||||
optionals.push(action);
|
||||
} else {
|
||||
positionals.push(action);
|
||||
}
|
||||
});
|
||||
|
||||
// build full usage string
|
||||
actionUsage = this._formatActionsUsage([].concat(optionals, positionals), groups);
|
||||
usage = [ prog, actionUsage ].join(' ');
|
||||
|
||||
// wrap the usage parts if it's too long
|
||||
textWidth = this._width - this._currentIndent;
|
||||
if ((prefix.length + usage.length) > textWidth) {
|
||||
|
||||
// break usage into wrappable parts
|
||||
var regexpPart = new RegExp('\\(.*?\\)+|\\[.*?\\]+|\\S+', 'g');
|
||||
var optionalUsage = this._formatActionsUsage(optionals, groups);
|
||||
var positionalUsage = this._formatActionsUsage(positionals, groups);
|
||||
|
||||
|
||||
var optionalParts = optionalUsage.match(regexpPart);
|
||||
var positionalParts = positionalUsage.match(regexpPart) || [];
|
||||
|
||||
if (optionalParts.join(' ') !== optionalUsage) {
|
||||
throw new Error('assert "optionalParts.join(\' \') === optionalUsage"');
|
||||
}
|
||||
if (positionalParts.join(' ') !== positionalUsage) {
|
||||
throw new Error('assert "positionalParts.join(\' \') === positionalUsage"');
|
||||
}
|
||||
|
||||
// helper for wrapping lines
|
||||
/*eslint-disable func-style*/ // node 0.10 compat
|
||||
var _getLines = function (parts, indent, prefix) {
|
||||
var lines = [];
|
||||
var line = [];
|
||||
|
||||
var lineLength = prefix ? prefix.length - 1 : indent.length - 1;
|
||||
|
||||
parts.forEach(function (part) {
|
||||
if (lineLength + 1 + part.length > textWidth) {
|
||||
lines.push(indent + line.join(' '));
|
||||
line = [];
|
||||
lineLength = indent.length - 1;
|
||||
}
|
||||
line.push(part);
|
||||
lineLength += part.length + 1;
|
||||
});
|
||||
|
||||
if (line) {
|
||||
lines.push(indent + line.join(' '));
|
||||
}
|
||||
if (prefix) {
|
||||
lines[0] = lines[0].substr(indent.length);
|
||||
}
|
||||
return lines;
|
||||
};
|
||||
|
||||
var lines, indent, parts;
|
||||
// if prog is short, follow it with optionals or positionals
|
||||
if (prefix.length + prog.length <= 0.75 * textWidth) {
|
||||
indent = $$.repeat(' ', (prefix.length + prog.length + 1));
|
||||
if (optionalParts) {
|
||||
lines = [].concat(
|
||||
_getLines([ prog ].concat(optionalParts), indent, prefix),
|
||||
_getLines(positionalParts, indent)
|
||||
);
|
||||
} else if (positionalParts) {
|
||||
lines = _getLines([ prog ].concat(positionalParts), indent, prefix);
|
||||
} else {
|
||||
lines = [ prog ];
|
||||
}
|
||||
|
||||
// if prog is long, put it on its own line
|
||||
} else {
|
||||
indent = $$.repeat(' ', prefix.length);
|
||||
parts = optionalParts.concat(positionalParts);
|
||||
lines = _getLines(parts, indent);
|
||||
if (lines.length > 1) {
|
||||
lines = [].concat(
|
||||
_getLines(optionalParts, indent),
|
||||
_getLines(positionalParts, indent)
|
||||
);
|
||||
}
|
||||
lines = [ prog ].concat(lines);
|
||||
}
|
||||
// join lines into usage
|
||||
usage = lines.join(c.EOL);
|
||||
}
|
||||
}
|
||||
|
||||
// prefix with 'usage:'
|
||||
return prefix + usage + c.EOL + c.EOL;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatActionsUsage = function (actions, groups) {
|
||||
// find group indices and identify actions in groups
|
||||
var groupActions = [];
|
||||
var inserts = [];
|
||||
var self = this;
|
||||
|
||||
groups.forEach(function (group) {
|
||||
var end;
|
||||
var i;
|
||||
|
||||
var start = actions.indexOf(group._groupActions[0]);
|
||||
if (start >= 0) {
|
||||
end = start + group._groupActions.length;
|
||||
|
||||
//if (actions.slice(start, end) === group._groupActions) {
|
||||
if ($$.arrayEqual(actions.slice(start, end), group._groupActions)) {
|
||||
group._groupActions.forEach(function (action) {
|
||||
groupActions.push(action);
|
||||
});
|
||||
|
||||
if (!group.required) {
|
||||
if (inserts[start]) {
|
||||
inserts[start] += ' [';
|
||||
} else {
|
||||
inserts[start] = '[';
|
||||
}
|
||||
inserts[end] = ']';
|
||||
} else {
|
||||
if (inserts[start]) {
|
||||
inserts[start] += ' (';
|
||||
} else {
|
||||
inserts[start] = '(';
|
||||
}
|
||||
inserts[end] = ')';
|
||||
}
|
||||
for (i = start + 1; i < end; i += 1) {
|
||||
inserts[i] = '|';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// collect all actions format strings
|
||||
var parts = [];
|
||||
|
||||
actions.forEach(function (action, actionIndex) {
|
||||
var part;
|
||||
var optionString;
|
||||
var argsDefault;
|
||||
var argsString;
|
||||
|
||||
// suppressed arguments are marked with None
|
||||
// remove | separators for suppressed arguments
|
||||
if (action.help === c.SUPPRESS) {
|
||||
parts.push(null);
|
||||
if (inserts[actionIndex] === '|') {
|
||||
inserts.splice(actionIndex, actionIndex);
|
||||
} else if (inserts[actionIndex + 1] === '|') {
|
||||
inserts.splice(actionIndex + 1, actionIndex + 1);
|
||||
}
|
||||
|
||||
// produce all arg strings
|
||||
} else if (!action.isOptional()) {
|
||||
part = self._formatArgs(action, action.dest);
|
||||
|
||||
// if it's in a group, strip the outer []
|
||||
if (groupActions.indexOf(action) >= 0) {
|
||||
if (part[0] === '[' && part[part.length - 1] === ']') {
|
||||
part = part.slice(1, -1);
|
||||
}
|
||||
}
|
||||
// add the action string to the list
|
||||
parts.push(part);
|
||||
|
||||
// produce the first way to invoke the option in brackets
|
||||
} else {
|
||||
optionString = action.optionStrings[0];
|
||||
|
||||
// if the Optional doesn't take a value, format is: -s or --long
|
||||
if (action.nargs === 0) {
|
||||
part = '' + optionString;
|
||||
|
||||
// if the Optional takes a value, format is: -s ARGS or --long ARGS
|
||||
} else {
|
||||
argsDefault = action.dest.toUpperCase();
|
||||
argsString = self._formatArgs(action, argsDefault);
|
||||
part = optionString + ' ' + argsString;
|
||||
}
|
||||
// make it look optional if it's not required or in a group
|
||||
if (!action.required && groupActions.indexOf(action) < 0) {
|
||||
part = '[' + part + ']';
|
||||
}
|
||||
// add the action string to the list
|
||||
parts.push(part);
|
||||
}
|
||||
});
|
||||
|
||||
// insert things at the necessary indices
|
||||
for (var i = inserts.length - 1; i >= 0; --i) {
|
||||
if (inserts[i] !== null) {
|
||||
parts.splice(i, 0, inserts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// join all the action items with spaces
|
||||
var text = parts.filter(function (part) {
|
||||
return !!part;
|
||||
}).join(' ');
|
||||
|
||||
// clean up separators for mutually exclusive groups
|
||||
text = text.replace(/([\[(]) /g, '$1'); // remove spaces
|
||||
text = text.replace(/ ([\])])/g, '$1');
|
||||
text = text.replace(/\[ *\]/g, ''); // remove empty groups
|
||||
text = text.replace(/\( *\)/g, '');
|
||||
text = text.replace(/\(([^|]*)\)/g, '$1'); // remove () from single action groups
|
||||
|
||||
text = text.trim();
|
||||
|
||||
// return the text
|
||||
return text;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatText = function (text) {
|
||||
text = sprintf(text, { prog: this._prog });
|
||||
var textWidth = this._width - this._currentIndent;
|
||||
var indentIncriment = $$.repeat(' ', this._currentIndent);
|
||||
return this._fillText(text, textWidth, indentIncriment) + c.EOL + c.EOL;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatAction = function (action) {
|
||||
var self = this;
|
||||
|
||||
var helpText;
|
||||
var helpLines;
|
||||
var parts;
|
||||
var indentFirst;
|
||||
|
||||
// determine the required width and the entry label
|
||||
var helpPosition = Math.min(this._actionMaxLength + 2, this._maxHelpPosition);
|
||||
var helpWidth = this._width - helpPosition;
|
||||
var actionWidth = helpPosition - this._currentIndent - 2;
|
||||
var actionHeader = this._formatActionInvocation(action);
|
||||
|
||||
// no help; start on same line and add a final newline
|
||||
if (!action.help) {
|
||||
actionHeader = $$.repeat(' ', this._currentIndent) + actionHeader + c.EOL;
|
||||
|
||||
// short action name; start on the same line and pad two spaces
|
||||
} else if (actionHeader.length <= actionWidth) {
|
||||
actionHeader = $$.repeat(' ', this._currentIndent) +
|
||||
actionHeader +
|
||||
' ' +
|
||||
$$.repeat(' ', actionWidth - actionHeader.length);
|
||||
indentFirst = 0;
|
||||
|
||||
// long action name; start on the next line
|
||||
} else {
|
||||
actionHeader = $$.repeat(' ', this._currentIndent) + actionHeader + c.EOL;
|
||||
indentFirst = helpPosition;
|
||||
}
|
||||
|
||||
// collect the pieces of the action help
|
||||
parts = [ actionHeader ];
|
||||
|
||||
// if there was help for the action, add lines of help text
|
||||
if (action.help) {
|
||||
helpText = this._expandHelp(action);
|
||||
helpLines = this._splitLines(helpText, helpWidth);
|
||||
parts.push($$.repeat(' ', indentFirst) + helpLines[0] + c.EOL);
|
||||
helpLines.slice(1).forEach(function (line) {
|
||||
parts.push($$.repeat(' ', helpPosition) + line + c.EOL);
|
||||
});
|
||||
|
||||
// or add a newline if the description doesn't end with one
|
||||
} else if (actionHeader.charAt(actionHeader.length - 1) !== c.EOL) {
|
||||
parts.push(c.EOL);
|
||||
}
|
||||
// if there are any sub-actions, add their help as well
|
||||
if (action._getSubactions) {
|
||||
this._indent();
|
||||
action._getSubactions().forEach(function (subaction) {
|
||||
parts.push(self._formatAction(subaction));
|
||||
});
|
||||
this._dedent();
|
||||
}
|
||||
// return a single string
|
||||
return this._joinParts(parts);
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatActionInvocation = function (action) {
|
||||
if (!action.isOptional()) {
|
||||
var format_func = this._metavarFormatter(action, action.dest);
|
||||
var metavars = format_func(1);
|
||||
return metavars[0];
|
||||
}
|
||||
|
||||
var parts = [];
|
||||
var argsDefault;
|
||||
var argsString;
|
||||
|
||||
// if the Optional doesn't take a value, format is: -s, --long
|
||||
if (action.nargs === 0) {
|
||||
parts = parts.concat(action.optionStrings);
|
||||
|
||||
// if the Optional takes a value, format is: -s ARGS, --long ARGS
|
||||
} else {
|
||||
argsDefault = action.dest.toUpperCase();
|
||||
argsString = this._formatArgs(action, argsDefault);
|
||||
action.optionStrings.forEach(function (optionString) {
|
||||
parts.push(optionString + ' ' + argsString);
|
||||
});
|
||||
}
|
||||
return parts.join(', ');
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._metavarFormatter = function (action, metavarDefault) {
|
||||
var result;
|
||||
|
||||
if (action.metavar || action.metavar === '') {
|
||||
result = action.metavar;
|
||||
} else if (action.choices) {
|
||||
var choices = action.choices;
|
||||
|
||||
if (typeof choices === 'string') {
|
||||
choices = choices.split('').join(', ');
|
||||
} else if (Array.isArray(choices)) {
|
||||
choices = choices.join(',');
|
||||
} else {
|
||||
choices = Object.keys(choices).join(',');
|
||||
}
|
||||
result = '{' + choices + '}';
|
||||
} else {
|
||||
result = metavarDefault;
|
||||
}
|
||||
|
||||
return function (size) {
|
||||
if (Array.isArray(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var metavars = [];
|
||||
for (var i = 0; i < size; i += 1) {
|
||||
metavars.push(result);
|
||||
}
|
||||
return metavars;
|
||||
};
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._formatArgs = function (action, metavarDefault) {
|
||||
var result;
|
||||
var metavars;
|
||||
|
||||
var buildMetavar = this._metavarFormatter(action, metavarDefault);
|
||||
|
||||
switch (action.nargs) {
|
||||
/*eslint-disable no-undefined*/
|
||||
case undefined:
|
||||
case null:
|
||||
metavars = buildMetavar(1);
|
||||
result = '' + metavars[0];
|
||||
break;
|
||||
case c.OPTIONAL:
|
||||
metavars = buildMetavar(1);
|
||||
result = '[' + metavars[0] + ']';
|
||||
break;
|
||||
case c.ZERO_OR_MORE:
|
||||
metavars = buildMetavar(2);
|
||||
result = '[' + metavars[0] + ' [' + metavars[1] + ' ...]]';
|
||||
break;
|
||||
case c.ONE_OR_MORE:
|
||||
metavars = buildMetavar(2);
|
||||
result = '' + metavars[0] + ' [' + metavars[1] + ' ...]';
|
||||
break;
|
||||
case c.REMAINDER:
|
||||
result = '...';
|
||||
break;
|
||||
case c.PARSER:
|
||||
metavars = buildMetavar(1);
|
||||
result = metavars[0] + ' ...';
|
||||
break;
|
||||
default:
|
||||
metavars = buildMetavar(action.nargs);
|
||||
result = metavars.join(' ');
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._expandHelp = function (action) {
|
||||
var params = { prog: this._prog };
|
||||
|
||||
Object.keys(action).forEach(function (actionProperty) {
|
||||
var actionValue = action[actionProperty];
|
||||
|
||||
if (actionValue !== c.SUPPRESS) {
|
||||
params[actionProperty] = actionValue;
|
||||
}
|
||||
});
|
||||
|
||||
if (params.choices) {
|
||||
if (typeof params.choices === 'string') {
|
||||
params.choices = params.choices.split('').join(', ');
|
||||
} else if (Array.isArray(params.choices)) {
|
||||
params.choices = params.choices.join(', ');
|
||||
} else {
|
||||
params.choices = Object.keys(params.choices).join(', ');
|
||||
}
|
||||
}
|
||||
|
||||
return sprintf(this._getHelpString(action), params);
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._splitLines = function (text, width) {
|
||||
var lines = [];
|
||||
var delimiters = [ ' ', '.', ',', '!', '?' ];
|
||||
var re = new RegExp('[' + delimiters.join('') + '][^' + delimiters.join('') + ']*$');
|
||||
|
||||
text = text.replace(/[\n\|\t]/g, ' ');
|
||||
|
||||
text = text.trim();
|
||||
text = text.replace(this._whitespaceMatcher, ' ');
|
||||
|
||||
// Wraps the single paragraph in text (a string) so every line
|
||||
// is at most width characters long.
|
||||
text.split(c.EOL).forEach(function (line) {
|
||||
if (width >= line.length) {
|
||||
lines.push(line);
|
||||
return;
|
||||
}
|
||||
|
||||
var wrapStart = 0;
|
||||
var wrapEnd = width;
|
||||
var delimiterIndex = 0;
|
||||
while (wrapEnd <= line.length) {
|
||||
if (wrapEnd !== line.length && delimiters.indexOf(line[wrapEnd] < -1)) {
|
||||
delimiterIndex = (re.exec(line.substring(wrapStart, wrapEnd)) || {}).index;
|
||||
wrapEnd = wrapStart + delimiterIndex + 1;
|
||||
}
|
||||
lines.push(line.substring(wrapStart, wrapEnd));
|
||||
wrapStart = wrapEnd;
|
||||
wrapEnd += width;
|
||||
}
|
||||
if (wrapStart < line.length) {
|
||||
lines.push(line.substring(wrapStart, wrapEnd));
|
||||
}
|
||||
});
|
||||
|
||||
return lines;
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._fillText = function (text, width, indent) {
|
||||
var lines = this._splitLines(text, width);
|
||||
lines = lines.map(function (line) {
|
||||
return indent + line;
|
||||
});
|
||||
return lines.join(c.EOL);
|
||||
};
|
||||
|
||||
HelpFormatter.prototype._getHelpString = function (action) {
|
||||
return action.help;
|
||||
};
|
76
tools/doc/node_modules/argparse/lib/namespace.js
generated
vendored
Normal file
76
tools/doc/node_modules/argparse/lib/namespace.js
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
* class Namespace
|
||||
*
|
||||
* Simple object for storing attributes. Implements equality by attribute names
|
||||
* and values, and provides a simple string representation.
|
||||
*
|
||||
* See also [original guide][1]
|
||||
*
|
||||
* [1]:http://docs.python.org/dev/library/argparse.html#the-namespace-object
|
||||
**/
|
||||
'use strict';
|
||||
|
||||
var $$ = require('./utils');
|
||||
|
||||
/**
|
||||
* new Namespace(options)
|
||||
* - options(object): predefined propertis for result object
|
||||
*
|
||||
**/
|
||||
var Namespace = module.exports = function Namespace(options) {
|
||||
$$.extend(this, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace#isset(key) -> Boolean
|
||||
* - key (string|number): property name
|
||||
*
|
||||
* Tells whenever `namespace` contains given `key` or not.
|
||||
**/
|
||||
Namespace.prototype.isset = function (key) {
|
||||
return $$.has(this, key);
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace#set(key, value) -> self
|
||||
* -key (string|number|object): propery name
|
||||
* -value (mixed): new property value
|
||||
*
|
||||
* Set the property named key with value.
|
||||
* If key object then set all key properties to namespace object
|
||||
**/
|
||||
Namespace.prototype.set = function (key, value) {
|
||||
if (typeof (key) === 'object') {
|
||||
$$.extend(this, key);
|
||||
} else {
|
||||
this[key] = value;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace#get(key, defaultValue) -> mixed
|
||||
* - key (string|number): property name
|
||||
* - defaultValue (mixed): default value
|
||||
*
|
||||
* Return the property key or defaulValue if not set
|
||||
**/
|
||||
Namespace.prototype.get = function (key, defaultValue) {
|
||||
return !this[key] ? defaultValue : this[key];
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace#unset(key, defaultValue) -> mixed
|
||||
* - key (string|number): property name
|
||||
* - defaultValue (mixed): default value
|
||||
*
|
||||
* Return data[key](and delete it) or defaultValue
|
||||
**/
|
||||
Namespace.prototype.unset = function (key, defaultValue) {
|
||||
var value = this[key];
|
||||
if (value !== null) {
|
||||
delete this[key];
|
||||
return value;
|
||||
}
|
||||
return defaultValue;
|
||||
};
|
57
tools/doc/node_modules/argparse/lib/utils.js
generated
vendored
Normal file
57
tools/doc/node_modules/argparse/lib/utils.js
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
|
||||
exports.repeat = function (str, num) {
|
||||
var result = '';
|
||||
for (var i = 0; i < num; i++) { result += str; }
|
||||
return result;
|
||||
};
|
||||
|
||||
exports.arrayEqual = function (a, b) {
|
||||
if (a.length !== b.length) { return false; }
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
if (a[i] !== b[i]) { return false; }
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
exports.trimChars = function (str, chars) {
|
||||
var start = 0;
|
||||
var end = str.length - 1;
|
||||
while (chars.indexOf(str.charAt(start)) >= 0) { start++; }
|
||||
while (chars.indexOf(str.charAt(end)) >= 0) { end--; }
|
||||
return str.slice(start, end + 1);
|
||||
};
|
||||
|
||||
exports.capitalize = function (str) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
};
|
||||
|
||||
exports.arrayUnion = function () {
|
||||
var result = [];
|
||||
for (var i = 0, values = {}; i < arguments.length; i++) {
|
||||
var arr = arguments[i];
|
||||
for (var j = 0; j < arr.length; j++) {
|
||||
if (!values[arr[j]]) {
|
||||
values[arr[j]] = true;
|
||||
result.push(arr[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
function has(obj, key) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||
}
|
||||
|
||||
exports.has = has;
|
||||
|
||||
exports.extend = function (dest, src) {
|
||||
for (var i in src) {
|
||||
if (has(src, i)) { dest[i] = src[i]; }
|
||||
}
|
||||
};
|
||||
|
||||
exports.trimEnd = function (str) {
|
||||
return str.replace(/\s+$/g, '');
|
||||
};
|
74
tools/doc/node_modules/argparse/package.json
generated
vendored
Normal file
74
tools/doc/node_modules/argparse/package.json
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"argparse@1.0.10",
|
||||
"/Users/rubys/git/node/tools/doc"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "argparse@1.0.10",
|
||||
"_id": "argparse@1.0.10",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"_location": "/argparse",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "argparse@1.0.10",
|
||||
"name": "argparse",
|
||||
"escapedName": "argparse",
|
||||
"rawSpec": "1.0.10",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.10"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/js-yaml"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"_spec": "1.0.10",
|
||||
"_where": "/Users/rubys/git/node/tools/doc",
|
||||
"bugs": {
|
||||
"url": "https://github.com/nodeca/argparse/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Eugene Shkuropat"
|
||||
},
|
||||
{
|
||||
"name": "Paul Jacobson"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
},
|
||||
"description": "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library",
|
||||
"devDependencies": {
|
||||
"eslint": "^2.13.1",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^3.1.0",
|
||||
"ndoc": "^5.0.1"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"homepage": "https://github.com/nodeca/argparse#readme",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"parser",
|
||||
"argparse",
|
||||
"option",
|
||||
"args"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "argparse",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/nodeca/argparse.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "1.0.10"
|
||||
}
|
21
tools/doc/node_modules/esprima/LICENSE.BSD
generated
vendored
Normal file
21
tools/doc/node_modules/esprima/LICENSE.BSD
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
Copyright JS Foundation and other contributors, https://js.foundation/
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
46
tools/doc/node_modules/esprima/README.md
generated
vendored
Normal file
46
tools/doc/node_modules/esprima/README.md
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
[](https://www.npmjs.com/package/esprima)
|
||||
[](https://www.npmjs.com/package/esprima)
|
||||
[](https://travis-ci.org/jquery/esprima)
|
||||
[](https://codecov.io/github/jquery/esprima)
|
||||
|
||||
**Esprima** ([esprima.org](http://esprima.org), BSD license) is a high performance,
|
||||
standard-compliant [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
|
||||
parser written in ECMAScript (also popularly known as
|
||||
[JavaScript](https://en.wikipedia.org/wiki/JavaScript)).
|
||||
Esprima is created and maintained by [Ariya Hidayat](https://twitter.com/ariyahidayat),
|
||||
with the help of [many contributors](https://github.com/jquery/esprima/contributors).
|
||||
|
||||
### Features
|
||||
|
||||
- Full support for ECMAScript 2017 ([ECMA-262 8th Edition](http://www.ecma-international.org/publications/standards/Ecma-262.htm))
|
||||
- Sensible [syntax tree format](https://github.com/estree/estree/blob/master/es5.md) as standardized by [ESTree project](https://github.com/estree/estree)
|
||||
- Experimental support for [JSX](https://facebook.github.io/jsx/), a syntax extension for [React](https://facebook.github.io/react/)
|
||||
- Optional tracking of syntax node location (index-based and line-column)
|
||||
- [Heavily tested](http://esprima.org/test/ci.html) (~1500 [unit tests](https://github.com/jquery/esprima/tree/master/test/fixtures) with [full code coverage](https://codecov.io/github/jquery/esprima))
|
||||
|
||||
### API
|
||||
|
||||
Esprima can be used to perform [lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis) (tokenization) or [syntactic analysis](https://en.wikipedia.org/wiki/Parsing) (parsing) of a JavaScript program.
|
||||
|
||||
A simple example on Node.js REPL:
|
||||
|
||||
```javascript
|
||||
> var esprima = require('esprima');
|
||||
> var program = 'const answer = 42';
|
||||
|
||||
> esprima.tokenize(program);
|
||||
[ { type: 'Keyword', value: 'const' },
|
||||
{ type: 'Identifier', value: 'answer' },
|
||||
{ type: 'Punctuator', value: '=' },
|
||||
{ type: 'Numeric', value: '42' } ]
|
||||
|
||||
> esprima.parseScript(program);
|
||||
{ type: 'Program',
|
||||
body:
|
||||
[ { type: 'VariableDeclaration',
|
||||
declarations: [Object],
|
||||
kind: 'const' } ],
|
||||
sourceType: 'script' }
|
||||
```
|
||||
|
||||
For more information, please read the [complete documentation](http://esprima.org/doc).
|
139
tools/doc/node_modules/esprima/bin/esparse.js
generated
vendored
Executable file
139
tools/doc/node_modules/esprima/bin/esparse.js
generated
vendored
Executable file
@ -0,0 +1,139 @@
|
||||
#!/usr/bin/env node
|
||||
/*
|
||||
Copyright JS Foundation and other contributors, https://js.foundation/
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true node:true rhino:true */
|
||||
|
||||
var fs, esprima, fname, forceFile, content, options, syntax;
|
||||
|
||||
if (typeof require === 'function') {
|
||||
fs = require('fs');
|
||||
try {
|
||||
esprima = require('esprima');
|
||||
} catch (e) {
|
||||
esprima = require('../');
|
||||
}
|
||||
} else if (typeof load === 'function') {
|
||||
try {
|
||||
load('esprima.js');
|
||||
} catch (e) {
|
||||
load('../esprima.js');
|
||||
}
|
||||
}
|
||||
|
||||
// Shims to Node.js objects when running under Rhino.
|
||||
if (typeof console === 'undefined' && typeof process === 'undefined') {
|
||||
console = { log: print };
|
||||
fs = { readFileSync: readFile };
|
||||
process = { argv: arguments, exit: quit };
|
||||
process.argv.unshift('esparse.js');
|
||||
process.argv.unshift('rhino');
|
||||
}
|
||||
|
||||
function showUsage() {
|
||||
console.log('Usage:');
|
||||
console.log(' esparse [options] [file.js]');
|
||||
console.log();
|
||||
console.log('Available options:');
|
||||
console.log();
|
||||
console.log(' --comment Gather all line and block comments in an array');
|
||||
console.log(' --loc Include line-column location info for each syntax node');
|
||||
console.log(' --range Include index-based range for each syntax node');
|
||||
console.log(' --raw Display the raw value of literals');
|
||||
console.log(' --tokens List all tokens in an array');
|
||||
console.log(' --tolerant Tolerate errors on a best-effort basis (experimental)');
|
||||
console.log(' -v, --version Shows program version');
|
||||
console.log();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
options = {};
|
||||
|
||||
process.argv.splice(2).forEach(function (entry) {
|
||||
|
||||
if (forceFile || entry === '-' || entry.slice(0, 1) !== '-') {
|
||||
if (typeof fname === 'string') {
|
||||
console.log('Error: more than one input file.');
|
||||
process.exit(1);
|
||||
} else {
|
||||
fname = entry;
|
||||
}
|
||||
} else if (entry === '-h' || entry === '--help') {
|
||||
showUsage();
|
||||
} else if (entry === '-v' || entry === '--version') {
|
||||
console.log('ECMAScript Parser (using Esprima version', esprima.version, ')');
|
||||
console.log();
|
||||
process.exit(0);
|
||||
} else if (entry === '--comment') {
|
||||
options.comment = true;
|
||||
} else if (entry === '--loc') {
|
||||
options.loc = true;
|
||||
} else if (entry === '--range') {
|
||||
options.range = true;
|
||||
} else if (entry === '--raw') {
|
||||
options.raw = true;
|
||||
} else if (entry === '--tokens') {
|
||||
options.tokens = true;
|
||||
} else if (entry === '--tolerant') {
|
||||
options.tolerant = true;
|
||||
} else if (entry === '--') {
|
||||
forceFile = true;
|
||||
} else {
|
||||
console.log('Error: unknown option ' + entry + '.');
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
// Special handling for regular expression literal since we need to
|
||||
// convert it to a string literal, otherwise it will be decoded
|
||||
// as object "{}" and the regular expression would be lost.
|
||||
function adjustRegexLiteral(key, value) {
|
||||
if (key === 'value' && value instanceof RegExp) {
|
||||
value = value.toString();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function run(content) {
|
||||
syntax = esprima.parse(content, options);
|
||||
console.log(JSON.stringify(syntax, adjustRegexLiteral, 4));
|
||||
}
|
||||
|
||||
try {
|
||||
if (fname && (fname !== '-' || forceFile)) {
|
||||
run(fs.readFileSync(fname, 'utf-8'));
|
||||
} else {
|
||||
var content = '';
|
||||
process.stdin.resume();
|
||||
process.stdin.on('data', function(chunk) {
|
||||
content += chunk;
|
||||
});
|
||||
process.stdin.on('end', function() {
|
||||
run(content);
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error: ' + e.message);
|
||||
process.exit(1);
|
||||
}
|
236
tools/doc/node_modules/esprima/bin/esvalidate.js
generated
vendored
Executable file
236
tools/doc/node_modules/esprima/bin/esvalidate.js
generated
vendored
Executable file
@ -0,0 +1,236 @@
|
||||
#!/usr/bin/env node
|
||||
/*
|
||||
Copyright JS Foundation and other contributors, https://js.foundation/
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true plusplus:true node:true rhino:true */
|
||||
/*global phantom:true */
|
||||
|
||||
var fs, system, esprima, options, fnames, forceFile, count;
|
||||
|
||||
if (typeof esprima === 'undefined') {
|
||||
// PhantomJS can only require() relative files
|
||||
if (typeof phantom === 'object') {
|
||||
fs = require('fs');
|
||||
system = require('system');
|
||||
esprima = require('./esprima');
|
||||
} else if (typeof require === 'function') {
|
||||
fs = require('fs');
|
||||
try {
|
||||
esprima = require('esprima');
|
||||
} catch (e) {
|
||||
esprima = require('../');
|
||||
}
|
||||
} else if (typeof load === 'function') {
|
||||
try {
|
||||
load('esprima.js');
|
||||
} catch (e) {
|
||||
load('../esprima.js');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shims to Node.js objects when running under PhantomJS 1.7+.
|
||||
if (typeof phantom === 'object') {
|
||||
fs.readFileSync = fs.read;
|
||||
process = {
|
||||
argv: [].slice.call(system.args),
|
||||
exit: phantom.exit,
|
||||
on: function (evt, callback) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
process.argv.unshift('phantomjs');
|
||||
}
|
||||
|
||||
// Shims to Node.js objects when running under Rhino.
|
||||
if (typeof console === 'undefined' && typeof process === 'undefined') {
|
||||
console = { log: print };
|
||||
fs = { readFileSync: readFile };
|
||||
process = {
|
||||
argv: arguments,
|
||||
exit: quit,
|
||||
on: function (evt, callback) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
process.argv.unshift('esvalidate.js');
|
||||
process.argv.unshift('rhino');
|
||||
}
|
||||
|
||||
function showUsage() {
|
||||
console.log('Usage:');
|
||||
console.log(' esvalidate [options] [file.js...]');
|
||||
console.log();
|
||||
console.log('Available options:');
|
||||
console.log();
|
||||
console.log(' --format=type Set the report format, plain (default) or junit');
|
||||
console.log(' -v, --version Print program version');
|
||||
console.log();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
options = {
|
||||
format: 'plain'
|
||||
};
|
||||
|
||||
fnames = [];
|
||||
|
||||
process.argv.splice(2).forEach(function (entry) {
|
||||
|
||||
if (forceFile || entry === '-' || entry.slice(0, 1) !== '-') {
|
||||
fnames.push(entry);
|
||||
} else if (entry === '-h' || entry === '--help') {
|
||||
showUsage();
|
||||
} else if (entry === '-v' || entry === '--version') {
|
||||
console.log('ECMAScript Validator (using Esprima version', esprima.version, ')');
|
||||
console.log();
|
||||
process.exit(0);
|
||||
} else if (entry.slice(0, 9) === '--format=') {
|
||||
options.format = entry.slice(9);
|
||||
if (options.format !== 'plain' && options.format !== 'junit') {
|
||||
console.log('Error: unknown report format ' + options.format + '.');
|
||||
process.exit(1);
|
||||
}
|
||||
} else if (entry === '--') {
|
||||
forceFile = true;
|
||||
} else {
|
||||
console.log('Error: unknown option ' + entry + '.');
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
if (fnames.length === 0) {
|
||||
fnames.push('');
|
||||
}
|
||||
|
||||
if (options.format === 'junit') {
|
||||
console.log('<?xml version="1.0" encoding="UTF-8"?>');
|
||||
console.log('<testsuites>');
|
||||
}
|
||||
|
||||
count = 0;
|
||||
|
||||
function run(fname, content) {
|
||||
var timestamp, syntax, name;
|
||||
try {
|
||||
if (typeof content !== 'string') {
|
||||
throw content;
|
||||
}
|
||||
|
||||
if (content[0] === '#' && content[1] === '!') {
|
||||
content = '//' + content.substr(2, content.length);
|
||||
}
|
||||
|
||||
timestamp = Date.now();
|
||||
syntax = esprima.parse(content, { tolerant: true });
|
||||
|
||||
if (options.format === 'junit') {
|
||||
|
||||
name = fname;
|
||||
if (name.lastIndexOf('/') >= 0) {
|
||||
name = name.slice(name.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
console.log('<testsuite name="' + fname + '" errors="0" ' +
|
||||
' failures="' + syntax.errors.length + '" ' +
|
||||
' tests="' + syntax.errors.length + '" ' +
|
||||
' time="' + Math.round((Date.now() - timestamp) / 1000) +
|
||||
'">');
|
||||
|
||||
syntax.errors.forEach(function (error) {
|
||||
var msg = error.message;
|
||||
msg = msg.replace(/^Line\ [0-9]*\:\ /, '');
|
||||
console.log(' <testcase name="Line ' + error.lineNumber + ': ' + msg + '" ' +
|
||||
' time="0">');
|
||||
console.log(' <error type="SyntaxError" message="' + error.message + '">' +
|
||||
error.message + '(' + name + ':' + error.lineNumber + ')' +
|
||||
'</error>');
|
||||
console.log(' </testcase>');
|
||||
});
|
||||
|
||||
console.log('</testsuite>');
|
||||
|
||||
} else if (options.format === 'plain') {
|
||||
|
||||
syntax.errors.forEach(function (error) {
|
||||
var msg = error.message;
|
||||
msg = msg.replace(/^Line\ [0-9]*\:\ /, '');
|
||||
msg = fname + ':' + error.lineNumber + ': ' + msg;
|
||||
console.log(msg);
|
||||
++count;
|
||||
});
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
++count;
|
||||
if (options.format === 'junit') {
|
||||
console.log('<testsuite name="' + fname + '" errors="1" failures="0" tests="1" ' +
|
||||
' time="' + Math.round((Date.now() - timestamp) / 1000) + '">');
|
||||
console.log(' <testcase name="' + e.message + '" ' + ' time="0">');
|
||||
console.log(' <error type="ParseError" message="' + e.message + '">' +
|
||||
e.message + '(' + fname + ((e.lineNumber) ? ':' + e.lineNumber : '') +
|
||||
')</error>');
|
||||
console.log(' </testcase>');
|
||||
console.log('</testsuite>');
|
||||
} else {
|
||||
console.log(fname + ':' + e.lineNumber + ': ' + e.message.replace(/^Line\ [0-9]*\:\ /, ''));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fnames.forEach(function (fname) {
|
||||
var content = '';
|
||||
try {
|
||||
if (fname && (fname !== '-' || forceFile)) {
|
||||
content = fs.readFileSync(fname, 'utf-8');
|
||||
} else {
|
||||
fname = '';
|
||||
process.stdin.resume();
|
||||
process.stdin.on('data', function(chunk) {
|
||||
content += chunk;
|
||||
});
|
||||
process.stdin.on('end', function() {
|
||||
run(fname, content);
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
content = e;
|
||||
}
|
||||
run(fname, content);
|
||||
});
|
||||
|
||||
process.on('exit', function () {
|
||||
if (options.format === 'junit') {
|
||||
console.log('</testsuites>');
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (count === 0 && typeof phantom === 'object') {
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
6700
tools/doc/node_modules/esprima/dist/esprima.js
generated
vendored
Normal file
6700
tools/doc/node_modules/esprima/dist/esprima.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
141
tools/doc/node_modules/esprima/package.json
generated
vendored
Normal file
141
tools/doc/node_modules/esprima/package.json
generated
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"esprima@4.0.0",
|
||||
"/Users/rubys/git/node/tools/doc"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "esprima@4.0.0",
|
||||
"_id": "esprima@4.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==",
|
||||
"_location": "/esprima",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "esprima@4.0.0",
|
||||
"name": "esprima",
|
||||
"escapedName": "esprima",
|
||||
"rawSpec": "4.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "4.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/js-yaml"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
|
||||
"_spec": "4.0.0",
|
||||
"_where": "/Users/rubys/git/node/tools/doc",
|
||||
"author": {
|
||||
"name": "Ariya Hidayat",
|
||||
"email": "ariya.hidayat@gmail.com"
|
||||
},
|
||||
"bin": {
|
||||
"esparse": "./bin/esparse.js",
|
||||
"esvalidate": "./bin/esvalidate.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jquery/esprima/issues"
|
||||
},
|
||||
"description": "ECMAScript parsing infrastructure for multipurpose analysis",
|
||||
"devDependencies": {
|
||||
"codecov.io": "~0.1.6",
|
||||
"escomplex-js": "1.2.0",
|
||||
"everything.js": "~1.0.3",
|
||||
"glob": "~7.1.0",
|
||||
"istanbul": "~0.4.0",
|
||||
"json-diff": "~0.3.1",
|
||||
"karma": "~1.3.0",
|
||||
"karma-chrome-launcher": "~2.0.0",
|
||||
"karma-detect-browsers": "~2.2.3",
|
||||
"karma-edge-launcher": "~0.2.0",
|
||||
"karma-firefox-launcher": "~1.0.0",
|
||||
"karma-ie-launcher": "~1.0.0",
|
||||
"karma-mocha": "~1.3.0",
|
||||
"karma-safari-launcher": "~1.0.0",
|
||||
"karma-safaritechpreview-launcher": "~0.0.4",
|
||||
"karma-sauce-launcher": "~1.1.0",
|
||||
"lodash": "~3.10.1",
|
||||
"mocha": "~3.2.0",
|
||||
"node-tick-processor": "~0.0.2",
|
||||
"regenerate": "~1.3.2",
|
||||
"temp": "~0.8.3",
|
||||
"tslint": "~5.1.0",
|
||||
"typescript": "~2.3.2",
|
||||
"typescript-formatter": "~5.1.3",
|
||||
"unicode-8.0.0": "~0.7.0",
|
||||
"webpack": "~1.14.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"dist/esprima.js"
|
||||
],
|
||||
"homepage": "http://esprima.org",
|
||||
"keywords": [
|
||||
"ast",
|
||||
"ecmascript",
|
||||
"esprima",
|
||||
"javascript",
|
||||
"parser",
|
||||
"syntax"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "dist/esprima.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Ariya Hidayat",
|
||||
"email": "ariya.hidayat@gmail.com",
|
||||
"url": "http://ariya.ofilabs.com"
|
||||
}
|
||||
],
|
||||
"name": "esprima",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jquery/esprima.git"
|
||||
},
|
||||
"scripts": {
|
||||
"all-tests": "npm run verify-line-ending && npm run generate-fixtures && npm run unit-tests && npm run api-tests && npm run grammar-tests && npm run regression-tests && npm run hostile-env-tests",
|
||||
"analyze-coverage": "istanbul cover test/unit-tests.js",
|
||||
"api-tests": "mocha -R dot test/api-tests.js",
|
||||
"appveyor": "npm run compile && npm run all-tests && npm run browser-tests",
|
||||
"benchmark": "npm run benchmark-parser && npm run benchmark-tokenizer",
|
||||
"benchmark-parser": "node -expose_gc test/benchmark-parser.js",
|
||||
"benchmark-tokenizer": "node --expose_gc test/benchmark-tokenizer.js",
|
||||
"browser-tests": "npm run compile && npm run generate-fixtures && cd test && karma start --single-run",
|
||||
"check-coverage": "istanbul check-coverage --statement 100 --branch 100 --function 100",
|
||||
"check-version": "node test/check-version.js",
|
||||
"circleci": "npm test && npm run codecov && npm run downstream",
|
||||
"code-style": "tsfmt --verify src/*.ts && tsfmt --verify test/*.js",
|
||||
"codecov": "istanbul report cobertura && codecov < ./coverage/cobertura-coverage.xml",
|
||||
"compile": "tsc -p src/ && webpack && node tools/fixupbundle.js",
|
||||
"complexity": "node test/check-complexity.js",
|
||||
"downstream": "node test/downstream.js",
|
||||
"droneio": "npm run compile && npm run all-tests && npm run saucelabs",
|
||||
"dynamic-analysis": "npm run analyze-coverage && npm run check-coverage",
|
||||
"format-code": "tsfmt -r src/*.ts && tsfmt -r test/*.js",
|
||||
"generate-fixtures": "node tools/generate-fixtures.js",
|
||||
"generate-regex": "node tools/generate-identifier-regex.js",
|
||||
"generate-xhtml-entities": "node tools/generate-xhtml-entities.js",
|
||||
"grammar-tests": "node test/grammar-tests.js",
|
||||
"hostile-env-tests": "node test/hostile-environment-tests.js",
|
||||
"prepublish": "npm run compile",
|
||||
"profile": "node --prof test/profile.js && mv isolate*.log v8.log && node-tick-processor",
|
||||
"regression-tests": "node test/regression-tests.js",
|
||||
"saucelabs": "npm run saucelabs-evergreen && npm run saucelabs-ie && npm run saucelabs-safari",
|
||||
"saucelabs-evergreen": "cd test && karma start saucelabs-evergreen.conf.js",
|
||||
"saucelabs-ie": "cd test && karma start saucelabs-ie.conf.js",
|
||||
"saucelabs-safari": "cd test && karma start saucelabs-safari.conf.js",
|
||||
"static-analysis": "npm run check-version && npm run tslint && npm run code-style && npm run complexity",
|
||||
"test": "npm run compile && npm run all-tests && npm run static-analysis && npm run dynamic-analysis",
|
||||
"travis": "npm test",
|
||||
"tslint": "tslint src/*.ts",
|
||||
"unit-tests": "node test/unit-tests.js",
|
||||
"verify-line-ending": "node test/verify-line-ending.js"
|
||||
},
|
||||
"version": "4.0.0"
|
||||
}
|
21
tools/doc/node_modules/js-yaml/LICENSE
generated
vendored
Normal file
21
tools/doc/node_modules/js-yaml/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (C) 2011-2015 by Vitaly Puzrin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
313
tools/doc/node_modules/js-yaml/README.md
generated
vendored
Normal file
313
tools/doc/node_modules/js-yaml/README.md
generated
vendored
Normal file
@ -0,0 +1,313 @@
|
||||
JS-YAML - YAML 1.2 parser / writer for JavaScript
|
||||
=================================================
|
||||
|
||||
[](https://travis-ci.org/nodeca/js-yaml)
|
||||
[](https://www.npmjs.org/package/js-yaml)
|
||||
|
||||
__[Online Demo](http://nodeca.github.com/js-yaml/)__
|
||||
|
||||
|
||||
This is an implementation of [YAML](http://yaml.org/), a human-friendly data
|
||||
serialization language. Started as [PyYAML](http://pyyaml.org/) port, it was
|
||||
completely rewritten from scratch. Now it's very fast, and supports 1.2 spec.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
### YAML module for node.js
|
||||
|
||||
```
|
||||
npm install js-yaml
|
||||
```
|
||||
|
||||
|
||||
### CLI executable
|
||||
|
||||
If you want to inspect your YAML files from CLI, install js-yaml globally:
|
||||
|
||||
```
|
||||
npm install -g js-yaml
|
||||
```
|
||||
|
||||
#### Usage
|
||||
|
||||
```
|
||||
usage: js-yaml [-h] [-v] [-c] [-t] file
|
||||
|
||||
Positional arguments:
|
||||
file File with YAML document(s)
|
||||
|
||||
Optional arguments:
|
||||
-h, --help Show this help message and exit.
|
||||
-v, --version Show program's version number and exit.
|
||||
-c, --compact Display errors in compact mode
|
||||
-t, --trace Show stack trace on error
|
||||
```
|
||||
|
||||
|
||||
### Bundled YAML library for browsers
|
||||
|
||||
``` html
|
||||
<!-- esprima required only for !!js/function -->
|
||||
<script src="esprima.js"></script>
|
||||
<script src="js-yaml.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var doc = jsyaml.load('greeting: hello\nname: world');
|
||||
</script>
|
||||
```
|
||||
|
||||
Browser support was done mostly for the online demo. If you find any errors - feel
|
||||
free to send pull requests with fixes. Also note, that IE and other old browsers
|
||||
needs [es5-shims](https://github.com/kriskowal/es5-shim) to operate.
|
||||
|
||||
Notes:
|
||||
|
||||
1. We have no resources to support browserified version. Don't expect it to be
|
||||
well tested. Don't expect fast fixes if something goes wrong there.
|
||||
2. `!!js/function` in browser bundle will not work by default. If you really need
|
||||
it - load `esprima` parser first (via amd or directly).
|
||||
3. `!!bin` in browser will return `Array`, because browsers do not support
|
||||
node.js `Buffer` and adding Buffer shims is completely useless on practice.
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
Here we cover the most 'useful' methods. If you need advanced details (creating
|
||||
your own tags), see [wiki](https://github.com/nodeca/js-yaml/wiki) and
|
||||
[examples](https://github.com/nodeca/js-yaml/tree/master/examples) for more
|
||||
info.
|
||||
|
||||
``` javascript
|
||||
yaml = require('js-yaml');
|
||||
fs = require('fs');
|
||||
|
||||
// Get document, or throw exception on error
|
||||
try {
|
||||
var doc = yaml.safeLoad(fs.readFileSync('/home/ixti/example.yml', 'utf8'));
|
||||
console.log(doc);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### safeLoad (string [ , options ])
|
||||
|
||||
**Recommended loading way.** Parses `string` as single YAML document. Returns a JavaScript
|
||||
object or throws `YAMLException` on error. By default, does not support regexps,
|
||||
functions and undefined. This method is safe for untrusted data.
|
||||
|
||||
options:
|
||||
|
||||
- `filename` _(default: null)_ - string to be used as a file path in
|
||||
error/warning messages.
|
||||
- `onWarning` _(default: null)_ - function to call on warning messages.
|
||||
Loader will throw on warnings if this function is not provided.
|
||||
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ - specifies a schema to use.
|
||||
- `FAILSAFE_SCHEMA` - only strings, arrays and plain objects:
|
||||
http://www.yaml.org/spec/1.2/spec.html#id2802346
|
||||
- `JSON_SCHEMA` - all JSON-supported types:
|
||||
http://www.yaml.org/spec/1.2/spec.html#id2803231
|
||||
- `CORE_SCHEMA` - same as `JSON_SCHEMA`:
|
||||
http://www.yaml.org/spec/1.2/spec.html#id2804923
|
||||
- `DEFAULT_SAFE_SCHEMA` - all supported YAML types, without unsafe ones
|
||||
(`!!js/undefined`, `!!js/regexp` and `!!js/function`):
|
||||
http://yaml.org/type/
|
||||
- `DEFAULT_FULL_SCHEMA` - all supported YAML types.
|
||||
- `json` _(default: false)_ - compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error.
|
||||
|
||||
NOTE: This function **does not** understand multi-document sources, it throws
|
||||
exception on those.
|
||||
|
||||
NOTE: JS-YAML **does not** support schema-specific tag resolution restrictions.
|
||||
So, the JSON schema is not as strictly defined in the YAML specification.
|
||||
It allows numbers in any notation, use `Null` and `NULL` as `null`, etc.
|
||||
The core schema also has no such restrictions. It allows binary notation for integers.
|
||||
|
||||
|
||||
### load (string [ , options ])
|
||||
|
||||
**Use with care with untrusted sources**. The same as `safeLoad()` but uses
|
||||
`DEFAULT_FULL_SCHEMA` by default - adds some JavaScript-specific types:
|
||||
`!!js/function`, `!!js/regexp` and `!!js/undefined`. For untrusted sources, you
|
||||
must additionally validate object structure to avoid injections:
|
||||
|
||||
``` javascript
|
||||
var untrusted_code = '"toString": !<tag:yaml.org,2002:js/function> "function (){very_evil_thing();}"';
|
||||
|
||||
// I'm just converting that string, what could possibly go wrong?
|
||||
require('js-yaml').load(untrusted_code) + ''
|
||||
```
|
||||
|
||||
|
||||
### safeLoadAll (string [, iterator] [, options ])
|
||||
|
||||
Same as `safeLoad()`, but understands multi-document sources. Applies
|
||||
`iterator` to each document if specified, or returns array of documents.
|
||||
|
||||
``` javascript
|
||||
var yaml = require('js-yaml');
|
||||
|
||||
yaml.safeLoadAll(data, function (doc) {
|
||||
console.log(doc);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### loadAll (string [, iterator] [ , options ])
|
||||
|
||||
Same as `safeLoadAll()` but uses `DEFAULT_FULL_SCHEMA` by default.
|
||||
|
||||
|
||||
### safeDump (object [ , options ])
|
||||
|
||||
Serializes `object` as a YAML document. Uses `DEFAULT_SAFE_SCHEMA`, so it will
|
||||
throw an exception if you try to dump regexps or functions. However, you can
|
||||
disable exceptions by setting the `skipInvalid` option to `true`.
|
||||
|
||||
options:
|
||||
|
||||
- `indent` _(default: 2)_ - indentation width to use (in spaces).
|
||||
- `skipInvalid` _(default: false)_ - do not throw on invalid types (like function
|
||||
in the safe schema) and skip pairs and single values with such types.
|
||||
- `flowLevel` (default: -1) - specifies level of nesting, when to switch from
|
||||
block to flow style for collections. -1 means block style everwhere
|
||||
- `styles` - "tag" => "style" map. Each tag may have own set of styles.
|
||||
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ specifies a schema to use.
|
||||
- `sortKeys` _(default: `false`)_ - if `true`, sort keys when dumping YAML. If a
|
||||
function, use the function to sort the keys.
|
||||
- `lineWidth` _(default: `80`)_ - set max line width.
|
||||
- `noRefs` _(default: `false`)_ - if `true`, don't convert duplicate objects into references
|
||||
- `noCompatMode` _(default: `false`)_ - if `true` don't try to be compatible with older
|
||||
yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1
|
||||
- `condenseFlow` _(default: `false`)_ - if `true` flow sequences will be condensed, omitting the space between `a, b`. Eg. `'[a,b]'`, and omitting the space between `key: value` and quoting the key. Eg. `'{"a":b}'` Can be useful when using yaml for pretty URL query params as spaces are %-encoded.
|
||||
|
||||
The following table show availlable styles (e.g. "canonical",
|
||||
"binary"...) available for each tag (.e.g. !!null, !!int ...). Yaml
|
||||
output is shown on the right side after `=>` (default setting) or `->`:
|
||||
|
||||
``` none
|
||||
!!null
|
||||
"canonical" -> "~"
|
||||
"lowercase" => "null"
|
||||
"uppercase" -> "NULL"
|
||||
"camelcase" -> "Null"
|
||||
|
||||
!!int
|
||||
"binary" -> "0b1", "0b101010", "0b1110001111010"
|
||||
"octal" -> "01", "052", "016172"
|
||||
"decimal" => "1", "42", "7290"
|
||||
"hexadecimal" -> "0x1", "0x2A", "0x1C7A"
|
||||
|
||||
!!bool
|
||||
"lowercase" => "true", "false"
|
||||
"uppercase" -> "TRUE", "FALSE"
|
||||
"camelcase" -> "True", "False"
|
||||
|
||||
!!float
|
||||
"lowercase" => ".nan", '.inf'
|
||||
"uppercase" -> ".NAN", '.INF'
|
||||
"camelcase" -> ".NaN", '.Inf'
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
``` javascript
|
||||
safeDump (object, {
|
||||
'styles': {
|
||||
'!!null': 'canonical' // dump null as ~
|
||||
},
|
||||
'sortKeys': true // sort object keys
|
||||
});
|
||||
```
|
||||
|
||||
### dump (object [ , options ])
|
||||
|
||||
Same as `safeDump()` but without limits (uses `DEFAULT_FULL_SCHEMA` by default).
|
||||
|
||||
|
||||
Supported YAML types
|
||||
--------------------
|
||||
|
||||
The list of standard YAML tags and corresponding JavaScipt types. See also
|
||||
[YAML tag discussion](http://pyyaml.org/wiki/YAMLTagDiscussion) and
|
||||
[YAML types repository](http://yaml.org/type/).
|
||||
|
||||
```
|
||||
!!null '' # null
|
||||
!!bool 'yes' # bool
|
||||
!!int '3...' # number
|
||||
!!float '3.14...' # number
|
||||
!!binary '...base64...' # buffer
|
||||
!!timestamp 'YYYY-...' # date
|
||||
!!omap [ ... ] # array of key-value pairs
|
||||
!!pairs [ ... ] # array or array pairs
|
||||
!!set { ... } # array of objects with given keys and null values
|
||||
!!str '...' # string
|
||||
!!seq [ ... ] # array
|
||||
!!map { ... } # object
|
||||
```
|
||||
|
||||
**JavaScript-specific tags**
|
||||
|
||||
```
|
||||
!!js/regexp /pattern/gim # RegExp
|
||||
!!js/undefined '' # Undefined
|
||||
!!js/function 'function () {...}' # Function
|
||||
```
|
||||
|
||||
Caveats
|
||||
-------
|
||||
|
||||
Note, that you use arrays or objects as key in JS-YAML. JS does not allow objects
|
||||
or arrays as keys, and stringifies (by calling `toString()` method) them at the
|
||||
moment of adding them.
|
||||
|
||||
``` yaml
|
||||
---
|
||||
? [ foo, bar ]
|
||||
: - baz
|
||||
? { foo: bar }
|
||||
: - baz
|
||||
- baz
|
||||
```
|
||||
|
||||
``` javascript
|
||||
{ "foo,bar": ["baz"], "[object Object]": ["baz", "baz"] }
|
||||
```
|
||||
|
||||
Also, reading of properties on implicit block mapping keys is not supported yet.
|
||||
So, the following YAML document cannot be loaded.
|
||||
|
||||
``` yaml
|
||||
&anchor foo:
|
||||
foo: bar
|
||||
*anchor: duplicate key
|
||||
baz: bat
|
||||
*anchor: duplicate key
|
||||
```
|
||||
|
||||
|
||||
Breaking changes in 2.x.x -> 3.x.x
|
||||
----------------------------------
|
||||
|
||||
If you have not used __custom__ tags or loader classes and not loaded yaml
|
||||
files via `require()`, no changes are needed. Just upgrade the library.
|
||||
|
||||
Otherwise, you should:
|
||||
|
||||
1. Replace all occurrences of `require('xxxx.yml')` by `fs.readFileSync()` +
|
||||
`yaml.safeLoad()`.
|
||||
2. rewrite your custom tags constructors and custom loader
|
||||
classes, to conform the new API. See
|
||||
[examples](https://github.com/nodeca/js-yaml/tree/master/examples) and
|
||||
[wiki](https://github.com/nodeca/js-yaml/wiki) for details.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
View the [LICENSE](https://github.com/nodeca/js-yaml/blob/master/LICENSE) file
|
||||
(MIT).
|
132
tools/doc/node_modules/js-yaml/bin/js-yaml.js
generated
vendored
Executable file
132
tools/doc/node_modules/js-yaml/bin/js-yaml.js
generated
vendored
Executable file
@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
/*eslint-disable no-console*/
|
||||
|
||||
|
||||
// stdlib
|
||||
var fs = require('fs');
|
||||
|
||||
|
||||
// 3rd-party
|
||||
var argparse = require('argparse');
|
||||
|
||||
|
||||
// internal
|
||||
var yaml = require('..');
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
var cli = new argparse.ArgumentParser({
|
||||
prog: 'js-yaml',
|
||||
version: require('../package.json').version,
|
||||
addHelp: true
|
||||
});
|
||||
|
||||
|
||||
cli.addArgument([ '-c', '--compact' ], {
|
||||
help: 'Display errors in compact mode',
|
||||
action: 'storeTrue'
|
||||
});
|
||||
|
||||
|
||||
// deprecated (not needed after we removed output colors)
|
||||
// option suppressed, but not completely removed for compatibility
|
||||
cli.addArgument([ '-j', '--to-json' ], {
|
||||
help: argparse.Const.SUPPRESS,
|
||||
dest: 'json',
|
||||
action: 'storeTrue'
|
||||
});
|
||||
|
||||
|
||||
cli.addArgument([ '-t', '--trace' ], {
|
||||
help: 'Show stack trace on error',
|
||||
action: 'storeTrue'
|
||||
});
|
||||
|
||||
cli.addArgument([ 'file' ], {
|
||||
help: 'File to read, utf-8 encoded without BOM',
|
||||
nargs: '?',
|
||||
defaultValue: '-'
|
||||
});
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
var options = cli.parseArgs();
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function readFile(filename, encoding, callback) {
|
||||
if (options.file === '-') {
|
||||
// read from stdin
|
||||
|
||||
var chunks = [];
|
||||
|
||||
process.stdin.on('data', function (chunk) {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
|
||||
process.stdin.on('end', function () {
|
||||
return callback(null, Buffer.concat(chunks).toString(encoding));
|
||||
});
|
||||
} else {
|
||||
fs.readFile(filename, encoding, callback);
|
||||
}
|
||||
}
|
||||
|
||||
readFile(options.file, 'utf8', function (error, input) {
|
||||
var output, isYaml;
|
||||
|
||||
if (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
console.error('File not found: ' + options.file);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
console.error(
|
||||
options.trace && error.stack ||
|
||||
error.message ||
|
||||
String(error));
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
output = JSON.parse(input);
|
||||
isYaml = false;
|
||||
} catch (err) {
|
||||
if (err instanceof SyntaxError) {
|
||||
try {
|
||||
output = [];
|
||||
yaml.loadAll(input, function (doc) { output.push(doc); }, {});
|
||||
isYaml = true;
|
||||
|
||||
if (output.length === 0) output = null;
|
||||
else if (output.length === 1) output = output[0];
|
||||
|
||||
} catch (e) {
|
||||
if (options.trace && err.stack) console.error(e.stack);
|
||||
else console.error(e.toString(options.compact));
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
console.error(
|
||||
options.trace && err.stack ||
|
||||
err.message ||
|
||||
String(err));
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (isYaml) console.log(JSON.stringify(output, null, ' '));
|
||||
else console.log(yaml.dump(output));
|
||||
});
|
3905
tools/doc/node_modules/js-yaml/dist/js-yaml.js
generated
vendored
Normal file
3905
tools/doc/node_modules/js-yaml/dist/js-yaml.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tools/doc/node_modules/js-yaml/dist/js-yaml.min.js
generated
vendored
Normal file
1
tools/doc/node_modules/js-yaml/dist/js-yaml.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
7
tools/doc/node_modules/js-yaml/index.js
generated
vendored
Normal file
7
tools/doc/node_modules/js-yaml/index.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
var yaml = require('./lib/js-yaml.js');
|
||||
|
||||
|
||||
module.exports = yaml;
|
39
tools/doc/node_modules/js-yaml/lib/js-yaml.js
generated
vendored
Normal file
39
tools/doc/node_modules/js-yaml/lib/js-yaml.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
var loader = require('./js-yaml/loader');
|
||||
var dumper = require('./js-yaml/dumper');
|
||||
|
||||
|
||||
function deprecated(name) {
|
||||
return function () {
|
||||
throw new Error('Function ' + name + ' is deprecated and cannot be used.');
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
module.exports.Type = require('./js-yaml/type');
|
||||
module.exports.Schema = require('./js-yaml/schema');
|
||||
module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe');
|
||||
module.exports.JSON_SCHEMA = require('./js-yaml/schema/json');
|
||||
module.exports.CORE_SCHEMA = require('./js-yaml/schema/core');
|
||||
module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
|
||||
module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full');
|
||||
module.exports.load = loader.load;
|
||||
module.exports.loadAll = loader.loadAll;
|
||||
module.exports.safeLoad = loader.safeLoad;
|
||||
module.exports.safeLoadAll = loader.safeLoadAll;
|
||||
module.exports.dump = dumper.dump;
|
||||
module.exports.safeDump = dumper.safeDump;
|
||||
module.exports.YAMLException = require('./js-yaml/exception');
|
||||
|
||||
// Deprecated schema names from JS-YAML 2.0.x
|
||||
module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe');
|
||||
module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
|
||||
module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full');
|
||||
|
||||
// Deprecated functions from JS-YAML 1.x.x
|
||||
module.exports.scan = deprecated('scan');
|
||||
module.exports.parse = deprecated('parse');
|
||||
module.exports.compose = deprecated('compose');
|
||||
module.exports.addConstructor = deprecated('addConstructor');
|
59
tools/doc/node_modules/js-yaml/lib/js-yaml/common.js
generated
vendored
Normal file
59
tools/doc/node_modules/js-yaml/lib/js-yaml/common.js
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
function isNothing(subject) {
|
||||
return (typeof subject === 'undefined') || (subject === null);
|
||||
}
|
||||
|
||||
|
||||
function isObject(subject) {
|
||||
return (typeof subject === 'object') && (subject !== null);
|
||||
}
|
||||
|
||||
|
||||
function toArray(sequence) {
|
||||
if (Array.isArray(sequence)) return sequence;
|
||||
else if (isNothing(sequence)) return [];
|
||||
|
||||
return [ sequence ];
|
||||
}
|
||||
|
||||
|
||||
function extend(target, source) {
|
||||
var index, length, key, sourceKeys;
|
||||
|
||||
if (source) {
|
||||
sourceKeys = Object.keys(source);
|
||||
|
||||
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
||||
key = sourceKeys[index];
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
function repeat(string, count) {
|
||||
var result = '', cycle;
|
||||
|
||||
for (cycle = 0; cycle < count; cycle += 1) {
|
||||
result += string;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
function isNegativeZero(number) {
|
||||
return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
|
||||
}
|
||||
|
||||
|
||||
module.exports.isNothing = isNothing;
|
||||
module.exports.isObject = isObject;
|
||||
module.exports.toArray = toArray;
|
||||
module.exports.repeat = repeat;
|
||||
module.exports.isNegativeZero = isNegativeZero;
|
||||
module.exports.extend = extend;
|
819
tools/doc/node_modules/js-yaml/lib/js-yaml/dumper.js
generated
vendored
Normal file
819
tools/doc/node_modules/js-yaml/lib/js-yaml/dumper.js
generated
vendored
Normal file
@ -0,0 +1,819 @@
|
||||
'use strict';
|
||||
|
||||
/*eslint-disable no-use-before-define*/
|
||||
|
||||
var common = require('./common');
|
||||
var YAMLException = require('./exception');
|
||||
var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
|
||||
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
|
||||
|
||||
var _toString = Object.prototype.toString;
|
||||
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
var CHAR_TAB = 0x09; /* Tab */
|
||||
var CHAR_LINE_FEED = 0x0A; /* LF */
|
||||
var CHAR_SPACE = 0x20; /* Space */
|
||||
var CHAR_EXCLAMATION = 0x21; /* ! */
|
||||
var CHAR_DOUBLE_QUOTE = 0x22; /* " */
|
||||
var CHAR_SHARP = 0x23; /* # */
|
||||
var CHAR_PERCENT = 0x25; /* % */
|
||||
var CHAR_AMPERSAND = 0x26; /* & */
|
||||
var CHAR_SINGLE_QUOTE = 0x27; /* ' */
|
||||
var CHAR_ASTERISK = 0x2A; /* * */
|
||||
var CHAR_COMMA = 0x2C; /* , */
|
||||
var CHAR_MINUS = 0x2D; /* - */
|
||||
var CHAR_COLON = 0x3A; /* : */
|
||||
var CHAR_GREATER_THAN = 0x3E; /* > */
|
||||
var CHAR_QUESTION = 0x3F; /* ? */
|
||||
var CHAR_COMMERCIAL_AT = 0x40; /* @ */
|
||||
var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
|
||||
var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
|
||||
var CHAR_GRAVE_ACCENT = 0x60; /* ` */
|
||||
var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
|
||||
var CHAR_VERTICAL_LINE = 0x7C; /* | */
|
||||
var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
|
||||
|
||||
var ESCAPE_SEQUENCES = {};
|
||||
|
||||
ESCAPE_SEQUENCES[0x00] = '\\0';
|
||||
ESCAPE_SEQUENCES[0x07] = '\\a';
|
||||
ESCAPE_SEQUENCES[0x08] = '\\b';
|
||||
ESCAPE_SEQUENCES[0x09] = '\\t';
|
||||
ESCAPE_SEQUENCES[0x0A] = '\\n';
|
||||
ESCAPE_SEQUENCES[0x0B] = '\\v';
|
||||
ESCAPE_SEQUENCES[0x0C] = '\\f';
|
||||
ESCAPE_SEQUENCES[0x0D] = '\\r';
|
||||
ESCAPE_SEQUENCES[0x1B] = '\\e';
|
||||
ESCAPE_SEQUENCES[0x22] = '\\"';
|
||||
ESCAPE_SEQUENCES[0x5C] = '\\\\';
|
||||
ESCAPE_SEQUENCES[0x85] = '\\N';
|
||||
ESCAPE_SEQUENCES[0xA0] = '\\_';
|
||||
ESCAPE_SEQUENCES[0x2028] = '\\L';
|
||||
ESCAPE_SEQUENCES[0x2029] = '\\P';
|
||||
|
||||
var DEPRECATED_BOOLEANS_SYNTAX = [
|
||||
'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
|
||||
'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
|
||||
];
|
||||
|
||||
function compileStyleMap(schema, map) {
|
||||
var result, keys, index, length, tag, style, type;
|
||||
|
||||
if (map === null) return {};
|
||||
|
||||
result = {};
|
||||
keys = Object.keys(map);
|
||||
|
||||
for (index = 0, length = keys.length; index < length; index += 1) {
|
||||
tag = keys[index];
|
||||
style = String(map[tag]);
|
||||
|
||||
if (tag.slice(0, 2) === '!!') {
|
||||
tag = 'tag:yaml.org,2002:' + tag.slice(2);
|
||||
}
|
||||
type = schema.compiledTypeMap['fallback'][tag];
|
||||
|
||||
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
||||
style = type.styleAliases[style];
|
||||
}
|
||||
|
||||
result[tag] = style;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function encodeHex(character) {
|
||||
var string, handle, length;
|
||||
|
||||
string = character.toString(16).toUpperCase();
|
||||
|
||||
if (character <= 0xFF) {
|
||||
handle = 'x';
|
||||
length = 2;
|
||||
} else if (character <= 0xFFFF) {
|
||||
handle = 'u';
|
||||
length = 4;
|
||||
} else if (character <= 0xFFFFFFFF) {
|
||||
handle = 'U';
|
||||
length = 8;
|
||||
} else {
|
||||
throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
|
||||
}
|
||||
|
||||
return '\\' + handle + common.repeat('0', length - string.length) + string;
|
||||
}
|
||||
|
||||
function State(options) {
|
||||
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
||||
this.indent = Math.max(1, (options['indent'] || 2));
|
||||
this.skipInvalid = options['skipInvalid'] || false;
|
||||
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
|
||||
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
|
||||
this.sortKeys = options['sortKeys'] || false;
|
||||
this.lineWidth = options['lineWidth'] || 80;
|
||||
this.noRefs = options['noRefs'] || false;
|
||||
this.noCompatMode = options['noCompatMode'] || false;
|
||||
this.condenseFlow = options['condenseFlow'] || false;
|
||||
|
||||
this.implicitTypes = this.schema.compiledImplicit;
|
||||
this.explicitTypes = this.schema.compiledExplicit;
|
||||
|
||||
this.tag = null;
|
||||
this.result = '';
|
||||
|
||||
this.duplicates = [];
|
||||
this.usedDuplicates = null;
|
||||
}
|
||||
|
||||
// Indents every line in a string. Empty lines (\n only) are not indented.
|
||||
function indentString(string, spaces) {
|
||||
var ind = common.repeat(' ', spaces),
|
||||
position = 0,
|
||||
next = -1,
|
||||
result = '',
|
||||
line,
|
||||
length = string.length;
|
||||
|
||||
while (position < length) {
|
||||
next = string.indexOf('\n', position);
|
||||
if (next === -1) {
|
||||
line = string.slice(position);
|
||||
position = length;
|
||||
} else {
|
||||
line = string.slice(position, next + 1);
|
||||
position = next + 1;
|
||||
}
|
||||
|
||||
if (line.length && line !== '\n') result += ind;
|
||||
|
||||
result += line;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function generateNextLine(state, level) {
|
||||
return '\n' + common.repeat(' ', state.indent * level);
|
||||
}
|
||||
|
||||
function testImplicitResolving(state, str) {
|
||||
var index, length, type;
|
||||
|
||||
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
||||
type = state.implicitTypes[index];
|
||||
|
||||
if (type.resolve(str)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// [33] s-white ::= s-space | s-tab
|
||||
function isWhitespace(c) {
|
||||
return c === CHAR_SPACE || c === CHAR_TAB;
|
||||
}
|
||||
|
||||
// Returns true if the character can be printed without escaping.
|
||||
// From YAML 1.2: "any allowed characters known to be non-printable
|
||||
// should also be escaped. [However,] This isn’t mandatory"
|
||||
// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
|
||||
function isPrintable(c) {
|
||||
return (0x00020 <= c && c <= 0x00007E)
|
||||
|| ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
|
||||
|| ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */)
|
||||
|| (0x10000 <= c && c <= 0x10FFFF);
|
||||
}
|
||||
|
||||
// Simplified test for values allowed after the first character in plain style.
|
||||
function isPlainSafe(c) {
|
||||
// Uses a subset of nb-char - c-flow-indicator - ":" - "#"
|
||||
// where nb-char ::= c-printable - b-char - c-byte-order-mark.
|
||||
return isPrintable(c) && c !== 0xFEFF
|
||||
// - c-flow-indicator
|
||||
&& c !== CHAR_COMMA
|
||||
&& c !== CHAR_LEFT_SQUARE_BRACKET
|
||||
&& c !== CHAR_RIGHT_SQUARE_BRACKET
|
||||
&& c !== CHAR_LEFT_CURLY_BRACKET
|
||||
&& c !== CHAR_RIGHT_CURLY_BRACKET
|
||||
// - ":" - "#"
|
||||
&& c !== CHAR_COLON
|
||||
&& c !== CHAR_SHARP;
|
||||
}
|
||||
|
||||
// Simplified test for values allowed as the first character in plain style.
|
||||
function isPlainSafeFirst(c) {
|
||||
// Uses a subset of ns-char - c-indicator
|
||||
// where ns-char = nb-char - s-white.
|
||||
return isPrintable(c) && c !== 0xFEFF
|
||||
&& !isWhitespace(c) // - s-white
|
||||
// - (c-indicator ::=
|
||||
// “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
|
||||
&& c !== CHAR_MINUS
|
||||
&& c !== CHAR_QUESTION
|
||||
&& c !== CHAR_COLON
|
||||
&& c !== CHAR_COMMA
|
||||
&& c !== CHAR_LEFT_SQUARE_BRACKET
|
||||
&& c !== CHAR_RIGHT_SQUARE_BRACKET
|
||||
&& c !== CHAR_LEFT_CURLY_BRACKET
|
||||
&& c !== CHAR_RIGHT_CURLY_BRACKET
|
||||
// | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"”
|
||||
&& c !== CHAR_SHARP
|
||||
&& c !== CHAR_AMPERSAND
|
||||
&& c !== CHAR_ASTERISK
|
||||
&& c !== CHAR_EXCLAMATION
|
||||
&& c !== CHAR_VERTICAL_LINE
|
||||
&& c !== CHAR_GREATER_THAN
|
||||
&& c !== CHAR_SINGLE_QUOTE
|
||||
&& c !== CHAR_DOUBLE_QUOTE
|
||||
// | “%” | “@” | “`”)
|
||||
&& c !== CHAR_PERCENT
|
||||
&& c !== CHAR_COMMERCIAL_AT
|
||||
&& c !== CHAR_GRAVE_ACCENT;
|
||||
}
|
||||
|
||||
var STYLE_PLAIN = 1,
|
||||
STYLE_SINGLE = 2,
|
||||
STYLE_LITERAL = 3,
|
||||
STYLE_FOLDED = 4,
|
||||
STYLE_DOUBLE = 5;
|
||||
|
||||
// Determines which scalar styles are possible and returns the preferred style.
|
||||
// lineWidth = -1 => no limit.
|
||||
// Pre-conditions: str.length > 0.
|
||||
// Post-conditions:
|
||||
// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
|
||||
// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
|
||||
// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
|
||||
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
|
||||
var i;
|
||||
var char;
|
||||
var hasLineBreak = false;
|
||||
var hasFoldableLine = false; // only checked if shouldTrackWidth
|
||||
var shouldTrackWidth = lineWidth !== -1;
|
||||
var previousLineBreak = -1; // count the first line correctly
|
||||
var plain = isPlainSafeFirst(string.charCodeAt(0))
|
||||
&& !isWhitespace(string.charCodeAt(string.length - 1));
|
||||
|
||||
if (singleLineOnly) {
|
||||
// Case: no block styles.
|
||||
// Check for disallowed characters to rule out plain and single.
|
||||
for (i = 0; i < string.length; i++) {
|
||||
char = string.charCodeAt(i);
|
||||
if (!isPrintable(char)) {
|
||||
return STYLE_DOUBLE;
|
||||
}
|
||||
plain = plain && isPlainSafe(char);
|
||||
}
|
||||
} else {
|
||||
// Case: block styles permitted.
|
||||
for (i = 0; i < string.length; i++) {
|
||||
char = string.charCodeAt(i);
|
||||
if (char === CHAR_LINE_FEED) {
|
||||
hasLineBreak = true;
|
||||
// Check if any line can be folded.
|
||||
if (shouldTrackWidth) {
|
||||
hasFoldableLine = hasFoldableLine ||
|
||||
// Foldable line = too long, and not more-indented.
|
||||
(i - previousLineBreak - 1 > lineWidth &&
|
||||
string[previousLineBreak + 1] !== ' ');
|
||||
previousLineBreak = i;
|
||||
}
|
||||
} else if (!isPrintable(char)) {
|
||||
return STYLE_DOUBLE;
|
||||
}
|
||||
plain = plain && isPlainSafe(char);
|
||||
}
|
||||
// in case the end is missing a \n
|
||||
hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
|
||||
(i - previousLineBreak - 1 > lineWidth &&
|
||||
string[previousLineBreak + 1] !== ' '));
|
||||
}
|
||||
// Although every style can represent \n without escaping, prefer block styles
|
||||
// for multiline, since they're more readable and they don't add empty lines.
|
||||
// Also prefer folding a super-long line.
|
||||
if (!hasLineBreak && !hasFoldableLine) {
|
||||
// Strings interpretable as another type have to be quoted;
|
||||
// e.g. the string 'true' vs. the boolean true.
|
||||
return plain && !testAmbiguousType(string)
|
||||
? STYLE_PLAIN : STYLE_SINGLE;
|
||||
}
|
||||
// Edge case: block indentation indicator can only have one digit.
|
||||
if (string[0] === ' ' && indentPerLevel > 9) {
|
||||
return STYLE_DOUBLE;
|
||||
}
|
||||
// At this point we know block styles are valid.
|
||||
// Prefer literal style unless we want to fold.
|
||||
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
||||
}
|
||||
|
||||
// Note: line breaking/folding is implemented for only the folded style.
|
||||
// NB. We drop the last trailing newline (if any) of a returned block scalar
|
||||
// since the dumper adds its own newline. This always works:
|
||||
// • No ending newline => unaffected; already using strip "-" chomping.
|
||||
// • Ending newline => removed then restored.
|
||||
// Importantly, this keeps the "+" chomp indicator from gaining an extra line.
|
||||
function writeScalar(state, string, level, iskey) {
|
||||
state.dump = (function () {
|
||||
if (string.length === 0) {
|
||||
return "''";
|
||||
}
|
||||
if (!state.noCompatMode &&
|
||||
DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
|
||||
return "'" + string + "'";
|
||||
}
|
||||
|
||||
var indent = state.indent * Math.max(1, level); // no 0-indent scalars
|
||||
// As indentation gets deeper, let the width decrease monotonically
|
||||
// to the lower bound min(state.lineWidth, 40).
|
||||
// Note that this implies
|
||||
// state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
|
||||
// state.lineWidth > 40 + state.indent: width decreases until the lower bound.
|
||||
// This behaves better than a constant minimum width which disallows narrower options,
|
||||
// or an indent threshold which causes the width to suddenly increase.
|
||||
var lineWidth = state.lineWidth === -1
|
||||
? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
||||
|
||||
// Without knowing if keys are implicit/explicit, assume implicit for safety.
|
||||
var singleLineOnly = iskey
|
||||
// No block styles in flow mode.
|
||||
|| (state.flowLevel > -1 && level >= state.flowLevel);
|
||||
function testAmbiguity(string) {
|
||||
return testImplicitResolving(state, string);
|
||||
}
|
||||
|
||||
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
|
||||
case STYLE_PLAIN:
|
||||
return string;
|
||||
case STYLE_SINGLE:
|
||||
return "'" + string.replace(/'/g, "''") + "'";
|
||||
case STYLE_LITERAL:
|
||||
return '|' + blockHeader(string, state.indent)
|
||||
+ dropEndingNewline(indentString(string, indent));
|
||||
case STYLE_FOLDED:
|
||||
return '>' + blockHeader(string, state.indent)
|
||||
+ dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
||||
case STYLE_DOUBLE:
|
||||
return '"' + escapeString(string, lineWidth) + '"';
|
||||
default:
|
||||
throw new YAMLException('impossible error: invalid scalar style');
|
||||
}
|
||||
}());
|
||||
}
|
||||
|
||||
// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
|
||||
function blockHeader(string, indentPerLevel) {
|
||||
var indentIndicator = (string[0] === ' ') ? String(indentPerLevel) : '';
|
||||
|
||||
// note the special case: the string '\n' counts as a "trailing" empty line.
|
||||
var clip = string[string.length - 1] === '\n';
|
||||
var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
|
||||
var chomp = keep ? '+' : (clip ? '' : '-');
|
||||
|
||||
return indentIndicator + chomp + '\n';
|
||||
}
|
||||
|
||||
// (See the note for writeScalar.)
|
||||
function dropEndingNewline(string) {
|
||||
return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
|
||||
}
|
||||
|
||||
// Note: a long line without a suitable break point will exceed the width limit.
|
||||
// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
|
||||
function foldString(string, width) {
|
||||
// In folded style, $k$ consecutive newlines output as $k+1$ newlines—
|
||||
// unless they're before or after a more-indented line, or at the very
|
||||
// beginning or end, in which case $k$ maps to $k$.
|
||||
// Therefore, parse each chunk as newline(s) followed by a content line.
|
||||
var lineRe = /(\n+)([^\n]*)/g;
|
||||
|
||||
// first line (possibly an empty line)
|
||||
var result = (function () {
|
||||
var nextLF = string.indexOf('\n');
|
||||
nextLF = nextLF !== -1 ? nextLF : string.length;
|
||||
lineRe.lastIndex = nextLF;
|
||||
return foldLine(string.slice(0, nextLF), width);
|
||||
}());
|
||||
// If we haven't reached the first content line yet, don't add an extra \n.
|
||||
var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
|
||||
var moreIndented;
|
||||
|
||||
// rest of the lines
|
||||
var match;
|
||||
while ((match = lineRe.exec(string))) {
|
||||
var prefix = match[1], line = match[2];
|
||||
moreIndented = (line[0] === ' ');
|
||||
result += prefix
|
||||
+ (!prevMoreIndented && !moreIndented && line !== ''
|
||||
? '\n' : '')
|
||||
+ foldLine(line, width);
|
||||
prevMoreIndented = moreIndented;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Greedy line breaking.
|
||||
// Picks the longest line under the limit each time,
|
||||
// otherwise settles for the shortest line over the limit.
|
||||
// NB. More-indented lines *cannot* be folded, as that would add an extra \n.
|
||||
function foldLine(line, width) {
|
||||
if (line === '' || line[0] === ' ') return line;
|
||||
|
||||
// Since a more-indented line adds a \n, breaks can't be followed by a space.
|
||||
var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
|
||||
var match;
|
||||
// start is an inclusive index. end, curr, and next are exclusive.
|
||||
var start = 0, end, curr = 0, next = 0;
|
||||
var result = '';
|
||||
|
||||
// Invariants: 0 <= start <= length-1.
|
||||
// 0 <= curr <= next <= max(0, length-2). curr - start <= width.
|
||||
// Inside the loop:
|
||||
// A match implies length >= 2, so curr and next are <= length-2.
|
||||
while ((match = breakRe.exec(line))) {
|
||||
next = match.index;
|
||||
// maintain invariant: curr - start <= width
|
||||
if (next - start > width) {
|
||||
end = (curr > start) ? curr : next; // derive end <= length-2
|
||||
result += '\n' + line.slice(start, end);
|
||||
// skip the space that was output as \n
|
||||
start = end + 1; // derive start <= length-1
|
||||
}
|
||||
curr = next;
|
||||
}
|
||||
|
||||
// By the invariants, start <= length-1, so there is something left over.
|
||||
// It is either the whole string or a part starting from non-whitespace.
|
||||
result += '\n';
|
||||
// Insert a break if the remainder is too long and there is a break available.
|
||||
if (line.length - start > width && curr > start) {
|
||||
result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
|
||||
} else {
|
||||
result += line.slice(start);
|
||||
}
|
||||
|
||||
return result.slice(1); // drop extra \n joiner
|
||||
}
|
||||
|
||||
// Escapes a double-quoted string.
|
||||
function escapeString(string) {
|
||||
var result = '';
|
||||
var char, nextChar;
|
||||
var escapeSeq;
|
||||
|
||||
for (var i = 0; i < string.length; i++) {
|
||||
char = string.charCodeAt(i);
|
||||
// Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates").
|
||||
if (char >= 0xD800 && char <= 0xDBFF/* high surrogate */) {
|
||||
nextChar = string.charCodeAt(i + 1);
|
||||
if (nextChar >= 0xDC00 && nextChar <= 0xDFFF/* low surrogate */) {
|
||||
// Combine the surrogate pair and store it escaped.
|
||||
result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000);
|
||||
// Advance index one extra since we already used that char here.
|
||||
i++; continue;
|
||||
}
|
||||
}
|
||||
escapeSeq = ESCAPE_SEQUENCES[char];
|
||||
result += !escapeSeq && isPrintable(char)
|
||||
? string[i]
|
||||
: escapeSeq || encodeHex(char);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function writeFlowSequence(state, level, object) {
|
||||
var _result = '',
|
||||
_tag = state.tag,
|
||||
index,
|
||||
length;
|
||||
|
||||
for (index = 0, length = object.length; index < length; index += 1) {
|
||||
// Write only valid elements.
|
||||
if (writeNode(state, level, object[index], false, false)) {
|
||||
if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : '');
|
||||
_result += state.dump;
|
||||
}
|
||||
}
|
||||
|
||||
state.tag = _tag;
|
||||
state.dump = '[' + _result + ']';
|
||||
}
|
||||
|
||||
function writeBlockSequence(state, level, object, compact) {
|
||||
var _result = '',
|
||||
_tag = state.tag,
|
||||
index,
|
||||
length;
|
||||
|
||||
for (index = 0, length = object.length; index < length; index += 1) {
|
||||
// Write only valid elements.
|
||||
if (writeNode(state, level + 1, object[index], true, true)) {
|
||||
if (!compact || index !== 0) {
|
||||
_result += generateNextLine(state, level);
|
||||
}
|
||||
|
||||
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
||||
_result += '-';
|
||||
} else {
|
||||
_result += '- ';
|
||||
}
|
||||
|
||||
_result += state.dump;
|
||||
}
|
||||
}
|
||||
|
||||
state.tag = _tag;
|
||||
state.dump = _result || '[]'; // Empty sequence if no valid values.
|
||||
}
|
||||
|
||||
function writeFlowMapping(state, level, object) {
|
||||
var _result = '',
|
||||
_tag = state.tag,
|
||||
objectKeyList = Object.keys(object),
|
||||
index,
|
||||
length,
|
||||
objectKey,
|
||||
objectValue,
|
||||
pairBuffer;
|
||||
|
||||
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||
pairBuffer = state.condenseFlow ? '"' : '';
|
||||
|
||||
if (index !== 0) pairBuffer += ', ';
|
||||
|
||||
objectKey = objectKeyList[index];
|
||||
objectValue = object[objectKey];
|
||||
|
||||
if (!writeNode(state, level, objectKey, false, false)) {
|
||||
continue; // Skip this pair because of invalid key;
|
||||
}
|
||||
|
||||
if (state.dump.length > 1024) pairBuffer += '? ';
|
||||
|
||||
pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
|
||||
|
||||
if (!writeNode(state, level, objectValue, false, false)) {
|
||||
continue; // Skip this pair because of invalid value.
|
||||
}
|
||||
|
||||
pairBuffer += state.dump;
|
||||
|
||||
// Both key and value are valid.
|
||||
_result += pairBuffer;
|
||||
}
|
||||
|
||||
state.tag = _tag;
|
||||
state.dump = '{' + _result + '}';
|
||||
}
|
||||
|
||||
function writeBlockMapping(state, level, object, compact) {
|
||||
var _result = '',
|
||||
_tag = state.tag,
|
||||
objectKeyList = Object.keys(object),
|
||||
index,
|
||||
length,
|
||||
objectKey,
|
||||
objectValue,
|
||||
explicitPair,
|
||||
pairBuffer;
|
||||
|
||||
// Allow sorting keys so that the output file is deterministic
|
||||
if (state.sortKeys === true) {
|
||||
// Default sorting
|
||||
objectKeyList.sort();
|
||||
} else if (typeof state.sortKeys === 'function') {
|
||||
// Custom sort function
|
||||
objectKeyList.sort(state.sortKeys);
|
||||
} else if (state.sortKeys) {
|
||||
// Something is wrong
|
||||
throw new YAMLException('sortKeys must be a boolean or a function');
|
||||
}
|
||||
|
||||
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||
pairBuffer = '';
|
||||
|
||||
if (!compact || index !== 0) {
|
||||
pairBuffer += generateNextLine(state, level);
|
||||
}
|
||||
|
||||
objectKey = objectKeyList[index];
|
||||
objectValue = object[objectKey];
|
||||
|
||||
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
||||
continue; // Skip this pair because of invalid key.
|
||||
}
|
||||
|
||||
explicitPair = (state.tag !== null && state.tag !== '?') ||
|
||||
(state.dump && state.dump.length > 1024);
|
||||
|
||||
if (explicitPair) {
|
||||
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
||||
pairBuffer += '?';
|
||||
} else {
|
||||
pairBuffer += '? ';
|
||||
}
|
||||
}
|
||||
|
||||
pairBuffer += state.dump;
|
||||
|
||||
if (explicitPair) {
|
||||
pairBuffer += generateNextLine(state, level);
|
||||
}
|
||||
|
||||
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
||||
continue; // Skip this pair because of invalid value.
|
||||
}
|
||||
|
||||
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
||||
pairBuffer += ':';
|
||||
} else {
|
||||
pairBuffer += ': ';
|
||||
}
|
||||
|
||||
pairBuffer += state.dump;
|
||||
|
||||
// Both key and value are valid.
|
||||
_result += pairBuffer;
|
||||
}
|
||||
|
||||
state.tag = _tag;
|
||||
state.dump = _result || '{}'; // Empty mapping if no valid pairs.
|
||||
}
|
||||
|
||||
function detectType(state, object, explicit) {
|
||||
var _result, typeList, index, length, type, style;
|
||||
|
||||
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
||||
|
||||
for (index = 0, length = typeList.length; index < length; index += 1) {
|
||||
type = typeList[index];
|
||||
|
||||
if ((type.instanceOf || type.predicate) &&
|
||||
(!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
|
||||
(!type.predicate || type.predicate(object))) {
|
||||
|
||||
state.tag = explicit ? type.tag : '?';
|
||||
|
||||
if (type.represent) {
|
||||
style = state.styleMap[type.tag] || type.defaultStyle;
|
||||
|
||||
if (_toString.call(type.represent) === '[object Function]') {
|
||||
_result = type.represent(object, style);
|
||||
} else if (_hasOwnProperty.call(type.represent, style)) {
|
||||
_result = type.represent[style](object, style);
|
||||
} else {
|
||||
throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
|
||||
}
|
||||
|
||||
state.dump = _result;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Serializes `object` and writes it to global `result`.
|
||||
// Returns true on success, or false on invalid object.
|
||||
//
|
||||
function writeNode(state, level, object, block, compact, iskey) {
|
||||
state.tag = null;
|
||||
state.dump = object;
|
||||
|
||||
if (!detectType(state, object, false)) {
|
||||
detectType(state, object, true);
|
||||
}
|
||||
|
||||
var type = _toString.call(state.dump);
|
||||
|
||||
if (block) {
|
||||
block = (state.flowLevel < 0 || state.flowLevel > level);
|
||||
}
|
||||
|
||||
var objectOrArray = type === '[object Object]' || type === '[object Array]',
|
||||
duplicateIndex,
|
||||
duplicate;
|
||||
|
||||
if (objectOrArray) {
|
||||
duplicateIndex = state.duplicates.indexOf(object);
|
||||
duplicate = duplicateIndex !== -1;
|
||||
}
|
||||
|
||||
if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
|
||||
compact = false;
|
||||
}
|
||||
|
||||
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
||||
state.dump = '*ref_' + duplicateIndex;
|
||||
} else {
|
||||
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
||||
state.usedDuplicates[duplicateIndex] = true;
|
||||
}
|
||||
if (type === '[object Object]') {
|
||||
if (block && (Object.keys(state.dump).length !== 0)) {
|
||||
writeBlockMapping(state, level, state.dump, compact);
|
||||
if (duplicate) {
|
||||
state.dump = '&ref_' + duplicateIndex + state.dump;
|
||||
}
|
||||
} else {
|
||||
writeFlowMapping(state, level, state.dump);
|
||||
if (duplicate) {
|
||||
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
|
||||
}
|
||||
}
|
||||
} else if (type === '[object Array]') {
|
||||
if (block && (state.dump.length !== 0)) {
|
||||
writeBlockSequence(state, level, state.dump, compact);
|
||||
if (duplicate) {
|
||||
state.dump = '&ref_' + duplicateIndex + state.dump;
|
||||
}
|
||||
} else {
|
||||
writeFlowSequence(state, level, state.dump);
|
||||
if (duplicate) {
|
||||
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
|
||||
}
|
||||
}
|
||||
} else if (type === '[object String]') {
|
||||
if (state.tag !== '?') {
|
||||
writeScalar(state, state.dump, level, iskey);
|
||||
}
|
||||
} else {
|
||||
if (state.skipInvalid) return false;
|
||||
throw new YAMLException('unacceptable kind of an object to dump ' + type);
|
||||
}
|
||||
|
||||
if (state.tag !== null && state.tag !== '?') {
|
||||
state.dump = '!<' + state.tag + '> ' + state.dump;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getDuplicateReferences(object, state) {
|
||||
var objects = [],
|
||||
duplicatesIndexes = [],
|
||||
index,
|
||||
length;
|
||||
|
||||
inspectNode(object, objects, duplicatesIndexes);
|
||||
|
||||
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
||||
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
||||
}
|
||||
state.usedDuplicates = new Array(length);
|
||||
}
|
||||
|
||||
function inspectNode(object, objects, duplicatesIndexes) {
|
||||
var objectKeyList,
|
||||
index,
|
||||
length;
|
||||
|
||||
if (object !== null && typeof object === 'object') {
|
||||
index = objects.indexOf(object);
|
||||
if (index !== -1) {
|
||||
if (duplicatesIndexes.indexOf(index) === -1) {
|
||||
duplicatesIndexes.push(index);
|
||||
}
|
||||
} else {
|
||||
objects.push(object);
|
||||
|
||||
if (Array.isArray(object)) {
|
||||
for (index = 0, length = object.length; index < length; index += 1) {
|
||||
inspectNode(object[index], objects, duplicatesIndexes);
|
||||
}
|
||||
} else {
|
||||
objectKeyList = Object.keys(object);
|
||||
|
||||
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function dump(input, options) {
|
||||
options = options || {};
|
||||
|
||||
var state = new State(options);
|
||||
|
||||
if (!state.noRefs) getDuplicateReferences(input, state);
|
||||
|
||||
if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function safeDump(input, options) {
|
||||
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
||||
}
|
||||
|
||||
module.exports.dump = dump;
|
||||
module.exports.safeDump = safeDump;
|
43
tools/doc/node_modules/js-yaml/lib/js-yaml/exception.js
generated
vendored
Normal file
43
tools/doc/node_modules/js-yaml/lib/js-yaml/exception.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
// YAML error class. http://stackoverflow.com/questions/8458984
|
||||
//
|
||||
'use strict';
|
||||
|
||||
function YAMLException(reason, mark) {
|
||||
// Super constructor
|
||||
Error.call(this);
|
||||
|
||||
this.name = 'YAMLException';
|
||||
this.reason = reason;
|
||||
this.mark = mark;
|
||||
this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
|
||||
|
||||
// Include stack trace in error object
|
||||
if (Error.captureStackTrace) {
|
||||
// Chrome and NodeJS
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
} else {
|
||||
// FF, IE 10+ and Safari 6+. Fallback for others
|
||||
this.stack = (new Error()).stack || '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Inherit from Error
|
||||
YAMLException.prototype = Object.create(Error.prototype);
|
||||
YAMLException.prototype.constructor = YAMLException;
|
||||
|
||||
|
||||
YAMLException.prototype.toString = function toString(compact) {
|
||||
var result = this.name + ': ';
|
||||
|
||||
result += this.reason || '(unknown reason)';
|
||||
|
||||
if (!compact && this.mark) {
|
||||
result += ' ' + this.mark.toString();
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
module.exports = YAMLException;
|
1598
tools/doc/node_modules/js-yaml/lib/js-yaml/loader.js
generated
vendored
Normal file
1598
tools/doc/node_modules/js-yaml/lib/js-yaml/loader.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
76
tools/doc/node_modules/js-yaml/lib/js-yaml/mark.js
generated
vendored
Normal file
76
tools/doc/node_modules/js-yaml/lib/js-yaml/mark.js
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
var common = require('./common');
|
||||
|
||||
|
||||
function Mark(name, buffer, position, line, column) {
|
||||
this.name = name;
|
||||
this.buffer = buffer;
|
||||
this.position = position;
|
||||
this.line = line;
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
|
||||
Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
|
||||
var head, start, tail, end, snippet;
|
||||
|
||||
if (!this.buffer) return null;
|
||||
|
||||
indent = indent || 4;
|
||||
maxLength = maxLength || 75;
|
||||
|
||||
head = '';
|
||||
start = this.position;
|
||||
|
||||
while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
|
||||
start -= 1;
|
||||
if (this.position - start > (maxLength / 2 - 1)) {
|
||||
head = ' ... ';
|
||||
start += 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tail = '';
|
||||
end = this.position;
|
||||
|
||||
while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
|
||||
end += 1;
|
||||
if (end - this.position > (maxLength / 2 - 1)) {
|
||||
tail = ' ... ';
|
||||
end -= 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
snippet = this.buffer.slice(start, end);
|
||||
|
||||
return common.repeat(' ', indent) + head + snippet + tail + '\n' +
|
||||
common.repeat(' ', indent + this.position - start + head.length) + '^';
|
||||
};
|
||||
|
||||
|
||||
Mark.prototype.toString = function toString(compact) {
|
||||
var snippet, where = '';
|
||||
|
||||
if (this.name) {
|
||||
where += 'in "' + this.name + '" ';
|
||||
}
|
||||
|
||||
where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
|
||||
|
||||
if (!compact) {
|
||||
snippet = this.getSnippet();
|
||||
|
||||
if (snippet) {
|
||||
where += ':\n' + snippet;
|
||||
}
|
||||
}
|
||||
|
||||
return where;
|
||||
};
|
||||
|
||||
|
||||
module.exports = Mark;
|
108
tools/doc/node_modules/js-yaml/lib/js-yaml/schema.js
generated
vendored
Normal file
108
tools/doc/node_modules/js-yaml/lib/js-yaml/schema.js
generated
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
'use strict';
|
||||
|
||||
/*eslint-disable max-len*/
|
||||
|
||||
var common = require('./common');
|
||||
var YAMLException = require('./exception');
|
||||
var Type = require('./type');
|
||||
|
||||
|
||||
function compileList(schema, name, result) {
|
||||
var exclude = [];
|
||||
|
||||
schema.include.forEach(function (includedSchema) {
|
||||
result = compileList(includedSchema, name, result);
|
||||
});
|
||||
|
||||
schema[name].forEach(function (currentType) {
|
||||
result.forEach(function (previousType, previousIndex) {
|
||||
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
|
||||
exclude.push(previousIndex);
|
||||
}
|
||||
});
|
||||
|
||||
result.push(currentType);
|
||||
});
|
||||
|
||||
return result.filter(function (type, index) {
|
||||
return exclude.indexOf(index) === -1;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function compileMap(/* lists... */) {
|
||||
var result = {
|
||||
scalar: {},
|
||||
sequence: {},
|
||||
mapping: {},
|
||||
fallback: {}
|
||||
}, index, length;
|
||||
|
||||
function collectType(type) {
|
||||
result[type.kind][type.tag] = result['fallback'][type.tag] = type;
|
||||
}
|
||||
|
||||
for (index = 0, length = arguments.length; index < length; index += 1) {
|
||||
arguments[index].forEach(collectType);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
function Schema(definition) {
|
||||
this.include = definition.include || [];
|
||||
this.implicit = definition.implicit || [];
|
||||
this.explicit = definition.explicit || [];
|
||||
|
||||
this.implicit.forEach(function (type) {
|
||||
if (type.loadKind && type.loadKind !== 'scalar') {
|
||||
throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
|
||||
}
|
||||
});
|
||||
|
||||
this.compiledImplicit = compileList(this, 'implicit', []);
|
||||
this.compiledExplicit = compileList(this, 'explicit', []);
|
||||
this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
|
||||
}
|
||||
|
||||
|
||||
Schema.DEFAULT = null;
|
||||
|
||||
|
||||
Schema.create = function createSchema() {
|
||||
var schemas, types;
|
||||
|
||||
switch (arguments.length) {
|
||||
case 1:
|
||||
schemas = Schema.DEFAULT;
|
||||
types = arguments[0];
|
||||
break;
|
||||
|
||||
case 2:
|
||||
schemas = arguments[0];
|
||||
types = arguments[1];
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new YAMLException('Wrong number of arguments for Schema.create function');
|
||||
}
|
||||
|
||||
schemas = common.toArray(schemas);
|
||||
types = common.toArray(types);
|
||||
|
||||
if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
|
||||
throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
|
||||
}
|
||||
|
||||
if (!types.every(function (type) { return type instanceof Type; })) {
|
||||
throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
|
||||
}
|
||||
|
||||
return new Schema({
|
||||
include: schemas,
|
||||
explicit: types
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports = Schema;
|
18
tools/doc/node_modules/js-yaml/lib/js-yaml/schema/core.js
generated
vendored
Normal file
18
tools/doc/node_modules/js-yaml/lib/js-yaml/schema/core.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
// Standard YAML's Core schema.
|
||||
// http://www.yaml.org/spec/1.2/spec.html#id2804923
|
||||
//
|
||||
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
|
||||
// So, Core schema has no distinctions from JSON schema is JS-YAML.
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
var Schema = require('../schema');
|
||||
|
||||
|
||||
module.exports = new Schema({
|
||||
include: [
|
||||
require('./json')
|
||||
]
|
||||
});
|
25
tools/doc/node_modules/js-yaml/lib/js-yaml/schema/default_full.js
generated
vendored
Normal file
25
tools/doc/node_modules/js-yaml/lib/js-yaml/schema/default_full.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// JS-YAML's default schema for `load` function.
|
||||
// It is not described in the YAML specification.
|
||||
//
|
||||
// This schema is based on JS-YAML's default safe schema and includes
|
||||
// JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
|
||||
//
|
||||
// Also this schema is used as default base schema at `Schema.create` function.
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
var Schema = require('../schema');
|
||||
|
||||
|
||||
module.exports = Schema.DEFAULT = new Schema({
|
||||
include: [
|
||||
require('./default_safe')
|
||||
],
|
||||
explicit: [
|
||||
require('../type/js/undefined'),
|
||||
require('../type/js/regexp'),
|
||||
require('../type/js/function')
|
||||
]
|
||||
});
|
28
tools/doc/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js
generated
vendored
Normal file
28
tools/doc/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// JS-YAML's default schema for `safeLoad` function.
|
||||
// It is not described in the YAML specification.
|
||||
//
|
||||
// This schema is based on standard YAML's Core schema and includes most of
|
||||
// extra types described at YAML tag repository. (http://yaml.org/type/)
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
var Schema = require('../schema');
|
||||
|
||||
|
||||
module.exports = new Schema({
|
||||
include: [
|
||||
require('./core')
|
||||
],
|
||||
implicit: [
|
||||
require('../type/timestamp'),
|
||||
require('../type/merge')
|
||||
],
|
||||
explicit: [
|
||||
require('../type/binary'),
|
||||
require('../type/omap'),
|
||||
require('../type/pairs'),
|
||||
require('../type/set')
|
||||
]
|
||||
});
|
17
tools/doc/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js
generated
vendored
Normal file
17
tools/doc/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Standard YAML's Failsafe schema.
|
||||
// http://www.yaml.org/spec/1.2/spec.html#id2802346
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
var Schema = require('../schema');
|
||||
|
||||
|
||||
module.exports = new Schema({
|
||||
explicit: [
|
||||
require('../type/str'),
|
||||
require('../type/seq'),
|
||||
require('../type/map')
|
||||
]
|
||||
});
|
25
tools/doc/node_modules/js-yaml/lib/js-yaml/schema/json.js
generated
vendored
Normal file
25
tools/doc/node_modules/js-yaml/lib/js-yaml/schema/json.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Standard YAML's JSON schema.
|
||||
// http://www.yaml.org/spec/1.2/spec.html#id2803231
|
||||
//
|
||||
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
|
||||
// So, this schema is not such strict as defined in the YAML specification.
|
||||
// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
var Schema = require('../schema');
|
||||
|
||||
|
||||
module.exports = new Schema({
|
||||
include: [
|
||||
require('./failsafe')
|
||||
],
|
||||
implicit: [
|
||||
require('../type/null'),
|
||||
require('../type/bool'),
|
||||
require('../type/int'),
|
||||
require('../type/float')
|
||||
]
|
||||
});
|
61
tools/doc/node_modules/js-yaml/lib/js-yaml/type.js
generated
vendored
Normal file
61
tools/doc/node_modules/js-yaml/lib/js-yaml/type.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
|
||||
var YAMLException = require('./exception');
|
||||
|
||||
var TYPE_CONSTRUCTOR_OPTIONS = [
|
||||
'kind',
|
||||
'resolve',
|
||||
'construct',
|
||||
'instanceOf',
|
||||
'predicate',
|
||||
'represent',
|
||||
'defaultStyle',
|
||||
'styleAliases'
|
||||
];
|
||||
|
||||
var YAML_NODE_KINDS = [
|
||||
'scalar',
|
||||
'sequence',
|
||||
'mapping'
|
||||
];
|
||||
|
||||
function compileStyleAliases(map) {
|
||||
var result = {};
|
||||
|
||||
if (map !== null) {
|
||||
Object.keys(map).forEach(function (style) {
|
||||
map[style].forEach(function (alias) {
|
||||
result[String(alias)] = style;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function Type(tag, options) {
|
||||
options = options || {};
|
||||
|
||||
Object.keys(options).forEach(function (name) {
|
||||
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
||||
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Add tag format check.
|
||||
this.tag = tag;
|
||||
this.kind = options['kind'] || null;
|
||||
this.resolve = options['resolve'] || function () { return true; };
|
||||
this.construct = options['construct'] || function (data) { return data; };
|
||||
this.instanceOf = options['instanceOf'] || null;
|
||||
this.predicate = options['predicate'] || null;
|
||||
this.represent = options['represent'] || null;
|
||||
this.defaultStyle = options['defaultStyle'] || null;
|
||||
this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
|
||||
|
||||
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
||||
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Type;
|
138
tools/doc/node_modules/js-yaml/lib/js-yaml/type/binary.js
generated
vendored
Normal file
138
tools/doc/node_modules/js-yaml/lib/js-yaml/type/binary.js
generated
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
'use strict';
|
||||
|
||||
/*eslint-disable no-bitwise*/
|
||||
|
||||
var NodeBuffer;
|
||||
|
||||
try {
|
||||
// A trick for browserified version, to not include `Buffer` shim
|
||||
var _require = require;
|
||||
NodeBuffer = _require('buffer').Buffer;
|
||||
} catch (__) {}
|
||||
|
||||
var Type = require('../type');
|
||||
|
||||
|
||||
// [ 64, 65, 66 ] -> [ padding, CR, LF ]
|
||||
var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
|
||||
|
||||
|
||||
function resolveYamlBinary(data) {
|
||||
if (data === null) return false;
|
||||
|
||||
var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
|
||||
|
||||
// Convert one by one.
|
||||
for (idx = 0; idx < max; idx++) {
|
||||
code = map.indexOf(data.charAt(idx));
|
||||
|
||||
// Skip CR/LF
|
||||
if (code > 64) continue;
|
||||
|
||||
// Fail on illegal characters
|
||||
if (code < 0) return false;
|
||||
|
||||
bitlen += 6;
|
||||
}
|
||||
|
||||
// If there are any bits left, source was corrupted
|
||||
return (bitlen % 8) === 0;
|
||||
}
|
||||
|
||||
function constructYamlBinary(data) {
|
||||
var idx, tailbits,
|
||||
input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
|
||||
max = input.length,
|
||||
map = BASE64_MAP,
|
||||
bits = 0,
|
||||
result = [];
|
||||
|
||||
// Collect by 6*4 bits (3 bytes)
|
||||
|
||||
for (idx = 0; idx < max; idx++) {
|
||||
if ((idx % 4 === 0) && idx) {
|
||||
result.push((bits >> 16) & 0xFF);
|
||||
result.push((bits >> 8) & 0xFF);
|
||||
result.push(bits & 0xFF);
|
||||
}
|
||||
|
||||
bits = (bits << 6) | map.indexOf(input.charAt(idx));
|
||||
}
|
||||
|
||||
// Dump tail
|
||||
|
||||
tailbits = (max % 4) * 6;
|
||||
|
||||
if (tailbits === 0) {
|
||||
result.push((bits >> 16) & 0xFF);
|
||||
result.push((bits >> 8) & 0xFF);
|
||||
result.push(bits & 0xFF);
|
||||
} else if (tailbits === 18) {
|
||||
result.push((bits >> 10) & 0xFF);
|
||||
result.push((bits >> 2) & 0xFF);
|
||||
} else if (tailbits === 12) {
|
||||
result.push((bits >> 4) & 0xFF);
|
||||
}
|
||||
|
||||
// Wrap into Buffer for NodeJS and leave Array for browser
|
||||
if (NodeBuffer) {
|
||||
// Support node 6.+ Buffer API when available
|
||||
return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function representYamlBinary(object /*, style*/) {
|
||||
var result = '', bits = 0, idx, tail,
|
||||
max = object.length,
|
||||
map = BASE64_MAP;
|
||||
|
||||
// Convert every three bytes to 4 ASCII characters.
|
||||
|
||||
for (idx = 0; idx < max; idx++) {
|
||||
if ((idx % 3 === 0) && idx) {
|
||||
result += map[(bits >> 18) & 0x3F];
|
||||
result += map[(bits >> 12) & 0x3F];
|
||||
result += map[(bits >> 6) & 0x3F];
|
||||
result += map[bits & 0x3F];
|
||||
}
|
||||
|
||||
bits = (bits << 8) + object[idx];
|
||||
}
|
||||
|
||||
// Dump tail
|
||||
|
||||
tail = max % 3;
|
||||
|
||||
if (tail === 0) {
|
||||
result += map[(bits >> 18) & 0x3F];
|
||||
result += map[(bits >> 12) & 0x3F];
|
||||
result += map[(bits >> 6) & 0x3F];
|
||||
result += map[bits & 0x3F];
|
||||
} else if (tail === 2) {
|
||||
result += map[(bits >> 10) & 0x3F];
|
||||
result += map[(bits >> 4) & 0x3F];
|
||||
result += map[(bits << 2) & 0x3F];
|
||||
result += map[64];
|
||||
} else if (tail === 1) {
|
||||
result += map[(bits >> 2) & 0x3F];
|
||||
result += map[(bits << 4) & 0x3F];
|
||||
result += map[64];
|
||||
result += map[64];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function isBinary(object) {
|
||||
return NodeBuffer && NodeBuffer.isBuffer(object);
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:binary', {
|
||||
kind: 'scalar',
|
||||
resolve: resolveYamlBinary,
|
||||
construct: constructYamlBinary,
|
||||
predicate: isBinary,
|
||||
represent: representYamlBinary
|
||||
});
|
35
tools/doc/node_modules/js-yaml/lib/js-yaml/type/bool.js
generated
vendored
Normal file
35
tools/doc/node_modules/js-yaml/lib/js-yaml/type/bool.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
var Type = require('../type');
|
||||
|
||||
function resolveYamlBoolean(data) {
|
||||
if (data === null) return false;
|
||||
|
||||
var max = data.length;
|
||||
|
||||
return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
|
||||
(max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
|
||||
}
|
||||
|
||||
function constructYamlBoolean(data) {
|
||||
return data === 'true' ||
|
||||
data === 'True' ||
|
||||
data === 'TRUE';
|
||||
}
|
||||
|
||||
function isBoolean(object) {
|
||||
return Object.prototype.toString.call(object) === '[object Boolean]';
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:bool', {
|
||||
kind: 'scalar',
|
||||
resolve: resolveYamlBoolean,
|
||||
construct: constructYamlBoolean,
|
||||
predicate: isBoolean,
|
||||
represent: {
|
||||
lowercase: function (object) { return object ? 'true' : 'false'; },
|
||||
uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
|
||||
camelcase: function (object) { return object ? 'True' : 'False'; }
|
||||
},
|
||||
defaultStyle: 'lowercase'
|
||||
});
|
116
tools/doc/node_modules/js-yaml/lib/js-yaml/type/float.js
generated
vendored
Normal file
116
tools/doc/node_modules/js-yaml/lib/js-yaml/type/float.js
generated
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
'use strict';
|
||||
|
||||
var common = require('../common');
|
||||
var Type = require('../type');
|
||||
|
||||
var YAML_FLOAT_PATTERN = new RegExp(
|
||||
// 2.5e4, 2.5 and integers
|
||||
'^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
|
||||
// .2e4, .2
|
||||
// special case, seems not from spec
|
||||
'|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
|
||||
// 20:59
|
||||
'|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
|
||||
// .inf
|
||||
'|[-+]?\\.(?:inf|Inf|INF)' +
|
||||
// .nan
|
||||
'|\\.(?:nan|NaN|NAN))$');
|
||||
|
||||
function resolveYamlFloat(data) {
|
||||
if (data === null) return false;
|
||||
|
||||
if (!YAML_FLOAT_PATTERN.test(data) ||
|
||||
// Quick hack to not allow integers end with `_`
|
||||
// Probably should update regexp & check speed
|
||||
data[data.length - 1] === '_') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function constructYamlFloat(data) {
|
||||
var value, sign, base, digits;
|
||||
|
||||
value = data.replace(/_/g, '').toLowerCase();
|
||||
sign = value[0] === '-' ? -1 : 1;
|
||||
digits = [];
|
||||
|
||||
if ('+-'.indexOf(value[0]) >= 0) {
|
||||
value = value.slice(1);
|
||||
}
|
||||
|
||||
if (value === '.inf') {
|
||||
return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
||||
|
||||
} else if (value === '.nan') {
|
||||
return NaN;
|
||||
|
||||
} else if (value.indexOf(':') >= 0) {
|
||||
value.split(':').forEach(function (v) {
|
||||
digits.unshift(parseFloat(v, 10));
|
||||
});
|
||||
|
||||
value = 0.0;
|
||||
base = 1;
|
||||
|
||||
digits.forEach(function (d) {
|
||||
value += d * base;
|
||||
base *= 60;
|
||||
});
|
||||
|
||||
return sign * value;
|
||||
|
||||
}
|
||||
return sign * parseFloat(value, 10);
|
||||
}
|
||||
|
||||
|
||||
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
||||
|
||||
function representYamlFloat(object, style) {
|
||||
var res;
|
||||
|
||||
if (isNaN(object)) {
|
||||
switch (style) {
|
||||
case 'lowercase': return '.nan';
|
||||
case 'uppercase': return '.NAN';
|
||||
case 'camelcase': return '.NaN';
|
||||
}
|
||||
} else if (Number.POSITIVE_INFINITY === object) {
|
||||
switch (style) {
|
||||
case 'lowercase': return '.inf';
|
||||
case 'uppercase': return '.INF';
|
||||
case 'camelcase': return '.Inf';
|
||||
}
|
||||
} else if (Number.NEGATIVE_INFINITY === object) {
|
||||
switch (style) {
|
||||
case 'lowercase': return '-.inf';
|
||||
case 'uppercase': return '-.INF';
|
||||
case 'camelcase': return '-.Inf';
|
||||
}
|
||||
} else if (common.isNegativeZero(object)) {
|
||||
return '-0.0';
|
||||
}
|
||||
|
||||
res = object.toString(10);
|
||||
|
||||
// JS stringifier can build scientific format without dots: 5e-100,
|
||||
// while YAML requres dot: 5.e-100. Fix it with simple hack
|
||||
|
||||
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
|
||||
}
|
||||
|
||||
function isFloat(object) {
|
||||
return (Object.prototype.toString.call(object) === '[object Number]') &&
|
||||
(object % 1 !== 0 || common.isNegativeZero(object));
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:float', {
|
||||
kind: 'scalar',
|
||||
resolve: resolveYamlFloat,
|
||||
construct: constructYamlFloat,
|
||||
predicate: isFloat,
|
||||
represent: representYamlFloat,
|
||||
defaultStyle: 'lowercase'
|
||||
});
|
173
tools/doc/node_modules/js-yaml/lib/js-yaml/type/int.js
generated
vendored
Normal file
173
tools/doc/node_modules/js-yaml/lib/js-yaml/type/int.js
generated
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
'use strict';
|
||||
|
||||
var common = require('../common');
|
||||
var Type = require('../type');
|
||||
|
||||
function isHexCode(c) {
|
||||
return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
|
||||
((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
|
||||
((0x61/* a */ <= c) && (c <= 0x66/* f */));
|
||||
}
|
||||
|
||||
function isOctCode(c) {
|
||||
return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
|
||||
}
|
||||
|
||||
function isDecCode(c) {
|
||||
return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
|
||||
}
|
||||
|
||||
function resolveYamlInteger(data) {
|
||||
if (data === null) return false;
|
||||
|
||||
var max = data.length,
|
||||
index = 0,
|
||||
hasDigits = false,
|
||||
ch;
|
||||
|
||||
if (!max) return false;
|
||||
|
||||
ch = data[index];
|
||||
|
||||
// sign
|
||||
if (ch === '-' || ch === '+') {
|
||||
ch = data[++index];
|
||||
}
|
||||
|
||||
if (ch === '0') {
|
||||
// 0
|
||||
if (index + 1 === max) return true;
|
||||
ch = data[++index];
|
||||
|
||||
// base 2, base 8, base 16
|
||||
|
||||
if (ch === 'b') {
|
||||
// base 2
|
||||
index++;
|
||||
|
||||
for (; index < max; index++) {
|
||||
ch = data[index];
|
||||
if (ch === '_') continue;
|
||||
if (ch !== '0' && ch !== '1') return false;
|
||||
hasDigits = true;
|
||||
}
|
||||
return hasDigits && ch !== '_';
|
||||
}
|
||||
|
||||
|
||||
if (ch === 'x') {
|
||||
// base 16
|
||||
index++;
|
||||
|
||||
for (; index < max; index++) {
|
||||
ch = data[index];
|
||||
if (ch === '_') continue;
|
||||
if (!isHexCode(data.charCodeAt(index))) return false;
|
||||
hasDigits = true;
|
||||
}
|
||||
return hasDigits && ch !== '_';
|
||||
}
|
||||
|
||||
// base 8
|
||||
for (; index < max; index++) {
|
||||
ch = data[index];
|
||||
if (ch === '_') continue;
|
||||
if (!isOctCode(data.charCodeAt(index))) return false;
|
||||
hasDigits = true;
|
||||
}
|
||||
return hasDigits && ch !== '_';
|
||||
}
|
||||
|
||||
// base 10 (except 0) or base 60
|
||||
|
||||
// value should not start with `_`;
|
||||
if (ch === '_') return false;
|
||||
|
||||
for (; index < max; index++) {
|
||||
ch = data[index];
|
||||
if (ch === '_') continue;
|
||||
if (ch === ':') break;
|
||||
if (!isDecCode(data.charCodeAt(index))) {
|
||||
return false;
|
||||
}
|
||||
hasDigits = true;
|
||||
}
|
||||
|
||||
// Should have digits and should not end with `_`
|
||||
if (!hasDigits || ch === '_') return false;
|
||||
|
||||
// if !base60 - done;
|
||||
if (ch !== ':') return true;
|
||||
|
||||
// base60 almost not used, no needs to optimize
|
||||
return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
|
||||
}
|
||||
|
||||
function constructYamlInteger(data) {
|
||||
var value = data, sign = 1, ch, base, digits = [];
|
||||
|
||||
if (value.indexOf('_') !== -1) {
|
||||
value = value.replace(/_/g, '');
|
||||
}
|
||||
|
||||
ch = value[0];
|
||||
|
||||
if (ch === '-' || ch === '+') {
|
||||
if (ch === '-') sign = -1;
|
||||
value = value.slice(1);
|
||||
ch = value[0];
|
||||
}
|
||||
|
||||
if (value === '0') return 0;
|
||||
|
||||
if (ch === '0') {
|
||||
if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
|
||||
if (value[1] === 'x') return sign * parseInt(value, 16);
|
||||
return sign * parseInt(value, 8);
|
||||
}
|
||||
|
||||
if (value.indexOf(':') !== -1) {
|
||||
value.split(':').forEach(function (v) {
|
||||
digits.unshift(parseInt(v, 10));
|
||||
});
|
||||
|
||||
value = 0;
|
||||
base = 1;
|
||||
|
||||
digits.forEach(function (d) {
|
||||
value += (d * base);
|
||||
base *= 60;
|
||||
});
|
||||
|
||||
return sign * value;
|
||||
|
||||
}
|
||||
|
||||
return sign * parseInt(value, 10);
|
||||
}
|
||||
|
||||
function isInteger(object) {
|
||||
return (Object.prototype.toString.call(object)) === '[object Number]' &&
|
||||
(object % 1 === 0 && !common.isNegativeZero(object));
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:int', {
|
||||
kind: 'scalar',
|
||||
resolve: resolveYamlInteger,
|
||||
construct: constructYamlInteger,
|
||||
predicate: isInteger,
|
||||
represent: {
|
||||
binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); },
|
||||
octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); },
|
||||
decimal: function (obj) { return obj.toString(10); },
|
||||
/* eslint-disable max-len */
|
||||
hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); }
|
||||
},
|
||||
defaultStyle: 'decimal',
|
||||
styleAliases: {
|
||||
binary: [ 2, 'bin' ],
|
||||
octal: [ 8, 'oct' ],
|
||||
decimal: [ 10, 'dec' ],
|
||||
hexadecimal: [ 16, 'hex' ]
|
||||
}
|
||||
});
|
86
tools/doc/node_modules/js-yaml/lib/js-yaml/type/js/function.js
generated
vendored
Normal file
86
tools/doc/node_modules/js-yaml/lib/js-yaml/type/js/function.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
'use strict';
|
||||
|
||||
var esprima;
|
||||
|
||||
// Browserified version does not have esprima
|
||||
//
|
||||
// 1. For node.js just require module as deps
|
||||
// 2. For browser try to require mudule via external AMD system.
|
||||
// If not found - try to fallback to window.esprima. If not
|
||||
// found too - then fail to parse.
|
||||
//
|
||||
try {
|
||||
// workaround to exclude package from browserify list.
|
||||
var _require = require;
|
||||
esprima = _require('esprima');
|
||||
} catch (_) {
|
||||
/*global window */
|
||||
if (typeof window !== 'undefined') esprima = window.esprima;
|
||||
}
|
||||
|
||||
var Type = require('../../type');
|
||||
|
||||
function resolveJavascriptFunction(data) {
|
||||
if (data === null) return false;
|
||||
|
||||
try {
|
||||
var source = '(' + data + ')',
|
||||
ast = esprima.parse(source, { range: true });
|
||||
|
||||
if (ast.type !== 'Program' ||
|
||||
ast.body.length !== 1 ||
|
||||
ast.body[0].type !== 'ExpressionStatement' ||
|
||||
(ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
|
||||
ast.body[0].expression.type !== 'FunctionExpression')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function constructJavascriptFunction(data) {
|
||||
/*jslint evil:true*/
|
||||
|
||||
var source = '(' + data + ')',
|
||||
ast = esprima.parse(source, { range: true }),
|
||||
params = [],
|
||||
body;
|
||||
|
||||
if (ast.type !== 'Program' ||
|
||||
ast.body.length !== 1 ||
|
||||
ast.body[0].type !== 'ExpressionStatement' ||
|
||||
(ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
|
||||
ast.body[0].expression.type !== 'FunctionExpression')) {
|
||||
throw new Error('Failed to resolve function');
|
||||
}
|
||||
|
||||
ast.body[0].expression.params.forEach(function (param) {
|
||||
params.push(param.name);
|
||||
});
|
||||
|
||||
body = ast.body[0].expression.body.range;
|
||||
|
||||
// Esprima's ranges include the first '{' and the last '}' characters on
|
||||
// function expressions. So cut them out.
|
||||
/*eslint-disable no-new-func*/
|
||||
return new Function(params, source.slice(body[0] + 1, body[1] - 1));
|
||||
}
|
||||
|
||||
function representJavascriptFunction(object /*, style*/) {
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
function isFunction(object) {
|
||||
return Object.prototype.toString.call(object) === '[object Function]';
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:js/function', {
|
||||
kind: 'scalar',
|
||||
resolve: resolveJavascriptFunction,
|
||||
construct: constructJavascriptFunction,
|
||||
predicate: isFunction,
|
||||
represent: representJavascriptFunction
|
||||
});
|
60
tools/doc/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js
generated
vendored
Normal file
60
tools/doc/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
var Type = require('../../type');
|
||||
|
||||
function resolveJavascriptRegExp(data) {
|
||||
if (data === null) return false;
|
||||
if (data.length === 0) return false;
|
||||
|
||||
var regexp = data,
|
||||
tail = /\/([gim]*)$/.exec(data),
|
||||
modifiers = '';
|
||||
|
||||
// if regexp starts with '/' it can have modifiers and must be properly closed
|
||||
// `/foo/gim` - modifiers tail can be maximum 3 chars
|
||||
if (regexp[0] === '/') {
|
||||
if (tail) modifiers = tail[1];
|
||||
|
||||
if (modifiers.length > 3) return false;
|
||||
// if expression starts with /, is should be properly terminated
|
||||
if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function constructJavascriptRegExp(data) {
|
||||
var regexp = data,
|
||||
tail = /\/([gim]*)$/.exec(data),
|
||||
modifiers = '';
|
||||
|
||||
// `/foo/gim` - tail can be maximum 4 chars
|
||||
if (regexp[0] === '/') {
|
||||
if (tail) modifiers = tail[1];
|
||||
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
|
||||
}
|
||||
|
||||
return new RegExp(regexp, modifiers);
|
||||
}
|
||||
|
||||
function representJavascriptRegExp(object /*, style*/) {
|
||||
var result = '/' + object.source + '/';
|
||||
|
||||
if (object.global) result += 'g';
|
||||
if (object.multiline) result += 'm';
|
||||
if (object.ignoreCase) result += 'i';
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function isRegExp(object) {
|
||||
return Object.prototype.toString.call(object) === '[object RegExp]';
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:js/regexp', {
|
||||
kind: 'scalar',
|
||||
resolve: resolveJavascriptRegExp,
|
||||
construct: constructJavascriptRegExp,
|
||||
predicate: isRegExp,
|
||||
represent: representJavascriptRegExp
|
||||
});
|
28
tools/doc/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js
generated
vendored
Normal file
28
tools/doc/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
var Type = require('../../type');
|
||||
|
||||
function resolveJavascriptUndefined() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function constructJavascriptUndefined() {
|
||||
/*eslint-disable no-undefined*/
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function representJavascriptUndefined() {
|
||||
return '';
|
||||
}
|
||||
|
||||
function isUndefined(object) {
|
||||
return typeof object === 'undefined';
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:js/undefined', {
|
||||
kind: 'scalar',
|
||||
resolve: resolveJavascriptUndefined,
|
||||
construct: constructJavascriptUndefined,
|
||||
predicate: isUndefined,
|
||||
represent: representJavascriptUndefined
|
||||
});
|
8
tools/doc/node_modules/js-yaml/lib/js-yaml/type/map.js
generated
vendored
Normal file
8
tools/doc/node_modules/js-yaml/lib/js-yaml/type/map.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var Type = require('../type');
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:map', {
|
||||
kind: 'mapping',
|
||||
construct: function (data) { return data !== null ? data : {}; }
|
||||
});
|
12
tools/doc/node_modules/js-yaml/lib/js-yaml/type/merge.js
generated
vendored
Normal file
12
tools/doc/node_modules/js-yaml/lib/js-yaml/type/merge.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
var Type = require('../type');
|
||||
|
||||
function resolveYamlMerge(data) {
|
||||
return data === '<<' || data === null;
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:merge', {
|
||||
kind: 'scalar',
|
||||
resolve: resolveYamlMerge
|
||||
});
|
34
tools/doc/node_modules/js-yaml/lib/js-yaml/type/null.js
generated
vendored
Normal file
34
tools/doc/node_modules/js-yaml/lib/js-yaml/type/null.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
var Type = require('../type');
|
||||
|
||||
function resolveYamlNull(data) {
|
||||
if (data === null) return true;
|
||||
|
||||
var max = data.length;
|
||||
|
||||
return (max === 1 && data === '~') ||
|
||||
(max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
|
||||
}
|
||||
|
||||
function constructYamlNull() {
|
||||
return null;
|
||||
}
|
||||
|
||||
function isNull(object) {
|
||||
return object === null;
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:null', {
|
||||
kind: 'scalar',
|
||||
resolve: resolveYamlNull,
|
||||
construct: constructYamlNull,
|
||||
predicate: isNull,
|
||||
represent: {
|
||||
canonical: function () { return '~'; },
|
||||
lowercase: function () { return 'null'; },
|
||||
uppercase: function () { return 'NULL'; },
|
||||
camelcase: function () { return 'Null'; }
|
||||
},
|
||||
defaultStyle: 'lowercase'
|
||||
});
|
44
tools/doc/node_modules/js-yaml/lib/js-yaml/type/omap.js
generated
vendored
Normal file
44
tools/doc/node_modules/js-yaml/lib/js-yaml/type/omap.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
var Type = require('../type');
|
||||
|
||||
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var _toString = Object.prototype.toString;
|
||||
|
||||
function resolveYamlOmap(data) {
|
||||
if (data === null) return true;
|
||||
|
||||
var objectKeys = [], index, length, pair, pairKey, pairHasKey,
|
||||
object = data;
|
||||
|
||||
for (index = 0, length = object.length; index < length; index += 1) {
|
||||
pair = object[index];
|
||||
pairHasKey = false;
|
||||
|
||||
if (_toString.call(pair) !== '[object Object]') return false;
|
||||
|
||||
for (pairKey in pair) {
|
||||
if (_hasOwnProperty.call(pair, pairKey)) {
|
||||
if (!pairHasKey) pairHasKey = true;
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pairHasKey) return false;
|
||||
|
||||
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
|
||||
else return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function constructYamlOmap(data) {
|
||||
return data !== null ? data : [];
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:omap', {
|
||||
kind: 'sequence',
|
||||
resolve: resolveYamlOmap,
|
||||
construct: constructYamlOmap
|
||||
});
|
53
tools/doc/node_modules/js-yaml/lib/js-yaml/type/pairs.js
generated
vendored
Normal file
53
tools/doc/node_modules/js-yaml/lib/js-yaml/type/pairs.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
var Type = require('../type');
|
||||
|
||||
var _toString = Object.prototype.toString;
|
||||
|
||||
function resolveYamlPairs(data) {
|
||||
if (data === null) return true;
|
||||
|
||||
var index, length, pair, keys, result,
|
||||
object = data;
|
||||
|
||||
result = new Array(object.length);
|
||||
|
||||
for (index = 0, length = object.length; index < length; index += 1) {
|
||||
pair = object[index];
|
||||
|
||||
if (_toString.call(pair) !== '[object Object]') return false;
|
||||
|
||||
keys = Object.keys(pair);
|
||||
|
||||
if (keys.length !== 1) return false;
|
||||
|
||||
result[index] = [ keys[0], pair[keys[0]] ];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function constructYamlPairs(data) {
|
||||
if (data === null) return [];
|
||||
|
||||
var index, length, pair, keys, result,
|
||||
object = data;
|
||||
|
||||
result = new Array(object.length);
|
||||
|
||||
for (index = 0, length = object.length; index < length; index += 1) {
|
||||
pair = object[index];
|
||||
|
||||
keys = Object.keys(pair);
|
||||
|
||||
result[index] = [ keys[0], pair[keys[0]] ];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:pairs', {
|
||||
kind: 'sequence',
|
||||
resolve: resolveYamlPairs,
|
||||
construct: constructYamlPairs
|
||||
});
|
8
tools/doc/node_modules/js-yaml/lib/js-yaml/type/seq.js
generated
vendored
Normal file
8
tools/doc/node_modules/js-yaml/lib/js-yaml/type/seq.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var Type = require('../type');
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:seq', {
|
||||
kind: 'sequence',
|
||||
construct: function (data) { return data !== null ? data : []; }
|
||||
});
|
29
tools/doc/node_modules/js-yaml/lib/js-yaml/type/set.js
generated
vendored
Normal file
29
tools/doc/node_modules/js-yaml/lib/js-yaml/type/set.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
var Type = require('../type');
|
||||
|
||||
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
function resolveYamlSet(data) {
|
||||
if (data === null) return true;
|
||||
|
||||
var key, object = data;
|
||||
|
||||
for (key in object) {
|
||||
if (_hasOwnProperty.call(object, key)) {
|
||||
if (object[key] !== null) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function constructYamlSet(data) {
|
||||
return data !== null ? data : {};
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:set', {
|
||||
kind: 'mapping',
|
||||
resolve: resolveYamlSet,
|
||||
construct: constructYamlSet
|
||||
});
|
8
tools/doc/node_modules/js-yaml/lib/js-yaml/type/str.js
generated
vendored
Normal file
8
tools/doc/node_modules/js-yaml/lib/js-yaml/type/str.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var Type = require('../type');
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:str', {
|
||||
kind: 'scalar',
|
||||
construct: function (data) { return data !== null ? data : ''; }
|
||||
});
|
88
tools/doc/node_modules/js-yaml/lib/js-yaml/type/timestamp.js
generated
vendored
Normal file
88
tools/doc/node_modules/js-yaml/lib/js-yaml/type/timestamp.js
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
'use strict';
|
||||
|
||||
var Type = require('../type');
|
||||
|
||||
var YAML_DATE_REGEXP = new RegExp(
|
||||
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
||||
'-([0-9][0-9])' + // [2] month
|
||||
'-([0-9][0-9])$'); // [3] day
|
||||
|
||||
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
||||
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
||||
'-([0-9][0-9]?)' + // [2] month
|
||||
'-([0-9][0-9]?)' + // [3] day
|
||||
'(?:[Tt]|[ \\t]+)' + // ...
|
||||
'([0-9][0-9]?)' + // [4] hour
|
||||
':([0-9][0-9])' + // [5] minute
|
||||
':([0-9][0-9])' + // [6] second
|
||||
'(?:\\.([0-9]*))?' + // [7] fraction
|
||||
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
|
||||
'(?::([0-9][0-9]))?))?$'); // [11] tz_minute
|
||||
|
||||
function resolveYamlTimestamp(data) {
|
||||
if (data === null) return false;
|
||||
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
||||
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function constructYamlTimestamp(data) {
|
||||
var match, year, month, day, hour, minute, second, fraction = 0,
|
||||
delta = null, tz_hour, tz_minute, date;
|
||||
|
||||
match = YAML_DATE_REGEXP.exec(data);
|
||||
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
||||
|
||||
if (match === null) throw new Error('Date resolve error');
|
||||
|
||||
// match: [1] year [2] month [3] day
|
||||
|
||||
year = +(match[1]);
|
||||
month = +(match[2]) - 1; // JS month starts with 0
|
||||
day = +(match[3]);
|
||||
|
||||
if (!match[4]) { // no hour
|
||||
return new Date(Date.UTC(year, month, day));
|
||||
}
|
||||
|
||||
// match: [4] hour [5] minute [6] second [7] fraction
|
||||
|
||||
hour = +(match[4]);
|
||||
minute = +(match[5]);
|
||||
second = +(match[6]);
|
||||
|
||||
if (match[7]) {
|
||||
fraction = match[7].slice(0, 3);
|
||||
while (fraction.length < 3) { // milli-seconds
|
||||
fraction += '0';
|
||||
}
|
||||
fraction = +fraction;
|
||||
}
|
||||
|
||||
// match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
|
||||
|
||||
if (match[9]) {
|
||||
tz_hour = +(match[10]);
|
||||
tz_minute = +(match[11] || 0);
|
||||
delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
|
||||
if (match[9] === '-') delta = -delta;
|
||||
}
|
||||
|
||||
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
||||
|
||||
if (delta) date.setTime(date.getTime() - delta);
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
function representYamlTimestamp(object /*, style*/) {
|
||||
return object.toISOString();
|
||||
}
|
||||
|
||||
module.exports = new Type('tag:yaml.org,2002:timestamp', {
|
||||
kind: 'scalar',
|
||||
resolve: resolveYamlTimestamp,
|
||||
construct: constructYamlTimestamp,
|
||||
instanceOf: Date,
|
||||
represent: representYamlTimestamp
|
||||
});
|
96
tools/doc/node_modules/js-yaml/package.json
generated
vendored
Normal file
96
tools/doc/node_modules/js-yaml/package.json
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"js-yaml@3.11.0",
|
||||
"/Users/rubys/git/node/tools/doc"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "js-yaml@3.11.0",
|
||||
"_id": "js-yaml@3.11.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==",
|
||||
"_location": "/js-yaml",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "js-yaml@3.11.0",
|
||||
"name": "js-yaml",
|
||||
"escapedName": "js-yaml",
|
||||
"rawSpec": "3.11.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.11.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#DEV:/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz",
|
||||
"_spec": "3.11.0",
|
||||
"_where": "/Users/rubys/git/node/tools/doc",
|
||||
"author": {
|
||||
"name": "Vladimir Zapparov",
|
||||
"email": "dervus.grim@gmail.com"
|
||||
},
|
||||
"bin": {
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/nodeca/js-yaml/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Aleksey V Zapparov",
|
||||
"email": "ixti@member.fsf.org",
|
||||
"url": "http://www.ixti.net/"
|
||||
},
|
||||
{
|
||||
"name": "Vitaly Puzrin",
|
||||
"email": "vitaly@rcdesign.ru",
|
||||
"url": "https://github.com/puzrin"
|
||||
},
|
||||
{
|
||||
"name": "Martin Grenfell",
|
||||
"email": "martin.grenfell@gmail.com",
|
||||
"url": "http://got-ravings.blogspot.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
},
|
||||
"description": "YAML 1.2 parser and serializer",
|
||||
"devDependencies": {
|
||||
"ansi": "^0.3.1",
|
||||
"benchmark": "^2.1.4",
|
||||
"browserify": "^14.3.0",
|
||||
"codemirror": "^5.13.4",
|
||||
"eslint": "^4.1.1",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^3.3.0",
|
||||
"uglify-js": "^3.0.1"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib/",
|
||||
"bin/",
|
||||
"dist/"
|
||||
],
|
||||
"homepage": "https://github.com/nodeca/js-yaml",
|
||||
"keywords": [
|
||||
"yaml",
|
||||
"parser",
|
||||
"serializer",
|
||||
"pyyaml"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "js-yaml",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/nodeca/js-yaml.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "3.11.0"
|
||||
}
|
2
tools/doc/node_modules/marked/.npmignore
generated
vendored
2
tools/doc/node_modules/marked/.npmignore
generated
vendored
@ -1,2 +0,0 @@
|
||||
.git*
|
||||
test/
|
5
tools/doc/node_modules/marked/.travis.yml
generated
vendored
5
tools/doc/node_modules/marked/.travis.yml
generated
vendored
@ -1,5 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.8"
|
||||
- "0.6"
|
22
tools/doc/node_modules/marked/Gulpfile.js
generated
vendored
22
tools/doc/node_modules/marked/Gulpfile.js
generated
vendored
@ -1,22 +0,0 @@
|
||||
var gulp = require('gulp');
|
||||
var uglify = require('gulp-uglify');
|
||||
var concat = require('gulp-concat');
|
||||
|
||||
var preserveFirstComment = function() {
|
||||
var set = false;
|
||||
|
||||
return function() {
|
||||
if (set) return false;
|
||||
set = true;
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
gulp.task('uglify', function() {
|
||||
gulp.src('lib/marked.js')
|
||||
.pipe(uglify({preserveComments: preserveFirstComment()}))
|
||||
.pipe(concat('marked.min.js'))
|
||||
.pipe(gulp.dest('.'));
|
||||
});
|
||||
|
||||
gulp.task('default', ['uglify']);
|
24
tools/doc/node_modules/marked/bower.json
generated
vendored
24
tools/doc/node_modules/marked/bower.json
generated
vendored
@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "marked",
|
||||
"version": "0.3.4",
|
||||
"homepage": "https://github.com/chjj/marked",
|
||||
"authors": [
|
||||
"Christopher Jeffrey <chjjeffrey@gmail.com>"
|
||||
],
|
||||
"description": "A markdown parser built for speed",
|
||||
"keywords": [
|
||||
"markdown",
|
||||
"markup",
|
||||
"html"
|
||||
],
|
||||
"main": "lib/marked.js",
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"app/bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
10
tools/doc/node_modules/marked/component.json
generated
vendored
10
tools/doc/node_modules/marked/component.json
generated
vendored
@ -1,10 +0,0 @@
|
||||
{
|
||||
"name": "marked",
|
||||
"version": "0.3.4",
|
||||
"repo": "chjj/marked",
|
||||
"description": "A markdown parser built for speed",
|
||||
"keywords": ["markdown", "markup", "html"],
|
||||
"scripts": ["lib/marked.js"],
|
||||
"main": "lib/marked.js",
|
||||
"license": "MIT"
|
||||
}
|
426
tools/doc/node_modules/marked/doc/broken.md
generated
vendored
426
tools/doc/node_modules/marked/doc/broken.md
generated
vendored
@ -1,426 +0,0 @@
|
||||
# Markdown is broken
|
||||
|
||||
I have a lot of scraps of markdown engine oddities that I've collected over the
|
||||
years. What you see below is slightly messy, but it's what I've managed to
|
||||
cobble together to illustrate the differences between markdown engines, and
|
||||
why, if there ever is a markdown specification, it has to be absolutely
|
||||
thorough. There are a lot more of these little differences I have documented
|
||||
elsewhere. I know I will find them lingering on my disk one day, but until
|
||||
then, I'll continue to add whatever strange nonsensical things I find.
|
||||
|
||||
Some of these examples may only mention a particular engine compared to marked.
|
||||
However, the examples with markdown.pl could easily be swapped out for
|
||||
discount, upskirt, or markdown.js, and you would very easily see even more
|
||||
inconsistencies.
|
||||
|
||||
A lot of this was written when I was very unsatisfied with the inconsistencies
|
||||
between markdown engines. Please excuse the frustration noticeable in my
|
||||
writing.
|
||||
|
||||
## Examples of markdown's "stupid" list parsing
|
||||
|
||||
```
|
||||
$ markdown.pl
|
||||
|
||||
* item1
|
||||
|
||||
* item2
|
||||
|
||||
text
|
||||
^D
|
||||
<ul>
|
||||
<li><p>item1</p>
|
||||
|
||||
<ul>
|
||||
<li>item2</li>
|
||||
</ul>
|
||||
|
||||
<p><p>text</p></li>
|
||||
</ul></p>
|
||||
```
|
||||
|
||||
|
||||
```
|
||||
$ marked
|
||||
* item1
|
||||
|
||||
* item2
|
||||
|
||||
text
|
||||
^D
|
||||
<ul>
|
||||
<li><p>item1</p>
|
||||
<ul>
|
||||
<li>item2</li>
|
||||
</ul>
|
||||
<p>text</p>
|
||||
</li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
Which looks correct to you?
|
||||
|
||||
- - -
|
||||
|
||||
```
|
||||
$ markdown.pl
|
||||
* hello
|
||||
> world
|
||||
^D
|
||||
<p><ul>
|
||||
<li>hello</p>
|
||||
|
||||
<blockquote>
|
||||
<p>world</li>
|
||||
</ul></p>
|
||||
</blockquote>
|
||||
```
|
||||
|
||||
```
|
||||
$ marked
|
||||
* hello
|
||||
> world
|
||||
^D
|
||||
<ul>
|
||||
<li>hello<blockquote>
|
||||
<p>world</p>
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
Again, which looks correct to you?
|
||||
|
||||
- - -
|
||||
|
||||
EXAMPLE:
|
||||
|
||||
```
|
||||
$ markdown.pl
|
||||
* hello
|
||||
* world
|
||||
* hi
|
||||
code
|
||||
^D
|
||||
<ul>
|
||||
<li>hello
|
||||
<ul>
|
||||
<li>world</li>
|
||||
<li>hi
|
||||
code</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
The code isn't a code block even though it's after the bullet margin. I know,
|
||||
lets give it two more spaces, effectively making it 8 spaces past the bullet.
|
||||
|
||||
```
|
||||
$ markdown.pl
|
||||
* hello
|
||||
* world
|
||||
* hi
|
||||
code
|
||||
^D
|
||||
<ul>
|
||||
<li>hello
|
||||
<ul>
|
||||
<li>world</li>
|
||||
<li>hi
|
||||
code</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
And, it's still not a code block. Did you also notice that the 3rd item isn't
|
||||
even its own list? Markdown screws that up too because of its indentation
|
||||
unaware parsing.
|
||||
|
||||
- - -
|
||||
|
||||
Let's look at some more examples of markdown's list parsing:
|
||||
|
||||
```
|
||||
$ markdown.pl
|
||||
|
||||
* item1
|
||||
|
||||
* item2
|
||||
|
||||
text
|
||||
^D
|
||||
<ul>
|
||||
<li><p>item1</p>
|
||||
|
||||
<ul>
|
||||
<li>item2</li>
|
||||
</ul>
|
||||
|
||||
<p><p>text</p></li>
|
||||
</ul></p>
|
||||
```
|
||||
|
||||
Misnested tags.
|
||||
|
||||
|
||||
```
|
||||
$ marked
|
||||
* item1
|
||||
|
||||
* item2
|
||||
|
||||
text
|
||||
^D
|
||||
<ul>
|
||||
<li><p>item1</p>
|
||||
<ul>
|
||||
<li>item2</li>
|
||||
</ul>
|
||||
<p>text</p>
|
||||
</li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
Which looks correct to you?
|
||||
|
||||
- - -
|
||||
|
||||
```
|
||||
$ markdown.pl
|
||||
* hello
|
||||
> world
|
||||
^D
|
||||
<p><ul>
|
||||
<li>hello</p>
|
||||
|
||||
<blockquote>
|
||||
<p>world</li>
|
||||
</ul></p>
|
||||
</blockquote>
|
||||
```
|
||||
|
||||
More misnested tags.
|
||||
|
||||
|
||||
```
|
||||
$ marked
|
||||
* hello
|
||||
> world
|
||||
^D
|
||||
<ul>
|
||||
<li>hello<blockquote>
|
||||
<p>world</p>
|
||||
</blockquote>
|
||||
</li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
Again, which looks correct to you?
|
||||
|
||||
- - -
|
||||
|
||||
# Why quality matters - Part 2
|
||||
|
||||
``` bash
|
||||
$ markdown.pl
|
||||
* hello
|
||||
> world
|
||||
^D
|
||||
<p><ul>
|
||||
<li>hello</p>
|
||||
|
||||
<blockquote>
|
||||
<p>world</li>
|
||||
</ul></p>
|
||||
</blockquote>
|
||||
```
|
||||
|
||||
``` bash
|
||||
$ sundown # upskirt
|
||||
* hello
|
||||
> world
|
||||
^D
|
||||
<ul>
|
||||
<li>hello
|
||||
> world</li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
``` bash
|
||||
$ marked
|
||||
* hello
|
||||
> world
|
||||
^D
|
||||
<ul><li>hello <blockquote><p>world</p></blockquote></li></ul>
|
||||
```
|
||||
|
||||
Which looks correct to you?
|
||||
|
||||
- - -
|
||||
|
||||
See: https://github.com/evilstreak/markdown-js/issues/23
|
||||
|
||||
``` bash
|
||||
$ markdown.pl # upskirt/markdown.js/discount
|
||||
* hello
|
||||
var a = 1;
|
||||
* world
|
||||
^D
|
||||
<ul>
|
||||
<li>hello
|
||||
var a = 1;</li>
|
||||
<li>world</li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
``` bash
|
||||
$ marked
|
||||
* hello
|
||||
var a = 1;
|
||||
* world
|
||||
^D
|
||||
<ul><li>hello
|
||||
<pre>code>var a = 1;</code></pre></li>
|
||||
<li>world</li></ul>
|
||||
```
|
||||
|
||||
Which looks more reasonable? Why shouldn't code blocks be able to appear in
|
||||
list items in a sane way?
|
||||
|
||||
- - -
|
||||
|
||||
``` bash
|
||||
$ markdown.js
|
||||
<div>hello</div>
|
||||
|
||||
<span>hello</span>
|
||||
^D
|
||||
<p><div>hello</div></p>
|
||||
|
||||
<p><span>hello</span></p>
|
||||
```
|
||||
|
||||
``` bash
|
||||
$ marked
|
||||
<div>hello</div>
|
||||
|
||||
<span>hello</span>
|
||||
^D
|
||||
<div>hello</div>
|
||||
|
||||
|
||||
<p><span>hello</span>
|
||||
</p>
|
||||
```
|
||||
|
||||
- - -
|
||||
|
||||
See: https://github.com/evilstreak/markdown-js/issues/27
|
||||
|
||||
``` bash
|
||||
$ markdown.js
|
||||
[](/link)
|
||||
^D
|
||||
<p><a href="/image)](/link">](/link)
|
||||
^D
|
||||
<p><a href="/link"><img src="/image" alt="an image"></a>
|
||||
</p>
|
||||
```
|
||||
|
||||
- - -
|
||||
|
||||
See: https://github.com/evilstreak/markdown-js/issues/24
|
||||
|
||||
``` bash
|
||||
$ markdown.js
|
||||
> a
|
||||
|
||||
> b
|
||||
|
||||
> c
|
||||
^D
|
||||
<blockquote><p>a</p><p>bundefined> c</p></blockquote>
|
||||
```
|
||||
|
||||
``` bash
|
||||
$ marked
|
||||
> a
|
||||
|
||||
> b
|
||||
|
||||
> c
|
||||
^D
|
||||
<blockquote><p>a
|
||||
|
||||
</p></blockquote>
|
||||
<blockquote><p>b
|
||||
|
||||
</p></blockquote>
|
||||
<blockquote><p>c
|
||||
</p></blockquote>
|
||||
```
|
||||
|
||||
- - -
|
||||
|
||||
``` bash
|
||||
$ markdown.pl
|
||||
* hello
|
||||
* world
|
||||
how
|
||||
|
||||
are
|
||||
you
|
||||
|
||||
* today
|
||||
* hi
|
||||
^D
|
||||
<ul>
|
||||
<li><p>hello</p>
|
||||
|
||||
<ul>
|
||||
<li>world
|
||||
how</li>
|
||||
</ul>
|
||||
|
||||
<p>are
|
||||
you</p>
|
||||
|
||||
<ul>
|
||||
<li>today</li>
|
||||
</ul></li>
|
||||
<li>hi</li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
``` bash
|
||||
$ marked
|
||||
* hello
|
||||
* world
|
||||
how
|
||||
|
||||
are
|
||||
you
|
||||
|
||||
* today
|
||||
* hi
|
||||
^D
|
||||
<ul>
|
||||
<li><p>hello</p>
|
||||
<ul>
|
||||
<li><p>world
|
||||
how</p>
|
||||
<p>are
|
||||
you</p>
|
||||
</li>
|
||||
<li><p>today</p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>hi</li>
|
||||
</ul>
|
||||
```
|
2
tools/doc/node_modules/marked/doc/todo.md
generated
vendored
2
tools/doc/node_modules/marked/doc/todo.md
generated
vendored
@ -1,2 +0,0 @@
|
||||
# Todo
|
||||
|
24
tools/doc/node_modules/sprintf-js/LICENSE
generated
vendored
Normal file
24
tools/doc/node_modules/sprintf-js/LICENSE
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
Copyright (c) 2007-2014, Alexandru Marasteanu <hello [at) alexei (dot] ro>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of this software nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
88
tools/doc/node_modules/sprintf-js/README.md
generated
vendored
Normal file
88
tools/doc/node_modules/sprintf-js/README.md
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
# sprintf.js
|
||||
**sprintf.js** is a complete open source JavaScript sprintf implementation for the *browser* and *node.js*.
|
||||
|
||||
Its prototype is simple:
|
||||
|
||||
string sprintf(string format , [mixed arg1 [, mixed arg2 [ ,...]]])
|
||||
|
||||
The placeholders in the format string are marked by `%` and are followed by one or more of these elements, in this order:
|
||||
|
||||
* An optional number followed by a `$` sign that selects which argument index to use for the value. If not specified, arguments will be placed in the same order as the placeholders in the input string.
|
||||
* An optional `+` sign that forces to preceed the result with a plus or minus sign on numeric values. By default, only the `-` sign is used on negative numbers.
|
||||
* An optional padding specifier that says what character to use for padding (if specified). Possible values are `0` or any other character precedeed by a `'` (single quote). The default is to pad with *spaces*.
|
||||
* An optional `-` sign, that causes sprintf to left-align the result of this placeholder. The default is to right-align the result.
|
||||
* An optional number, that says how many characters the result should have. If the value to be returned is shorter than this number, the result will be padded. When used with the `j` (JSON) type specifier, the padding length specifies the tab size used for indentation.
|
||||
* An optional precision modifier, consisting of a `.` (dot) followed by a number, that says how many digits should be displayed for floating point numbers. When used with the `g` type specifier, it specifies the number of significant digits. When used on a string, it causes the result to be truncated.
|
||||
* A type specifier that can be any of:
|
||||
* `%` — yields a literal `%` character
|
||||
* `b` — yields an integer as a binary number
|
||||
* `c` — yields an integer as the character with that ASCII value
|
||||
* `d` or `i` — yields an integer as a signed decimal number
|
||||
* `e` — yields a float using scientific notation
|
||||
* `u` — yields an integer as an unsigned decimal number
|
||||
* `f` — yields a float as is; see notes on precision above
|
||||
* `g` — yields a float as is; see notes on precision above
|
||||
* `o` — yields an integer as an octal number
|
||||
* `s` — yields a string as is
|
||||
* `x` — yields an integer as a hexadecimal number (lower-case)
|
||||
* `X` — yields an integer as a hexadecimal number (upper-case)
|
||||
* `j` — yields a JavaScript object or array as a JSON encoded string
|
||||
|
||||
## JavaScript `vsprintf`
|
||||
`vsprintf` is the same as `sprintf` except that it accepts an array of arguments, rather than a variable number of arguments:
|
||||
|
||||
vsprintf("The first 4 letters of the english alphabet are: %s, %s, %s and %s", ["a", "b", "c", "d"])
|
||||
|
||||
## Argument swapping
|
||||
You can also swap the arguments. That is, the order of the placeholders doesn't have to match the order of the arguments. You can do that by simply indicating in the format string which arguments the placeholders refer to:
|
||||
|
||||
sprintf("%2$s %3$s a %1$s", "cracker", "Polly", "wants")
|
||||
And, of course, you can repeat the placeholders without having to increase the number of arguments.
|
||||
|
||||
## Named arguments
|
||||
Format strings may contain replacement fields rather than positional placeholders. Instead of referring to a certain argument, you can now refer to a certain key within an object. Replacement fields are surrounded by rounded parentheses - `(` and `)` - and begin with a keyword that refers to a key:
|
||||
|
||||
var user = {
|
||||
name: "Dolly"
|
||||
}
|
||||
sprintf("Hello %(name)s", user) // Hello Dolly
|
||||
Keywords in replacement fields can be optionally followed by any number of keywords or indexes:
|
||||
|
||||
var users = [
|
||||
{name: "Dolly"},
|
||||
{name: "Molly"},
|
||||
{name: "Polly"}
|
||||
]
|
||||
sprintf("Hello %(users[0].name)s, %(users[1].name)s and %(users[2].name)s", {users: users}) // Hello Dolly, Molly and Polly
|
||||
Note: mixing positional and named placeholders is not (yet) supported
|
||||
|
||||
## Computed values
|
||||
You can pass in a function as a dynamic value and it will be invoked (with no arguments) in order to compute the value on-the-fly.
|
||||
|
||||
sprintf("Current timestamp: %d", Date.now) // Current timestamp: 1398005382890
|
||||
sprintf("Current date and time: %s", function() { return new Date().toString() })
|
||||
|
||||
# AngularJS
|
||||
You can now use `sprintf` and `vsprintf` (also aliased as `fmt` and `vfmt` respectively) in your AngularJS projects. See `demo/`.
|
||||
|
||||
# Installation
|
||||
|
||||
## Via Bower
|
||||
|
||||
bower install sprintf
|
||||
|
||||
## Or as a node.js module
|
||||
|
||||
npm install sprintf-js
|
||||
|
||||
### Usage
|
||||
|
||||
var sprintf = require("sprintf-js").sprintf,
|
||||
vsprintf = require("sprintf-js").vsprintf
|
||||
|
||||
sprintf("%2$s %3$s a %1$s", "cracker", "Polly", "wants")
|
||||
vsprintf("The first 4 letters of the english alphabet are: %s, %s, %s and %s", ["a", "b", "c", "d"])
|
||||
|
||||
# License
|
||||
|
||||
**sprintf.js** is licensed under the terms of the 3-clause BSD license.
|
4
tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.js
generated
vendored
Normal file
4
tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/*! sprintf-js | Alexandru Marasteanu <hello@alexei.ro> (http://alexei.ro/) | BSD-3-Clause */
|
||||
|
||||
angular.module("sprintf",[]).filter("sprintf",function(){return function(){return sprintf.apply(null,arguments)}}).filter("fmt",["$filter",function(a){return a("sprintf")}]).filter("vsprintf",function(){return function(a,b){return vsprintf(a,b)}}).filter("vfmt",["$filter",function(a){return a("vsprintf")}]);
|
||||
//# sourceMappingURL=angular-sprintf.min.map
|
1
tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.js.map
generated
vendored
Normal file
1
tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"angular-sprintf.min.js","sources":["../src/angular-sprintf.js"],"names":["angular","module","filter","sprintf","apply","arguments","$filter","format","argv","vsprintf"],"mappings":";;AAAAA,QACIC,OAAO,cACPC,OAAO,UAAW,WACd,MAAO,YACH,MAAOC,SAAQC,MAAM,KAAMC,cAGnCH,OAAO,OAAQ,UAAW,SAASI,GAC/B,MAAOA,GAAQ,cAEnBJ,OAAO,WAAY,WACf,MAAO,UAASK,EAAQC,GACpB,MAAOC,UAASF,EAAQC,MAGhCN,OAAO,QAAS,UAAW,SAASI,GAChC,MAAOA,GAAQ"}
|
1
tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.map
generated
vendored
Normal file
1
tools/doc/node_modules/sprintf-js/dist/angular-sprintf.min.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"angular-sprintf.min.js","sources":["../src/angular-sprintf.js"],"names":["angular","module","filter","sprintf","apply","arguments","$filter","format","argv","vsprintf"],"mappings":";;AAAAA,QACIC,OAAO,cACPC,OAAO,UAAW,WACd,MAAO,YACH,MAAOC,SAAQC,MAAM,KAAMC,cAGnCH,OAAO,OAAQ,UAAW,SAASI,GAC/B,MAAOA,GAAQ,cAEnBJ,OAAO,WAAY,WACf,MAAO,UAASK,EAAQC,GACpB,MAAOC,UAASF,EAAQC,MAGhCN,OAAO,QAAS,UAAW,SAASI,GAChC,MAAOA,GAAQ"}
|
4
tools/doc/node_modules/sprintf-js/dist/sprintf.min.js
generated
vendored
Normal file
4
tools/doc/node_modules/sprintf-js/dist/sprintf.min.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/*! sprintf-js | Alexandru Marasteanu <hello@alexei.ro> (http://alexei.ro/) | BSD-3-Clause */
|
||||
|
||||
!function(a){function b(){var a=arguments[0],c=b.cache;return c[a]&&c.hasOwnProperty(a)||(c[a]=b.parse(a)),b.format.call(null,c[a],arguments)}function c(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}function d(a,b){return Array(b+1).join(a)}var e={not_string:/[^s]/,number:/[diefg]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijosuxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};b.format=function(a,f){var g,h,i,j,k,l,m,n=1,o=a.length,p="",q=[],r=!0,s="";for(h=0;o>h;h++)if(p=c(a[h]),"string"===p)q[q.length]=a[h];else if("array"===p){if(j=a[h],j[2])for(g=f[n],i=0;i<j[2].length;i++){if(!g.hasOwnProperty(j[2][i]))throw new Error(b("[sprintf] property '%s' does not exist",j[2][i]));g=g[j[2][i]]}else g=j[1]?f[j[1]]:f[n++];if("function"==c(g)&&(g=g()),e.not_string.test(j[8])&&e.not_json.test(j[8])&&"number"!=c(g)&&isNaN(g))throw new TypeError(b("[sprintf] expecting number but found %s",c(g)));switch(e.number.test(j[8])&&(r=g>=0),j[8]){case"b":g=g.toString(2);break;case"c":g=String.fromCharCode(g);break;case"d":case"i":g=parseInt(g,10);break;case"j":g=JSON.stringify(g,null,j[6]?parseInt(j[6]):0);break;case"e":g=j[7]?g.toExponential(j[7]):g.toExponential();break;case"f":g=j[7]?parseFloat(g).toFixed(j[7]):parseFloat(g);break;case"g":g=j[7]?parseFloat(g).toPrecision(j[7]):parseFloat(g);break;case"o":g=g.toString(8);break;case"s":g=(g=String(g))&&j[7]?g.substring(0,j[7]):g;break;case"u":g>>>=0;break;case"x":g=g.toString(16);break;case"X":g=g.toString(16).toUpperCase()}e.json.test(j[8])?q[q.length]=g:(!e.number.test(j[8])||r&&!j[3]?s="":(s=r?"+":"-",g=g.toString().replace(e.sign,"")),l=j[4]?"0"===j[4]?"0":j[4].charAt(1):" ",m=j[6]-(s+g).length,k=j[6]&&m>0?d(l,m):"",q[q.length]=j[5]?s+g+k:"0"===l?s+k+g:k+s+g)}return q.join("")},b.cache={},b.parse=function(a){for(var b=a,c=[],d=[],f=0;b;){if(null!==(c=e.text.exec(b)))d[d.length]=c[0];else if(null!==(c=e.modulo.exec(b)))d[d.length]="%";else{if(null===(c=e.placeholder.exec(b)))throw new SyntaxError("[sprintf] unexpected placeholder");if(c[2]){f|=1;var g=[],h=c[2],i=[];if(null===(i=e.key.exec(h)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(g[g.length]=i[1];""!==(h=h.substring(i[0].length));)if(null!==(i=e.key_access.exec(h)))g[g.length]=i[1];else{if(null===(i=e.index_access.exec(h)))throw new SyntaxError("[sprintf] failed to parse named argument key");g[g.length]=i[1]}c[2]=g}else f|=2;if(3===f)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");d[d.length]=c}b=b.substring(c[0].length)}return d};var f=function(a,c,d){return d=(c||[]).slice(0),d.splice(0,0,a),b.apply(null,d)};"undefined"!=typeof exports?(exports.sprintf=b,exports.vsprintf=f):(a.sprintf=b,a.vsprintf=f,"function"==typeof define&&define.amd&&define(function(){return{sprintf:b,vsprintf:f}}))}("undefined"==typeof window?this:window);
|
||||
//# sourceMappingURL=sprintf.min.map
|
1
tools/doc/node_modules/sprintf-js/dist/sprintf.min.js.map
generated
vendored
Normal file
1
tools/doc/node_modules/sprintf-js/dist/sprintf.min.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"sprintf.min.js","sources":["../src/sprintf.js"],"names":["window","sprintf","key","arguments","cache","hasOwnProperty","parse","format","call","get_type","variable","Object","prototype","toString","slice","toLowerCase","str_repeat","input","multiplier","Array","join","re","not_string","number","json","not_json","text","modulo","placeholder","key_access","index_access","sign","parse_tree","argv","arg","i","k","match","pad","pad_character","pad_length","cursor","tree_length","length","node_type","output","is_positive","Error","test","isNaN","TypeError","String","fromCharCode","parseInt","JSON","stringify","toExponential","parseFloat","toFixed","substring","toUpperCase","replace","charAt","fmt","_fmt","arg_names","exec","SyntaxError","field_list","replacement_field","field_match","vsprintf","_argv","splice","apply","exports","define","amd","this"],"mappings":";;CAAA,SAAUA,GAeN,QAASC,KACL,GAAIC,GAAMC,UAAU,GAAIC,EAAQH,EAAQG,KAIxC,OAHMA,GAAMF,IAAQE,EAAMC,eAAeH,KACrCE,EAAMF,GAAOD,EAAQK,MAAMJ,IAExBD,EAAQM,OAAOC,KAAK,KAAMJ,EAAMF,GAAMC,WA4JjD,QAASM,GAASC,GACd,MAAOC,QAAOC,UAAUC,SAASL,KAAKE,GAAUI,MAAM,EAAG,IAAIC,cAGjE,QAASC,GAAWC,EAAOC,GACvB,MAAOC,OAAMD,EAAa,GAAGE,KAAKH,GApLtC,GAAII,IACAC,WAAY,OACZC,OAAQ,SACRC,KAAM,MACNC,SAAU,OACVC,KAAM,YACNC,OAAQ,WACRC,YAAa,yFACb1B,IAAK,sBACL2B,WAAY,wBACZC,aAAc,aACdC,KAAM,UAWV9B,GAAQM,OAAS,SAASyB,EAAYC,GAClC,GAAiEC,GAAkBC,EAAGC,EAAGC,EAAOC,EAAKC,EAAeC,EAAhHC,EAAS,EAAGC,EAAcV,EAAWW,OAAQC,EAAY,GAASC,KAA0DC,GAAc,EAAMf,EAAO,EAC3J,KAAKI,EAAI,EAAOO,EAAJP,EAAiBA,IAEzB,GADAS,EAAYnC,EAASuB,EAAWG,IACd,WAAdS,EACAC,EAAOA,EAAOF,QAAUX,EAAWG,OAElC,IAAkB,UAAdS,EAAuB,CAE5B,GADAP,EAAQL,EAAWG,GACfE,EAAM,GAEN,IADAH,EAAMD,EAAKQ,GACNL,EAAI,EAAGA,EAAIC,EAAM,GAAGM,OAAQP,IAAK,CAClC,IAAKF,EAAI7B,eAAegC,EAAM,GAAGD,IAC7B,KAAM,IAAIW,OAAM9C,EAAQ,yCAA0CoC,EAAM,GAAGD,IAE/EF,GAAMA,EAAIG,EAAM,GAAGD,QAIvBF,GADKG,EAAM,GACLJ,EAAKI,EAAM,IAGXJ,EAAKQ,IAOf,IAJqB,YAAjBhC,EAASyB,KACTA,EAAMA,KAGNb,EAAGC,WAAW0B,KAAKX,EAAM,KAAOhB,EAAGI,SAASuB,KAAKX,EAAM,KAAyB,UAAjB5B,EAASyB,IAAoBe,MAAMf,GAClG,KAAM,IAAIgB,WAAUjD,EAAQ,0CAA2CQ,EAASyB,IAOpF,QAJIb,EAAGE,OAAOyB,KAAKX,EAAM,MACrBS,EAAcZ,GAAO,GAGjBG,EAAM,IACV,IAAK,IACDH,EAAMA,EAAIrB,SAAS,EACvB,MACA,KAAK,IACDqB,EAAMiB,OAAOC,aAAalB,EAC9B,MACA,KAAK,IACL,IAAK,IACDA,EAAMmB,SAASnB,EAAK,GACxB,MACA,KAAK,IACDA,EAAMoB,KAAKC,UAAUrB,EAAK,KAAMG,EAAM,GAAKgB,SAAShB,EAAM,IAAM,EACpE,MACA,KAAK,IACDH,EAAMG,EAAM,GAAKH,EAAIsB,cAAcnB,EAAM,IAAMH,EAAIsB,eACvD,MACA,KAAK,IACDtB,EAAMG,EAAM,GAAKoB,WAAWvB,GAAKwB,QAAQrB,EAAM,IAAMoB,WAAWvB,EACpE,MACA,KAAK,IACDA,EAAMA,EAAIrB,SAAS,EACvB,MACA,KAAK,IACDqB,GAAQA,EAAMiB,OAAOjB,KAASG,EAAM,GAAKH,EAAIyB,UAAU,EAAGtB,EAAM,IAAMH,CAC1E,MACA,KAAK,IACDA,KAAc,CAClB,MACA,KAAK,IACDA,EAAMA,EAAIrB,SAAS,GACvB,MACA,KAAK,IACDqB,EAAMA,EAAIrB,SAAS,IAAI+C,cAG3BvC,EAAGG,KAAKwB,KAAKX,EAAM,IACnBQ,EAAOA,EAAOF,QAAUT,IAGpBb,EAAGE,OAAOyB,KAAKX,EAAM,KAASS,IAAeT,EAAM,GAKnDN,EAAO,IAJPA,EAAOe,EAAc,IAAM,IAC3BZ,EAAMA,EAAIrB,WAAWgD,QAAQxC,EAAGU,KAAM,KAK1CQ,EAAgBF,EAAM,GAAkB,MAAbA,EAAM,GAAa,IAAMA,EAAM,GAAGyB,OAAO,GAAK,IACzEtB,EAAaH,EAAM,IAAMN,EAAOG,GAAKS,OACrCL,EAAMD,EAAM,IAAMG,EAAa,EAAIxB,EAAWuB,EAAeC,GAAoB,GACjFK,EAAOA,EAAOF,QAAUN,EAAM,GAAKN,EAAOG,EAAMI,EAAyB,MAAlBC,EAAwBR,EAAOO,EAAMJ,EAAMI,EAAMP,EAAOG,GAI3H,MAAOW,GAAOzB,KAAK,KAGvBnB,EAAQG,SAERH,EAAQK,MAAQ,SAASyD,GAErB,IADA,GAAIC,GAAOD,EAAK1B,KAAYL,KAAiBiC,EAAY,EAClDD,GAAM,CACT,GAAqC,QAAhC3B,EAAQhB,EAAGK,KAAKwC,KAAKF,IACtBhC,EAAWA,EAAWW,QAAUN,EAAM,OAErC,IAAuC,QAAlCA,EAAQhB,EAAGM,OAAOuC,KAAKF,IAC7BhC,EAAWA,EAAWW,QAAU,QAE/B,CAAA,GAA4C,QAAvCN,EAAQhB,EAAGO,YAAYsC,KAAKF,IAgClC,KAAM,IAAIG,aAAY,mCA/BtB,IAAI9B,EAAM,GAAI,CACV4B,GAAa,CACb,IAAIG,MAAiBC,EAAoBhC,EAAM,GAAIiC,IACnD,IAAuD,QAAlDA,EAAcjD,EAAGnB,IAAIgE,KAAKG,IAe3B,KAAM,IAAIF,aAAY,+CAbtB,KADAC,EAAWA,EAAWzB,QAAU2B,EAAY,GACwC,MAA5ED,EAAoBA,EAAkBV,UAAUW,EAAY,GAAG3B,UACnE,GAA8D,QAAzD2B,EAAcjD,EAAGQ,WAAWqC,KAAKG,IAClCD,EAAWA,EAAWzB,QAAU2B,EAAY,OAE3C,CAAA,GAAgE,QAA3DA,EAAcjD,EAAGS,aAAaoC,KAAKG,IAIzC,KAAM,IAAIF,aAAY,+CAHtBC,GAAWA,EAAWzB,QAAU2B,EAAY,GAUxDjC,EAAM,GAAK+B,MAGXH,IAAa,CAEjB,IAAkB,IAAdA,EACA,KAAM,IAAIlB,OAAM,4EAEpBf,GAAWA,EAAWW,QAAUN,EAKpC2B,EAAOA,EAAKL,UAAUtB,EAAM,GAAGM,QAEnC,MAAOX,GAGX,IAAIuC,GAAW,SAASR,EAAK9B,EAAMuC,GAG/B,MAFAA,IAASvC,OAAYnB,MAAM,GAC3B0D,EAAMC,OAAO,EAAG,EAAGV,GACZ9D,EAAQyE,MAAM,KAAMF,GAiBR,oBAAZG,UACPA,QAAQ1E,QAAUA,EAClB0E,QAAQJ,SAAWA,IAGnBvE,EAAOC,QAAUA,EACjBD,EAAOuE,SAAWA,EAEI,kBAAXK,SAAyBA,OAAOC,KACvCD,OAAO,WACH,OACI3E,QAASA,EACTsE,SAAUA,OAKT,mBAAXvE,QAAyB8E,KAAO9E"}
|
1
tools/doc/node_modules/sprintf-js/dist/sprintf.min.map
generated
vendored
Normal file
1
tools/doc/node_modules/sprintf-js/dist/sprintf.min.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"sprintf.min.js","sources":["../src/sprintf.js"],"names":["window","sprintf","key","arguments","cache","hasOwnProperty","parse","format","call","get_type","variable","Object","prototype","toString","slice","toLowerCase","str_repeat","input","multiplier","Array","join","re","not_string","number","json","not_json","text","modulo","placeholder","key_access","index_access","sign","parse_tree","argv","arg","i","k","match","pad","pad_character","pad_length","cursor","tree_length","length","node_type","output","is_positive","Error","test","isNaN","TypeError","String","fromCharCode","parseInt","JSON","stringify","toExponential","parseFloat","toFixed","toPrecision","substring","toUpperCase","replace","charAt","fmt","_fmt","arg_names","exec","SyntaxError","field_list","replacement_field","field_match","vsprintf","_argv","splice","apply","exports","define","amd","this"],"mappings":";;CAAA,SAAUA,GAeN,QAASC,KACL,GAAIC,GAAMC,UAAU,GAAIC,EAAQH,EAAQG,KAIxC,OAHMA,GAAMF,IAAQE,EAAMC,eAAeH,KACrCE,EAAMF,GAAOD,EAAQK,MAAMJ,IAExBD,EAAQM,OAAOC,KAAK,KAAMJ,EAAMF,GAAMC,WA+JjD,QAASM,GAASC,GACd,MAAOC,QAAOC,UAAUC,SAASL,KAAKE,GAAUI,MAAM,EAAG,IAAIC,cAGjE,QAASC,GAAWC,EAAOC,GACvB,MAAOC,OAAMD,EAAa,GAAGE,KAAKH,GAvLtC,GAAII,IACAC,WAAY,OACZC,OAAQ,UACRC,KAAM,MACNC,SAAU,OACVC,KAAM,YACNC,OAAQ,WACRC,YAAa,yFACb1B,IAAK,sBACL2B,WAAY,wBACZC,aAAc,aACdC,KAAM,UAWV9B,GAAQM,OAAS,SAASyB,EAAYC,GAClC,GAAiEC,GAAkBC,EAAGC,EAAGC,EAAOC,EAAKC,EAAeC,EAAhHC,EAAS,EAAGC,EAAcV,EAAWW,OAAQC,EAAY,GAASC,KAA0DC,GAAc,EAAMf,EAAO,EAC3J,KAAKI,EAAI,EAAOO,EAAJP,EAAiBA,IAEzB,GADAS,EAAYnC,EAASuB,EAAWG,IACd,WAAdS,EACAC,EAAOA,EAAOF,QAAUX,EAAWG,OAElC,IAAkB,UAAdS,EAAuB,CAE5B,GADAP,EAAQL,EAAWG,GACfE,EAAM,GAEN,IADAH,EAAMD,EAAKQ,GACNL,EAAI,EAAGA,EAAIC,EAAM,GAAGM,OAAQP,IAAK,CAClC,IAAKF,EAAI7B,eAAegC,EAAM,GAAGD,IAC7B,KAAM,IAAIW,OAAM9C,EAAQ,yCAA0CoC,EAAM,GAAGD,IAE/EF,GAAMA,EAAIG,EAAM,GAAGD,QAIvBF,GADKG,EAAM,GACLJ,EAAKI,EAAM,IAGXJ,EAAKQ,IAOf,IAJqB,YAAjBhC,EAASyB,KACTA,EAAMA,KAGNb,EAAGC,WAAW0B,KAAKX,EAAM,KAAOhB,EAAGI,SAASuB,KAAKX,EAAM,KAAyB,UAAjB5B,EAASyB,IAAoBe,MAAMf,GAClG,KAAM,IAAIgB,WAAUjD,EAAQ,0CAA2CQ,EAASyB,IAOpF,QAJIb,EAAGE,OAAOyB,KAAKX,EAAM,MACrBS,EAAcZ,GAAO,GAGjBG,EAAM,IACV,IAAK,IACDH,EAAMA,EAAIrB,SAAS,EACvB,MACA,KAAK,IACDqB,EAAMiB,OAAOC,aAAalB,EAC9B,MACA,KAAK,IACL,IAAK,IACDA,EAAMmB,SAASnB,EAAK,GACxB,MACA,KAAK,IACDA,EAAMoB,KAAKC,UAAUrB,EAAK,KAAMG,EAAM,GAAKgB,SAAShB,EAAM,IAAM,EACpE,MACA,KAAK,IACDH,EAAMG,EAAM,GAAKH,EAAIsB,cAAcnB,EAAM,IAAMH,EAAIsB,eACvD,MACA,KAAK,IACDtB,EAAMG,EAAM,GAAKoB,WAAWvB,GAAKwB,QAAQrB,EAAM,IAAMoB,WAAWvB,EACpE,MACA,KAAK,IACDA,EAAMG,EAAM,GAAKoB,WAAWvB,GAAKyB,YAAYtB,EAAM,IAAMoB,WAAWvB,EACxE,MACA,KAAK,IACDA,EAAMA,EAAIrB,SAAS,EACvB,MACA,KAAK,IACDqB,GAAQA,EAAMiB,OAAOjB,KAASG,EAAM,GAAKH,EAAI0B,UAAU,EAAGvB,EAAM,IAAMH,CAC1E,MACA,KAAK,IACDA,KAAc,CAClB,MACA,KAAK,IACDA,EAAMA,EAAIrB,SAAS,GACvB,MACA,KAAK,IACDqB,EAAMA,EAAIrB,SAAS,IAAIgD,cAG3BxC,EAAGG,KAAKwB,KAAKX,EAAM,IACnBQ,EAAOA,EAAOF,QAAUT,IAGpBb,EAAGE,OAAOyB,KAAKX,EAAM,KAASS,IAAeT,EAAM,GAKnDN,EAAO,IAJPA,EAAOe,EAAc,IAAM,IAC3BZ,EAAMA,EAAIrB,WAAWiD,QAAQzC,EAAGU,KAAM,KAK1CQ,EAAgBF,EAAM,GAAkB,MAAbA,EAAM,GAAa,IAAMA,EAAM,GAAG0B,OAAO,GAAK,IACzEvB,EAAaH,EAAM,IAAMN,EAAOG,GAAKS,OACrCL,EAAMD,EAAM,IAAMG,EAAa,EAAIxB,EAAWuB,EAAeC,GAAoB,GACjFK,EAAOA,EAAOF,QAAUN,EAAM,GAAKN,EAAOG,EAAMI,EAAyB,MAAlBC,EAAwBR,EAAOO,EAAMJ,EAAMI,EAAMP,EAAOG,GAI3H,MAAOW,GAAOzB,KAAK,KAGvBnB,EAAQG,SAERH,EAAQK,MAAQ,SAAS0D,GAErB,IADA,GAAIC,GAAOD,EAAK3B,KAAYL,KAAiBkC,EAAY,EAClDD,GAAM,CACT,GAAqC,QAAhC5B,EAAQhB,EAAGK,KAAKyC,KAAKF,IACtBjC,EAAWA,EAAWW,QAAUN,EAAM,OAErC,IAAuC,QAAlCA,EAAQhB,EAAGM,OAAOwC,KAAKF,IAC7BjC,EAAWA,EAAWW,QAAU,QAE/B,CAAA,GAA4C,QAAvCN,EAAQhB,EAAGO,YAAYuC,KAAKF,IAgClC,KAAM,IAAIG,aAAY,mCA/BtB,IAAI/B,EAAM,GAAI,CACV6B,GAAa,CACb,IAAIG,MAAiBC,EAAoBjC,EAAM,GAAIkC,IACnD,IAAuD,QAAlDA,EAAclD,EAAGnB,IAAIiE,KAAKG,IAe3B,KAAM,IAAIF,aAAY,+CAbtB,KADAC,EAAWA,EAAW1B,QAAU4B,EAAY,GACwC,MAA5ED,EAAoBA,EAAkBV,UAAUW,EAAY,GAAG5B,UACnE,GAA8D,QAAzD4B,EAAclD,EAAGQ,WAAWsC,KAAKG,IAClCD,EAAWA,EAAW1B,QAAU4B,EAAY,OAE3C,CAAA,GAAgE,QAA3DA,EAAclD,EAAGS,aAAaqC,KAAKG,IAIzC,KAAM,IAAIF,aAAY,+CAHtBC,GAAWA,EAAW1B,QAAU4B,EAAY,GAUxDlC,EAAM,GAAKgC,MAGXH,IAAa,CAEjB,IAAkB,IAAdA,EACA,KAAM,IAAInB,OAAM,4EAEpBf,GAAWA,EAAWW,QAAUN,EAKpC4B,EAAOA,EAAKL,UAAUvB,EAAM,GAAGM,QAEnC,MAAOX,GAGX,IAAIwC,GAAW,SAASR,EAAK/B,EAAMwC,GAG/B,MAFAA,IAASxC,OAAYnB,MAAM,GAC3B2D,EAAMC,OAAO,EAAG,EAAGV,GACZ/D,EAAQ0E,MAAM,KAAMF,GAiBR,oBAAZG,UACPA,QAAQ3E,QAAUA,EAClB2E,QAAQJ,SAAWA,IAGnBxE,EAAOC,QAAUA,EACjBD,EAAOwE,SAAWA,EAEI,kBAAXK,SAAyBA,OAAOC,KACvCD,OAAO,WACH,OACI5E,QAASA,EACTuE,SAAUA,OAKT,mBAAXxE,QAAyB+E,KAAO/E"}
|
58
tools/doc/node_modules/sprintf-js/package.json
generated
vendored
Normal file
58
tools/doc/node_modules/sprintf-js/package.json
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"sprintf-js@1.0.3",
|
||||
"/Users/rubys/git/node/tools/doc"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "sprintf-js@1.0.3",
|
||||
"_id": "sprintf-js@1.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
|
||||
"_location": "/sprintf-js",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "sprintf-js@1.0.3",
|
||||
"name": "sprintf-js",
|
||||
"escapedName": "sprintf-js",
|
||||
"rawSpec": "1.0.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/argparse"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||
"_spec": "1.0.3",
|
||||
"_where": "/Users/rubys/git/node/tools/doc",
|
||||
"author": {
|
||||
"name": "Alexandru Marasteanu",
|
||||
"email": "hello@alexei.ro",
|
||||
"url": "http://alexei.ro/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/alexei/sprintf.js/issues"
|
||||
},
|
||||
"description": "JavaScript sprintf implementation",
|
||||
"devDependencies": {
|
||||
"grunt": "*",
|
||||
"grunt-contrib-uglify": "*",
|
||||
"grunt-contrib-watch": "*",
|
||||
"mocha": "*"
|
||||
},
|
||||
"homepage": "https://github.com/alexei/sprintf.js#readme",
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "src/sprintf.js",
|
||||
"name": "sprintf-js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/alexei/sprintf.js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test/test.js"
|
||||
},
|
||||
"version": "1.0.3"
|
||||
}
|
18
tools/doc/node_modules/sprintf-js/src/angular-sprintf.js
generated
vendored
Normal file
18
tools/doc/node_modules/sprintf-js/src/angular-sprintf.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
angular.
|
||||
module("sprintf", []).
|
||||
filter("sprintf", function() {
|
||||
return function() {
|
||||
return sprintf.apply(null, arguments)
|
||||
}
|
||||
}).
|
||||
filter("fmt", ["$filter", function($filter) {
|
||||
return $filter("sprintf")
|
||||
}]).
|
||||
filter("vsprintf", function() {
|
||||
return function(format, argv) {
|
||||
return vsprintf(format, argv)
|
||||
}
|
||||
}).
|
||||
filter("vfmt", ["$filter", function($filter) {
|
||||
return $filter("vsprintf")
|
||||
}])
|
208
tools/doc/node_modules/sprintf-js/src/sprintf.js
generated
vendored
Normal file
208
tools/doc/node_modules/sprintf-js/src/sprintf.js
generated
vendored
Normal file
@ -0,0 +1,208 @@
|
||||
(function(window) {
|
||||
var re = {
|
||||
not_string: /[^s]/,
|
||||
number: /[diefg]/,
|
||||
json: /[j]/,
|
||||
not_json: /[^j]/,
|
||||
text: /^[^\x25]+/,
|
||||
modulo: /^\x25{2}/,
|
||||
placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijosuxX])/,
|
||||
key: /^([a-z_][a-z_\d]*)/i,
|
||||
key_access: /^\.([a-z_][a-z_\d]*)/i,
|
||||
index_access: /^\[(\d+)\]/,
|
||||
sign: /^[\+\-]/
|
||||
}
|
||||
|
||||
function sprintf() {
|
||||
var key = arguments[0], cache = sprintf.cache
|
||||
if (!(cache[key] && cache.hasOwnProperty(key))) {
|
||||
cache[key] = sprintf.parse(key)
|
||||
}
|
||||
return sprintf.format.call(null, cache[key], arguments)
|
||||
}
|
||||
|
||||
sprintf.format = function(parse_tree, argv) {
|
||||
var cursor = 1, tree_length = parse_tree.length, node_type = "", arg, output = [], i, k, match, pad, pad_character, pad_length, is_positive = true, sign = ""
|
||||
for (i = 0; i < tree_length; i++) {
|
||||
node_type = get_type(parse_tree[i])
|
||||
if (node_type === "string") {
|
||||
output[output.length] = parse_tree[i]
|
||||
}
|
||||
else if (node_type === "array") {
|
||||
match = parse_tree[i] // convenience purposes only
|
||||
if (match[2]) { // keyword argument
|
||||
arg = argv[cursor]
|
||||
for (k = 0; k < match[2].length; k++) {
|
||||
if (!arg.hasOwnProperty(match[2][k])) {
|
||||
throw new Error(sprintf("[sprintf] property '%s' does not exist", match[2][k]))
|
||||
}
|
||||
arg = arg[match[2][k]]
|
||||
}
|
||||
}
|
||||
else if (match[1]) { // positional argument (explicit)
|
||||
arg = argv[match[1]]
|
||||
}
|
||||
else { // positional argument (implicit)
|
||||
arg = argv[cursor++]
|
||||
}
|
||||
|
||||
if (get_type(arg) == "function") {
|
||||
arg = arg()
|
||||
}
|
||||
|
||||
if (re.not_string.test(match[8]) && re.not_json.test(match[8]) && (get_type(arg) != "number" && isNaN(arg))) {
|
||||
throw new TypeError(sprintf("[sprintf] expecting number but found %s", get_type(arg)))
|
||||
}
|
||||
|
||||
if (re.number.test(match[8])) {
|
||||
is_positive = arg >= 0
|
||||
}
|
||||
|
||||
switch (match[8]) {
|
||||
case "b":
|
||||
arg = arg.toString(2)
|
||||
break
|
||||
case "c":
|
||||
arg = String.fromCharCode(arg)
|
||||
break
|
||||
case "d":
|
||||
case "i":
|
||||
arg = parseInt(arg, 10)
|
||||
break
|
||||
case "j":
|
||||
arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0)
|
||||
break
|
||||
case "e":
|
||||
arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential()
|
||||
break
|
||||
case "f":
|
||||
arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg)
|
||||
break
|
||||
case "g":
|
||||
arg = match[7] ? parseFloat(arg).toPrecision(match[7]) : parseFloat(arg)
|
||||
break
|
||||
case "o":
|
||||
arg = arg.toString(8)
|
||||
break
|
||||
case "s":
|
||||
arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg)
|
||||
break
|
||||
case "u":
|
||||
arg = arg >>> 0
|
||||
break
|
||||
case "x":
|
||||
arg = arg.toString(16)
|
||||
break
|
||||
case "X":
|
||||
arg = arg.toString(16).toUpperCase()
|
||||
break
|
||||
}
|
||||
if (re.json.test(match[8])) {
|
||||
output[output.length] = arg
|
||||
}
|
||||
else {
|
||||
if (re.number.test(match[8]) && (!is_positive || match[3])) {
|
||||
sign = is_positive ? "+" : "-"
|
||||
arg = arg.toString().replace(re.sign, "")
|
||||
}
|
||||
else {
|
||||
sign = ""
|
||||
}
|
||||
pad_character = match[4] ? match[4] === "0" ? "0" : match[4].charAt(1) : " "
|
||||
pad_length = match[6] - (sign + arg).length
|
||||
pad = match[6] ? (pad_length > 0 ? str_repeat(pad_character, pad_length) : "") : ""
|
||||
output[output.length] = match[5] ? sign + arg + pad : (pad_character === "0" ? sign + pad + arg : pad + sign + arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
return output.join("")
|
||||
}
|
||||
|
||||
sprintf.cache = {}
|
||||
|
||||
sprintf.parse = function(fmt) {
|
||||
var _fmt = fmt, match = [], parse_tree = [], arg_names = 0
|
||||
while (_fmt) {
|
||||
if ((match = re.text.exec(_fmt)) !== null) {
|
||||
parse_tree[parse_tree.length] = match[0]
|
||||
}
|
||||
else if ((match = re.modulo.exec(_fmt)) !== null) {
|
||||
parse_tree[parse_tree.length] = "%"
|
||||
}
|
||||
else if ((match = re.placeholder.exec(_fmt)) !== null) {
|
||||
if (match[2]) {
|
||||
arg_names |= 1
|
||||
var field_list = [], replacement_field = match[2], field_match = []
|
||||
if ((field_match = re.key.exec(replacement_field)) !== null) {
|
||||
field_list[field_list.length] = field_match[1]
|
||||
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== "") {
|
||||
if ((field_match = re.key_access.exec(replacement_field)) !== null) {
|
||||
field_list[field_list.length] = field_match[1]
|
||||
}
|
||||
else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
|
||||
field_list[field_list.length] = field_match[1]
|
||||
}
|
||||
else {
|
||||
throw new SyntaxError("[sprintf] failed to parse named argument key")
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new SyntaxError("[sprintf] failed to parse named argument key")
|
||||
}
|
||||
match[2] = field_list
|
||||
}
|
||||
else {
|
||||
arg_names |= 2
|
||||
}
|
||||
if (arg_names === 3) {
|
||||
throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported")
|
||||
}
|
||||
parse_tree[parse_tree.length] = match
|
||||
}
|
||||
else {
|
||||
throw new SyntaxError("[sprintf] unexpected placeholder")
|
||||
}
|
||||
_fmt = _fmt.substring(match[0].length)
|
||||
}
|
||||
return parse_tree
|
||||
}
|
||||
|
||||
var vsprintf = function(fmt, argv, _argv) {
|
||||
_argv = (argv || []).slice(0)
|
||||
_argv.splice(0, 0, fmt)
|
||||
return sprintf.apply(null, _argv)
|
||||
}
|
||||
|
||||
/**
|
||||
* helpers
|
||||
*/
|
||||
function get_type(variable) {
|
||||
return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase()
|
||||
}
|
||||
|
||||
function str_repeat(input, multiplier) {
|
||||
return Array(multiplier + 1).join(input)
|
||||
}
|
||||
|
||||
/**
|
||||
* export to either browser or node.js
|
||||
*/
|
||||
if (typeof exports !== "undefined") {
|
||||
exports.sprintf = sprintf
|
||||
exports.vsprintf = vsprintf
|
||||
}
|
||||
else {
|
||||
window.sprintf = sprintf
|
||||
window.vsprintf = vsprintf
|
||||
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(function() {
|
||||
return {
|
||||
sprintf: sprintf,
|
||||
vsprintf: vsprintf
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})(typeof window === "undefined" ? this : window);
|
1314
tools/doc/package-lock.json
generated
1314
tools/doc/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,14 @@
|
||||
"node": ">=6"
|
||||
},
|
||||
"dependencies": {
|
||||
"marked": "^0.3.5"
|
||||
"marked": "^0.3.5",
|
||||
"rehype-raw": "^2.0.0",
|
||||
"rehype-stringify": "^3.0.0",
|
||||
"remark-parse": "^5.0.0",
|
||||
"remark-rehype": "^3.0.0",
|
||||
"unified": "^7.0.0",
|
||||
"unist-util-find": "^1.0.1",
|
||||
"unist-util-visit": "^1.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"js-yaml": "^3.5.2"
|
||||
|
@ -84,7 +84,9 @@ addlicense "gtest" "deps/gtest" "$(cat ${rootdir}/deps/gtest/LICENSE)"
|
||||
# nghttp2
|
||||
addlicense "nghttp2" "deps/nghttp2" "$(cat ${rootdir}/deps/nghttp2/COPYING)"
|
||||
|
||||
# remark-cli
|
||||
# remark
|
||||
addlicense "unified" "deps/unified" "$(cat ${rootdir}/tools/doc/node_modules/unified/LICENSE)"
|
||||
addlicense "remark-rehype" "deps/remark-rehype" "$(cat ${rootdir}/tools/doc/node_modules/remark-rehype/LICENSE)"
|
||||
addlicense "remark-cli" "tools/remark-cli" "$(cat ${rootdir}/tools/remark-cli/LICENSE)"
|
||||
|
||||
# node-inspect
|
||||
|
31
vcbuild.bat
31
vcbuild.bat
@ -255,7 +255,7 @@ goto exit
|
||||
|
||||
:wix-not-found
|
||||
echo Build skipped. To generate installer, you need to install Wix.
|
||||
goto build-doc
|
||||
goto install-doctools
|
||||
|
||||
:msbuild-found
|
||||
|
||||
@ -385,7 +385,7 @@ exit /b 1
|
||||
|
||||
:msi
|
||||
@rem Skip msi generation if not requested
|
||||
if not defined msi goto build-doc
|
||||
if not defined msi goto install-doctools
|
||||
|
||||
:msibuild
|
||||
echo Building node-v%FULLVERSION%-%target_arch%.msi
|
||||
@ -400,7 +400,7 @@ if errorlevel 1 echo Failed to sign msi&goto exit
|
||||
|
||||
:upload
|
||||
@rem Skip upload if not requested
|
||||
if not defined upload goto build-doc
|
||||
if not defined upload goto install-doctools
|
||||
|
||||
if not defined SSHCONFIG (
|
||||
echo SSHCONFIG is not set for upload
|
||||
@ -428,6 +428,23 @@ ssh -F %SSHCONFIG% %STAGINGSERVER% "touch nodejs/%DISTTYPEDIR%/v%FULLVERSION%/no
|
||||
if errorlevel 1 goto exit
|
||||
|
||||
|
||||
:install-doctools
|
||||
REM only install if building doc OR testing doctool
|
||||
if not defined doc (
|
||||
echo.%test_args% | findstr doctool 1>nul
|
||||
if errorlevel 1 goto :skip-install-doctools
|
||||
)
|
||||
if exist "tools\doc\node_modules\unified\package.json" goto skip-install-doctools
|
||||
SETLOCAL
|
||||
cd tools\doc
|
||||
%npm_exe% install
|
||||
cd ..\..
|
||||
if errorlevel 1 goto exit
|
||||
ENDLOCAL
|
||||
:skip-install-doctools
|
||||
@rem Clear errorlevel from echo.%test_args% | findstr doctool 1>nul
|
||||
cd .
|
||||
|
||||
:build-doc
|
||||
@rem Build documentation if requested
|
||||
if not defined doc goto run
|
||||
@ -439,14 +456,6 @@ mkdir %config%\doc
|
||||
robocopy /e doc\api %config%\doc\api
|
||||
robocopy /e doc\api_assets %config%\doc\api\assets
|
||||
|
||||
if exist "tools\doc\node_modules\js-yaml\package.json" goto doc-skip-js-yaml
|
||||
SETLOCAL
|
||||
cd tools\doc
|
||||
%npm_exe% install
|
||||
cd ..\..
|
||||
if errorlevel 1 goto exit
|
||||
ENDLOCAL
|
||||
:doc-skip-js-yaml
|
||||
for %%F in (%config%\doc\api\*.md) do (
|
||||
%node_exe% tools\doc\generate.js --format=json %%F > %%~dF%%~pF%%~nF.json
|
||||
%node_exe% tools\doc\generate.js --node-version=v%FULLVERSION% --format=html --analytics=%DOCS_ANALYTICS% %%F > %%~dF%%~pF%%~nF.html
|
||||
|
Loading…
x
Reference in New Issue
Block a user