From a09f7fb3bb0323ada6a8eae2401bc66a91d8bb0f Mon Sep 17 00:00:00 2001
From: Tim Schaub
Date: Thu, 19 Apr 2018 17:27:02 -0600
Subject: [PATCH] Clean lint from jsdoc config
---
.eslintignore | 1 +
config/jsdoc/api/plugins/api.js | 26 +-
config/jsdoc/api/plugins/events.js | 14 +-
config/jsdoc/api/plugins/inheritdoc.js | 18 +-
config/jsdoc/api/plugins/observable.js | 16 +-
config/jsdoc/api/plugins/typedefs.js | 57 +-
config/jsdoc/api/template/publish.js | 748 +++++++++++++------------
config/jsdoc/info/define-plugin.js | 6 +-
config/jsdoc/info/virtual-plugin.js | 2 +-
package.json | 2 +-
10 files changed, 448 insertions(+), 442 deletions(-)
diff --git a/.eslintignore b/.eslintignore
index d6f9d6349f..dcc754f246 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,3 +1,4 @@
examples/Jugl.js
examples/resources/
build/package/**/*webgl*
+config/jsdoc/api/template/static/scripts/
\ No newline at end of file
diff --git a/config/jsdoc/api/plugins/api.js b/config/jsdoc/api/plugins/api.js
index c0e795eff2..8204835459 100644
--- a/config/jsdoc/api/plugins/api.js
+++ b/config/jsdoc/api/plugins/api.js
@@ -1,5 +1,6 @@
/**
* Define an @api tag
+ * @param {Object} dictionary The tag dictionary.
*/
exports.defineTags = function(dictionary) {
dictionary.defineTag('api', {
@@ -8,32 +9,31 @@ exports.defineTags = function(dictionary) {
canHaveName: false,
onTagged: function(doclet, tag) {
includeTypes(doclet);
- doclet.stability = "stable";
+ doclet.stability = 'stable';
}
});
};
-
/*
* Based on @api annotations, and assuming that items with no @api annotation
* should not be documented, this plugin removes undocumented symbols
* from the documentation.
*/
-var api = [];
-var classes = {};
-var types = {};
+const api = [];
+const classes = {};
+const types = {};
function hasApiMembers(doclet) {
return doclet.longname.split('#')[0] == this.longname;
}
function includeAugments(doclet) {
- var augments = doclet.augments;
+ const augments = doclet.augments;
if (augments) {
- var cls;
- for (var i = augments.length - 1; i >= 0; --i) {
+ let cls;
+ for (let i = augments.length - 1; i >= 0; --i) {
cls = classes[augments[i]];
if (cls) {
includeAugments(cls);
@@ -68,7 +68,7 @@ function includeAugments(doclet) {
function extractTypes(item) {
item.type.names.forEach(function(type) {
- var match = type.match(/^(.*<)?([^>]*)>?$/);
+ const match = type.match(/^(.*<)?([^>]*)>?$/);
if (match) {
types[match[2]] = true;
}
@@ -94,7 +94,7 @@ function includeTypes(doclet) {
exports.handlers = {
newDoclet: function(e) {
- var doclet = e.doclet;
+ const doclet = e.doclet;
// Keep track of api items - needed in parseComplete to determine classes
// with api members.
if (doclet.meta.filename == 'olx.js' && doclet.kind == 'typedef') {
@@ -114,9 +114,9 @@ exports.handlers = {
},
parseComplete: function(e) {
- var doclets = e.doclets;
- for (var i = doclets.length - 1; i >= 0; --i) {
- var doclet = doclets[i];
+ const doclets = e.doclets;
+ for (let i = doclets.length - 1; i >= 0; --i) {
+ const doclet = doclets[i];
if (doclet.stability || doclet.namespace_) {
if (doclet.kind == 'class') {
includeAugments(doclet);
diff --git a/config/jsdoc/api/plugins/events.js b/config/jsdoc/api/plugins/events.js
index 52141b2427..b1ffa9dfba 100644
--- a/config/jsdoc/api/plugins/events.js
+++ b/config/jsdoc/api/plugins/events.js
@@ -1,11 +1,11 @@
-var events = {};
-var classes = {};
+const events = {};
+const classes = {};
exports.handlers = {
newDoclet: function(e) {
- var doclet = e.doclet;
- var cls;
+ const doclet = e.doclet;
+ let cls;
if (doclet.kind == 'event') {
cls = doclet.longname.split('#')[0];
if (!(cls in events)) {
@@ -18,8 +18,8 @@ exports.handlers = {
},
parseComplete: function(e) {
- var doclets = e.doclets;
- var doclet, i, ii, j, jj, event, fires;
+ const doclets = e.doclets;
+ let doclet, i, ii, j, jj, event, fires;
for (i = 0, ii = doclets.length - 1; i < ii; ++i) {
doclet = doclets[i];
if (doclet.fires) {
@@ -28,7 +28,7 @@ exports.handlers = {
for (j = 0, jj = doclet.fires.length; j < jj; ++j) {
event = doclet.fires[j].replace('event:', '');
if (events[event]) {
- fires.push.apply(fires, events[event]);
+ fires.push.apply(fires, events[event]);
} else {
fires.push(doclet.fires[j]);
}
diff --git a/config/jsdoc/api/plugins/inheritdoc.js b/config/jsdoc/api/plugins/inheritdoc.js
index 04397af7c6..e252269bcc 100644
--- a/config/jsdoc/api/plugins/inheritdoc.js
+++ b/config/jsdoc/api/plugins/inheritdoc.js
@@ -19,16 +19,16 @@ exports.defineTags = function(dictionary) {
};
-var lookup = {};
-var incompleteByClass = {};
-var keepKeys = ['comment', 'meta', 'name', 'memberof', 'longname', 'augment',
- 'stability'];
+const lookup = {};
+const incompleteByClass = {};
+const keepKeys = ['comment', 'meta', 'name', 'memberof', 'longname', 'augment',
+ 'stability'];
exports.handlers = {
newDoclet: function(e) {
- var doclet = e.doclet;
- var incompletes;
+ const doclet = e.doclet;
+ let incompletes;
if (!(doclet.longname in lookup)) {
lookup[doclet.longname] = [];
}
@@ -45,9 +45,9 @@ exports.handlers = {
},
parseComplete: function(e) {
- var ancestors, candidate, candidates, doclet, i, j, k, l, key;
- var incompleteDoclet, stability, incomplete, incompletes;
- var doclets = e.doclets;
+ let ancestors, candidate, candidates, doclet, i, j, k, l, key;
+ let incompleteDoclet, stability, incomplete, incompletes;
+ const doclets = e.doclets;
for (i = doclets.length - 1; i >= 0; --i) {
doclet = doclets[i];
if (doclet.augments) {
diff --git a/config/jsdoc/api/plugins/observable.js b/config/jsdoc/api/plugins/observable.js
index 99b87e50a0..4622987d07 100644
--- a/config/jsdoc/api/plugins/observable.js
+++ b/config/jsdoc/api/plugins/observable.js
@@ -1,25 +1,25 @@
-var classes = {};
-var observables = {};
+const classes = {};
+const observables = {};
exports.handlers = {
newDoclet: function(e) {
- var doclet = e.doclet;
+ const doclet = e.doclet;
if (doclet.kind == 'class') {
classes[doclet.longname] = doclet;
}
},
parseComplete: function(e) {
- var doclets = e.doclets;
- var cls, doclet, event, i, ii, observable;
+ const doclets = e.doclets;
+ let cls, doclet, event, i, ii, observable;
for (i = 0, ii = doclets.length - 1; i < ii; ++i) {
doclet = doclets[i];
cls = classes[doclet.longname.split('#')[0]];
if (typeof doclet.observable == 'string' && cls) {
- var name = doclet.name.replace(/^[sg]et/, '');
+ let name = doclet.name.replace(/^[sg]et/, '');
name = name.substr(0, 1).toLowerCase() + name.substr(1);
- var key = doclet.longname.split('#')[0] + '#' + name;
+ const key = doclet.longname.split('#')[0] + '#' + name;
doclet.observable = key;
if (!observables[key]) {
observables[key] = {};
@@ -27,7 +27,7 @@ exports.handlers = {
observable = observables[key];
observable.name = name;
observable.readonly = typeof observable.readonly == 'boolean' ?
- observable.readonly : true;
+ observable.readonly : true;
if (doclet.name.indexOf('get') === 0) {
observable.type = doclet.returns[0].type;
observable.description = doclet.returns[0].description;
diff --git a/config/jsdoc/api/plugins/typedefs.js b/config/jsdoc/api/plugins/typedefs.js
index 67fe8ad4df..d2ff907286 100644
--- a/config/jsdoc/api/plugins/typedefs.js
+++ b/config/jsdoc/api/plugins/typedefs.js
@@ -3,19 +3,19 @@
* Changes @enum annotations into @typedef.
*/
-var lastOlxTypedef = null;
-var olxTypes = {};
+let lastOlxTypedef = null;
+const olxTypes = {};
// names of the olx typenames
-var olxTypeNames = [];
+const olxTypeNames = [];
// types that are undefined or typedefs containing undefined
-var undefinedLikes = null;
+let undefinedLikes = null;
function addSubparams(params) {
- for (var j = 0, jj = params.length; j < jj; ++j) {
- var param = params[j];
- var types = param.type.names;
- for (var k = 0, kk = types.length; k < kk; ++k) {
- var name = types[k];
+ for (let j = 0, jj = params.length; j < jj; ++j) {
+ const param = params[j];
+ const types = param.type.names;
+ for (let k = 0, kk = types.length; k < kk; ++k) {
+ const name = types[k];
if (name in olxTypes) {
param.subparams = olxTypes[name];
// TODO addSubparams(param.subparams);
@@ -30,20 +30,22 @@ function addSubparams(params) {
/**
* Changes the description of the param, if it is found to be a required
* option of an olxTypeName.
+ * @param {Object} doclet The doclet.
+ * @returns {Object} The modified doclet.
*/
-function markRequiredIfNeeded(doclet){
- var memberof = doclet.memberof;
+function markRequiredIfNeeded(doclet) {
+ const memberof = doclet.memberof;
// only check doclets that belong to an olxTypeName
if (!memberof || olxTypeNames.indexOf(memberof) == -1) {
return doclet;
}
- var types = doclet.type.names;
- var isRequiredParam = true;
+ const types = doclet.type.names;
+ let isRequiredParam = true;
// iterate over all types that are like-undefined (see above for explanation)
- for (var idx = undefinedLikes.length - 1; idx >= 0; idx--) {
- var undefinedLike = undefinedLikes[idx];
+ for (let idx = undefinedLikes.length - 1; idx >= 0; idx--) {
+ const undefinedLike = undefinedLikes[idx];
// … if the current types contains a type that is undefined-like,
// it is not required.
if (types.indexOf(undefinedLike) != -1) {
@@ -52,9 +54,9 @@ function markRequiredIfNeeded(doclet){
}
if (isRequiredParam) {
- var reqSnippet = 'Required.
';
- var endsWithP = /<\/p>$/i;
- var description = doclet.description;
+ const reqSnippet = 'Required.';
+ const endsWithP = /<\/p>$/i;
+ let description = doclet.description;
if (description && endsWithP.test(description)) {
description = description.replace(endsWithP, ' ' + reqSnippet);
} else if (doclet.description === undefined) {
@@ -69,13 +71,14 @@ function markRequiredIfNeeded(doclet){
* Iterates over all doclets and finds the names of types that contain
* undefined. Stores the names in the global variable undefinedLikes, so
* that e.g. markRequiredIfNeeded can use these.
+ * @param {Array} doclets The doclets.
*/
function findTypesLikeUndefined(doclets) {
undefinedLikes = ['undefined']; // include type 'undefined' explicitly
- for (var i = doclets.length - 1; i >= 0; --i) {
- var doclet = doclets[i];
- if(doclet.kind === 'typedef') {
- var types = doclet.type.names;
+ for (let i = doclets.length - 1; i >= 0; --i) {
+ const doclet = doclets[i];
+ if (doclet.kind === 'typedef') {
+ const types = doclet.type.names;
if (types.indexOf('undefined') !== -1) {
// the typedef contains 'undefined', so it self is undefinedLike.
undefinedLikes.push(doclet.longname);
@@ -87,7 +90,7 @@ function findTypesLikeUndefined(doclets) {
exports.handlers = {
newDoclet: function(e) {
- var doclet = e.doclet;
+ const doclet = e.doclet;
if (doclet.meta.filename == 'olx.js') {
if (doclet.kind == 'typedef') {
lastOlxTypedef = doclet;
@@ -108,11 +111,11 @@ exports.handlers = {
},
parseComplete: function(e) {
- var doclets = e.doclets;
+ const doclets = e.doclets;
findTypesLikeUndefined(doclets);
- for (var i = doclets.length - 1; i >= 0; --i) {
- var doclet = doclets[i];
- var params = doclet.params;
+ for (let i = doclets.length - 1; i >= 0; --i) {
+ const doclet = doclets[i];
+ const params = doclet.params;
if (params) {
addSubparams(params);
}
diff --git a/config/jsdoc/api/template/publish.js b/config/jsdoc/api/template/publish.js
index c98be1de77..aa17a11b8a 100644
--- a/config/jsdoc/api/template/publish.js
+++ b/config/jsdoc/api/template/publish.js
@@ -1,152 +1,152 @@
/*global env: true */
-var template = require('jsdoc/lib/jsdoc/template'),
- fs = require('jsdoc/lib/jsdoc/fs'),
- path = require('jsdoc/lib/jsdoc/path'),
- taffy = require('taffydb').taffy,
- handle = require('jsdoc/lib/jsdoc/util/error').handle,
- helper = require('jsdoc/lib/jsdoc/util/templateHelper'),
- _ = require('underscore'),
- htmlsafe = helper.htmlsafe,
- linkto = helper.linkto,
- resolveAuthorLinks = helper.resolveAuthorLinks,
- scopeToPunc = helper.scopeToPunc,
- hasOwnProp = Object.prototype.hasOwnProperty,
- data,
- view,
- outdir = env.opts.destination;
+const template = require('jsdoc/lib/jsdoc/template');
+const fs = require('jsdoc/lib/jsdoc/fs');
+const path = require('jsdoc/lib/jsdoc/path');
+const taffy = require('taffydb').taffy;
+const handle = require('jsdoc/lib/jsdoc/util/error').handle;
+const helper = require('jsdoc/lib/jsdoc/util/templateHelper');
+const _ = require('underscore');
+const htmlsafe = helper.htmlsafe;
+const linkto = helper.linkto;
+const resolveAuthorLinks = helper.resolveAuthorLinks;
+const hasOwnProp = Object.prototype.hasOwnProperty;
+const outdir = env.opts.destination;
+
+let view;
+let data;
function find(spec) {
- return helper.find(data, spec);
+ return helper.find(data, spec);
}
function tutoriallink(tutorial) {
- return helper.toTutorial(tutorial, null, { tag: 'em', classname: 'disabled', prefix: 'Tutorial: ' });
+ return helper.toTutorial(tutorial, null, {tag: 'em', classname: 'disabled', prefix: 'Tutorial: '});
}
function getAncestorLinks(doclet) {
- return helper.getAncestorLinks(data, doclet);
+ return helper.getAncestorLinks(data, doclet);
}
function hashToLink(doclet, hash) {
- if ( !/^(#.+)/.test(hash) ) { return hash; }
+ if (!/^(#.+)/.test(hash)) {
+ return hash;
+ }
- var url = helper.createLink(doclet);
+ let url = helper.createLink(doclet);
- url = url.replace(/(#.+|$)/, hash);
- return '' + hash + '';
+ url = url.replace(/(#.+|$)/, hash);
+ return '' + hash + '';
}
function needsSignature(doclet) {
- var needsSig = false;
+ let needsSig = false;
- // function and class definitions always get a signature
- if (doclet.kind === 'function' || doclet.kind === 'class') {
- needsSig = true;
- }
+ // function and class definitions always get a signature
+ if (doclet.kind === 'function' || doclet.kind === 'class') {
+ needsSig = true;
+ } else if (doclet.kind === 'typedef' && doclet.type && doclet.type.names &&
+ doclet.type.names.length) {
// typedefs that contain functions get a signature, too
- else if (doclet.kind === 'typedef' && doclet.type && doclet.type.names &&
- doclet.type.names.length) {
- for (var i = 0, l = doclet.type.names.length; i < l; i++) {
- if (doclet.type.names[i].toLowerCase() === 'function') {
- needsSig = true;
- break;
- }
- }
+ for (let i = 0, l = doclet.type.names.length; i < l; i++) {
+ if (doclet.type.names[i].toLowerCase() === 'function') {
+ needsSig = true;
+ break;
+ }
}
+ }
- return needsSig;
+ return needsSig;
}
function addSignatureParams(f) {
- var params = helper.getSignatureParams(f, 'optional');
+ const params = helper.getSignatureParams(f, 'optional');
- f.signature = (f.signature || '') + '('+params.join(', ')+')';
+ f.signature = (f.signature || '') + '(' + params.join(', ') + ')';
}
function addSignatureReturns(f) {
- var returnTypes = helper.getSignatureReturns(f);
+ const returnTypes = helper.getSignatureReturns(f);
- f.signature = ''+(f.signature || '') + '';
+ f.signature = '' + (f.signature || '') + '';
- if (returnTypes.length) {
- f.signature += ''+(returnTypes.length ? '{'+returnTypes.join('|')+'}' : '')+'';
- }
+ if (returnTypes.length) {
+ f.signature += '' + (returnTypes.length ? '{' + returnTypes.join('|') + '}' : '') + '';
+ }
}
function addSignatureTypes(f) {
- var types = helper.getSignatureTypes(f);
+ const types = helper.getSignatureTypes(f);
- f.signature = (f.signature || '') + ''+(types.length? ' :'+types.join('|') : '')+' ';
+ f.signature = (f.signature || '') + '' + (types.length ? ' :' + types.join('|') : '') + ' ';
}
function shortenPaths(files, commonPrefix) {
- // always use forward slashes
- var regexp = new RegExp('\\\\', 'g');
+ // always use forward slashes
+ const regexp = new RegExp('\\\\', 'g');
- Object.keys(files).forEach(function(file) {
- files[file].shortened = files[file].resolved.replace(commonPrefix, '')
- .replace(regexp, '/');
- });
+ Object.keys(files).forEach(function(file) {
+ files[file].shortened = files[file].resolved.replace(commonPrefix, '')
+ .replace(regexp, '/');
+ });
- return files;
+ return files;
}
function resolveSourcePath(filepath) {
- return path.resolve(process.cwd(), filepath);
+ return path.resolve(process.cwd(), filepath);
}
function getPathFromDoclet(doclet) {
- if (!doclet.meta) {
- return;
- }
+ if (!doclet.meta) {
+ return;
+ }
- var filepath = doclet.meta.path && doclet.meta.path !== 'null' ?
- doclet.meta.path + '/' + doclet.meta.filename.split(/[\/\\]/).pop() :
- doclet.meta.filename;
+ const filepath = doclet.meta.path && doclet.meta.path !== 'null' ?
+ doclet.meta.path + '/' + doclet.meta.filename.split(/[\/\\]/).pop() :
+ doclet.meta.filename;
- return filepath;
+ return filepath;
}
function generate(title, docs, filename, resolveLinks) {
- resolveLinks = resolveLinks === false ? false : true;
+ resolveLinks = resolveLinks === false ? false : true;
- var docData = {
- filename: filename,
- title: title,
- docs: docs,
- packageInfo: ( find({kind: 'package'}) || [] ) [0]
- };
+ const docData = {
+ filename: filename,
+ title: title,
+ docs: docs,
+ packageInfo: (find({kind: 'package'}) || []) [0]
+ };
- var outpath = path.join(outdir, filename),
- html = view.render('container.tmpl', docData);
+ const outpath = path.join(outdir, filename);
+ let html = view.render('container.tmpl', docData);
- if (resolveLinks) {
- html = helper.resolveLinks(html); // turn {@link foo} into foo
- }
+ if (resolveLinks) {
+ html = helper.resolveLinks(html); // turn {@link foo} into foo
+ }
- fs.writeFileSync(outpath, html, 'utf8');
+ fs.writeFileSync(outpath, html, 'utf8');
}
function generateSourceFiles(sourceFiles) {
- Object.keys(sourceFiles).forEach(function(file) {
- var source;
- // links are keyed to the shortened path in each doclet's `meta.filename` property
- var sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
- helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
+ Object.keys(sourceFiles).forEach(function(file) {
+ let source;
+ // links are keyed to the shortened path in each doclet's `meta.filename` property
+ const sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
+ helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
- try {
- source = {
- kind: 'source',
- code: helper.htmlsafe( fs.readFileSync(sourceFiles[file].resolved, 'utf8') )
- };
- }
- catch(e) {
- handle(e);
- }
+ try {
+ source = {
+ kind: 'source',
+ code: helper.htmlsafe(fs.readFileSync(sourceFiles[file].resolved, 'utf8'))
+ };
+ } catch (e) {
+ handle(e);
+ }
- generate('Source: ' + sourceFiles[file].shortened, [source], sourceOutfile,
- false);
- });
+ generate('Source: ' + sourceFiles[file].shortened, [source], sourceOutfile,
+ false);
+ });
}
/**
@@ -161,346 +161,348 @@ function generateSourceFiles(sourceFiles) {
* @param {Array.} modules - The array of module doclets to search.
*/
function attachModuleSymbols(doclets, modules) {
- var symbols = {};
+ const symbols = {};
- // build a lookup table
- doclets.forEach(function(symbol) {
- symbols[symbol.longname] = symbol;
- });
+ // build a lookup table
+ doclets.forEach(function(symbol) {
+ symbols[symbol.longname] = symbol;
+ });
- return modules.map(function(module) {
- if (symbols[module.longname]) {
- module.module = symbols[module.longname];
- module.module.name = module.module.name.replace('module:', 'require("') + '")';
- }
- });
+ modules.forEach(function(module) {
+ if (symbols[module.longname]) {
+ module.module = symbols[module.longname];
+ module.module.name = module.module.name.replace('module:', 'require("') + '")';
+ }
+ });
}
/**
* Create the navigation sidebar.
* @param {object} members The members that will be used to create the sidebar.
- * @param {array