Merge pull request #4163 from tschaub/node-four

Fixes for building with Node 4.x.
This commit is contained in:
Tim Schaub
2015-10-31 13:42:55 -06:00
5 changed files with 70 additions and 52 deletions
+1 -1
View File
@@ -16,7 +16,7 @@
] ]
}, },
"plugins": [ "plugins": [
"node_modules/jsdoc/plugins/markdown", "node_modules/jsdoc-fork/plugins/markdown",
"config/jsdoc/api/plugins/inheritdoc", "config/jsdoc/api/plugins/inheritdoc",
"config/jsdoc/api/plugins/typedefs", "config/jsdoc/api/plugins/typedefs",
"config/jsdoc/api/plugins/events", "config/jsdoc/api/plugins/events",
+1 -1
View File
@@ -16,7 +16,7 @@ exports.defineTags = function(dictionary) {
doclet.stability = level; doclet.stability = level;
} else { } else {
var errorText = util.format('Invalid stability level (%s) in %s line %s', tag.text, doclet.meta.filename, doclet.meta.lineno); var errorText = util.format('Invalid stability level (%s) in %s line %s', tag.text, doclet.meta.filename, doclet.meta.lineno);
require('jsdoc/util/error').handle( new Error(errorText) ); require('jsdoc-fork/lib/jsdoc/util/error').handle( new Error(errorText) );
} }
} }
}); });
+37 -37
View File
@@ -1,10 +1,10 @@
/*global env: true */ /*global env: true */
var template = require('jsdoc/template'), var template = require('jsdoc-fork/lib/jsdoc/template'),
fs = require('jsdoc/fs'), fs = require('jsdoc-fork/lib/jsdoc/fs'),
path = require('jsdoc/path'), path = require('jsdoc-fork/lib/jsdoc/path'),
taffy = require('taffydb').taffy, taffy = require('taffydb').taffy,
handle = require('jsdoc/util/error').handle, handle = require('jsdoc-fork/lib/jsdoc/util/error').handle,
helper = require('jsdoc/util/templateHelper'), helper = require('jsdoc-fork/lib/jsdoc/util/templateHelper'),
_ = require('underscore'), _ = require('underscore'),
htmlsafe = helper.htmlsafe, htmlsafe = helper.htmlsafe,
linkto = helper.linkto, linkto = helper.linkto,
@@ -29,9 +29,9 @@ function getAncestorLinks(doclet) {
function hashToLink(doclet, hash) { function hashToLink(doclet, hash) {
if ( !/^(#.+)/.test(hash) ) { return hash; } if ( !/^(#.+)/.test(hash) ) { return hash; }
var url = helper.createLink(doclet); var url = helper.createLink(doclet);
url = url.replace(/(#.+|$)/, hash); url = url.replace(/(#.+|$)/, hash);
return '<a href="' + url + '">' + hash + '</a>'; return '<a href="' + url + '">' + hash + '</a>';
} }
@@ -59,15 +59,15 @@ function needsSignature(doclet) {
function addSignatureParams(f) { function addSignatureParams(f) {
var params = helper.getSignatureParams(f, 'optional'); var params = helper.getSignatureParams(f, 'optional');
f.signature = (f.signature || '') + '('+params.join(', ')+')'; f.signature = (f.signature || '') + '('+params.join(', ')+')';
} }
function addSignatureReturns(f) { function addSignatureReturns(f) {
var returnTypes = helper.getSignatureReturns(f); var returnTypes = helper.getSignatureReturns(f);
f.signature = '<span class="signature">'+(f.signature || '') + '</span>'; f.signature = '<span class="signature">'+(f.signature || '') + '</span>';
if (returnTypes.length) { if (returnTypes.length) {
f.signature += '<span class="glyphicon glyphicon-circle-arrow-right"></span><span class="type-signature returnType">'+(returnTypes.length ? '{'+returnTypes.join('|')+'}' : '')+'</span>'; f.signature += '<span class="glyphicon glyphicon-circle-arrow-right"></span><span class="type-signature returnType">'+(returnTypes.length ? '{'+returnTypes.join('|')+'}' : '')+'</span>';
} }
@@ -75,7 +75,7 @@ function addSignatureReturns(f) {
function addSignatureTypes(f) { function addSignatureTypes(f) {
var types = helper.getSignatureTypes(f); var types = helper.getSignatureTypes(f);
f.signature = (f.signature || '') + '<span class="type-signature">'+(types.length? ' :'+types.join('|') : '')+' </span>'; f.signature = (f.signature || '') + '<span class="type-signature">'+(types.length? ' :'+types.join('|') : '')+' </span>';
} }
@@ -106,7 +106,7 @@ function getPathFromDoclet(doclet) {
return filepath; return filepath;
} }
function generate(title, docs, filename, resolveLinks) { function generate(title, docs, filename, resolveLinks) {
resolveLinks = resolveLinks === false ? false : true; resolveLinks = resolveLinks === false ? false : true;
@@ -115,14 +115,14 @@ function generate(title, docs, filename, resolveLinks) {
title: title, title: title,
docs: docs docs: docs
}; };
var outpath = path.join(outdir, filename), var outpath = path.join(outdir, filename),
html = view.render('container.tmpl', docData); html = view.render('container.tmpl', docData);
if (resolveLinks) { if (resolveLinks) {
html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a> html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
} }
fs.writeFileSync(outpath, html, 'utf8'); fs.writeFileSync(outpath, html, 'utf8');
} }
@@ -153,7 +153,7 @@ function generateSourceFiles(sourceFiles) {
* exports only that class or function), then attach the classes or functions to the `module` * exports only that class or function), then attach the classes or functions to the `module`
* property of the appropriate module doclets. The name of each class or function is also updated * property of the appropriate module doclets. The name of each class or function is also updated
* for display purposes. This function mutates the original arrays. * for display purposes. This function mutates the original arrays.
* *
* @private * @private
* @param {Array.<module:jsdoc/doclet.Doclet>} doclets - The array of classes and functions to * @param {Array.<module:jsdoc/doclet.Doclet>} doclets - The array of classes and functions to
* check. * check.
@@ -268,7 +268,7 @@ exports.publish = function(taffyData, opts, tutorials) {
var templatePath = opts.template; var templatePath = opts.template;
view = new template.Template(templatePath + '/tmpl'); view = new template.Template(templatePath + '/tmpl');
// claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
// doesn't try to hand them out later // doesn't try to hand them out later
var indexUrl = helper.getUniqueFilename('index'); var indexUrl = helper.getUniqueFilename('index');
@@ -291,16 +291,16 @@ exports.publish = function(taffyData, opts, tutorials) {
var sourceFilePaths = []; var sourceFilePaths = [];
data().each(function(doclet) { data().each(function(doclet) {
doclet.attribs = ''; doclet.attribs = '';
if (doclet.examples) { if (doclet.examples) {
doclet.examples = doclet.examples.map(function(example) { doclet.examples = doclet.examples.map(function(example) {
var caption, code; var caption, code;
if (example.match(/^\s*<caption>([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) { if (example.match(/^\s*<caption>([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) {
caption = RegExp.$1; caption = RegExp.$1;
code = RegExp.$3; code = RegExp.$3;
} }
return { return {
caption: caption || '', caption: caption || '',
code: code || example code: code || example
@@ -326,7 +326,7 @@ exports.publish = function(taffyData, opts, tutorials) {
sourceFilePaths.push(resolvedSourcePath); sourceFilePaths.push(resolvedSourcePath);
} }
}); });
// update outdir if necessary, then create outdir // update outdir if necessary, then create outdir
var packageInfo = ( find({kind: 'package'}) || [] ) [0]; var packageInfo = ( find({kind: 'package'}) || [] ) [0];
if (packageInfo && packageInfo.name) { if (packageInfo && packageInfo.name) {
@@ -350,8 +350,8 @@ exports.publish = function(taffyData, opts, tutorials) {
var staticFileScanner; var staticFileScanner;
if (conf['default'].staticFiles) { if (conf['default'].staticFiles) {
staticFilePaths = conf['default'].staticFiles.paths || []; staticFilePaths = conf['default'].staticFiles.paths || [];
staticFileFilter = new (require('jsdoc/src/filter')).Filter(conf['default'].staticFiles); staticFileFilter = new (require('jsdoc-fork/lib/jsdoc/src/filter')).Filter(conf['default'].staticFiles);
staticFileScanner = new (require('jsdoc/src/scanner')).Scanner(); staticFileScanner = new (require('jsdoc-fork/lib/jsdoc/src/scanner')).Scanner();
staticFilePaths.forEach(function(filePath) { staticFilePaths.forEach(function(filePath) {
var extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter); var extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter);
@@ -365,7 +365,7 @@ exports.publish = function(taffyData, opts, tutorials) {
}); });
}); });
} }
if (sourceFilePaths.length) { if (sourceFilePaths.length) {
sourceFiles = shortenPaths( sourceFiles, path.commonPrefix(sourceFilePaths) ); sourceFiles = shortenPaths( sourceFiles, path.commonPrefix(sourceFilePaths) );
} }
@@ -383,7 +383,7 @@ exports.publish = function(taffyData, opts, tutorials) {
} }
} }
}); });
data().each(function(doclet) { data().each(function(doclet) {
var url = helper.longnameToUrl[doclet.longname]; var url = helper.longnameToUrl[doclet.longname];
@@ -393,13 +393,13 @@ exports.publish = function(taffyData, opts, tutorials) {
else { else {
doclet.id = doclet.name; doclet.id = doclet.name;
} }
if ( needsSignature(doclet) ) { if ( needsSignature(doclet) ) {
addSignatureParams(doclet); addSignatureParams(doclet);
addSignatureReturns(doclet); addSignatureReturns(doclet);
} }
}); });
// do this after the urls have all been generated // do this after the urls have all been generated
data().each(function(doclet) { data().each(function(doclet) {
doclet.ancestors = getAncestorLinks(doclet); doclet.ancestors = getAncestorLinks(doclet);
@@ -407,13 +407,13 @@ exports.publish = function(taffyData, opts, tutorials) {
if (doclet.kind === 'member') { if (doclet.kind === 'member') {
addSignatureTypes(doclet); addSignatureTypes(doclet);
} }
if (doclet.kind === 'constant') { if (doclet.kind === 'constant') {
addSignatureTypes(doclet); addSignatureTypes(doclet);
doclet.kind = 'member'; doclet.kind = 'member';
} }
}); });
var members = helper.getMembers(data); var members = helper.getMembers(data);
members.tutorials = tutorials.children; members.tutorials = tutorials.children;
@@ -437,7 +437,7 @@ exports.publish = function(taffyData, opts, tutorials) {
} }
if (members.globals.length) { generate('Global', [{kind: 'globalobj'}], globalUrl); } if (members.globals.length) { generate('Global', [{kind: 'globalobj'}], globalUrl); }
// index page displays information from package.json and lists files // index page displays information from package.json and lists files
var files = find({kind: 'file'}), var files = find({kind: 'file'}),
packages = find({kind: 'package'}); packages = find({kind: 'package'});
@@ -454,14 +454,14 @@ exports.publish = function(taffyData, opts, tutorials) {
var namespaces = taffy(members.namespaces); var namespaces = taffy(members.namespaces);
var mixins = taffy(members.mixins); var mixins = taffy(members.mixins);
var externals = taffy(members.externals); var externals = taffy(members.externals);
for (var longname in helper.longnameToUrl) { for (var longname in helper.longnameToUrl) {
if ( hasOwnProp.call(helper.longnameToUrl, longname) ) { if ( hasOwnProp.call(helper.longnameToUrl, longname) ) {
var myClasses = helper.find(classes, {longname: longname}); var myClasses = helper.find(classes, {longname: longname});
if (myClasses.length) { if (myClasses.length) {
generate('Class: ' + myClasses[0].name, myClasses, helper.longnameToUrl[longname]); generate('Class: ' + myClasses[0].name, myClasses, helper.longnameToUrl[longname]);
} }
var myModules = helper.find(modules, {longname: longname}); var myModules = helper.find(modules, {longname: longname});
if (myModules.length) { if (myModules.length) {
generate('Module: ' + myModules[0].name, myModules, helper.longnameToUrl[longname]); generate('Module: ' + myModules[0].name, myModules, helper.longnameToUrl[longname]);
@@ -471,7 +471,7 @@ exports.publish = function(taffyData, opts, tutorials) {
if (myNamespaces.length) { if (myNamespaces.length) {
generate('Namespace: ' + myNamespaces[0].name, myNamespaces, helper.longnameToUrl[longname]); generate('Namespace: ' + myNamespaces[0].name, myNamespaces, helper.longnameToUrl[longname]);
} }
var myMixins = helper.find(mixins, {longname: longname}); var myMixins = helper.find(mixins, {longname: longname});
if (myMixins.length) { if (myMixins.length) {
generate('Mixin: ' + myMixins[0].name, myMixins, helper.longnameToUrl[longname]); generate('Mixin: ' + myMixins[0].name, myMixins, helper.longnameToUrl[longname]);
@@ -492,16 +492,16 @@ exports.publish = function(taffyData, opts, tutorials) {
content: tutorial.parse(), content: tutorial.parse(),
children: tutorial.children children: tutorial.children
}; };
var tutorialPath = path.join(outdir, filename), var tutorialPath = path.join(outdir, filename),
html = view.render('tutorial.tmpl', tutorialData); html = view.render('tutorial.tmpl', tutorialData);
// yes, you can use {@link} in tutorials too! // yes, you can use {@link} in tutorials too!
html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a> html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
fs.writeFileSync(tutorialPath, html, 'utf8'); fs.writeFileSync(tutorialPath, html, 'utf8');
} }
// tutorials can have only one parent so there is no risk for loops // tutorials can have only one parent so there is no risk for loops
function saveChildren(node) { function saveChildren(node) {
node.children.forEach(function(child) { node.children.forEach(function(child) {
+15 -8
View File
@@ -6,11 +6,14 @@ var assert = require('assert');
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
var Promise = require('bluebird');
/** /**
* Publish hook for the JSDoc template. Writes to JSON stdout. * Publish hook for the JSDoc template. Writes to JSON stdout.
* @param {function} data The root of the Taffy DB containing doclet records. * @param {function} data The root of the Taffy DB containing doclet records.
* @param {Object} opts Options. * @param {Object} opts Options.
* @return {Promise} A promise that resolves when writing is complete.
*/ */
exports.publish = function(data, opts) { exports.publish = function(data, opts) {
@@ -168,13 +171,17 @@ exports.publish = function(data, opts) {
return (symbol.name in augments || symbol.virtual); return (symbol.name in augments || symbol.virtual);
}); });
process.stdout.write( return new Promise(function(resolve, reject) {
JSON.stringify({
symbols: symbols, process.stdout.write(
defines: defines, JSON.stringify({
typedefs: typedefs, symbols: symbols,
externs: externs, defines: defines,
base: base typedefs: typedefs,
}, null, 2)); externs: externs,
base: base
}, null, 2), resolve);
});
}; };
+16 -5
View File
@@ -26,14 +26,15 @@
}, },
"dependencies": { "dependencies": {
"async": "0.9.0", "async": "0.9.0",
"bluebird": "^2.10.1",
"browserify": "9.0.3", "browserify": "9.0.3",
"derequire": "2.0.2",
"closure-util": "1.8.0", "closure-util": "1.8.0",
"derequire": "2.0.2",
"fs-extra": "0.12.0", "fs-extra": "0.12.0",
"glob": "5.0.3", "glob": "5.0.3",
"graceful-fs": "3.0.2", "graceful-fs": "3.0.2",
"handlebars": "3.0.1", "handlebars": "3.0.1",
"jsdoc": "3.3.2", "jsdoc-fork": "^4.0.0-beta.1",
"marked": "0.3.5", "marked": "0.3.5",
"metalsmith": "1.6.0", "metalsmith": "1.6.0",
"metalsmith-templates": "0.7.0", "metalsmith-templates": "0.7.0",
@@ -66,8 +67,18 @@
}, },
"ext": [ "ext": [
"rbush", "rbush",
{"module": "pbf", "browserify": true}, {
{"module": "pixelworks", "browserify": true}, "module": "pbf",
{"module": "vector-tile", "name": "vectortile", "browserify": true} "browserify": true
},
{
"module": "pixelworks",
"browserify": true
},
{
"module": "vector-tile",
"name": "vectortile",
"browserify": true
}
] ]
} }