Clean lint from jsdoc config
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
examples/Jugl.js
|
||||
examples/resources/
|
||||
build/package/**/*webgl*
|
||||
config/jsdoc/api/template/static/scripts/
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -19,16 +19,16 @@ exports.defineTags = function(dictionary) {
|
||||
};
|
||||
|
||||
|
||||
var lookup = {};
|
||||
var incompleteByClass = {};
|
||||
var keepKeys = ['comment', 'meta', 'name', 'memberof', 'longname', 'augment',
|
||||
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) {
|
||||
|
||||
@@ -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] = {};
|
||||
|
||||
@@ -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;
|
||||
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 = '<span class="required-option">Required.</span></p>';
|
||||
var endsWithP = /<\/p>$/i;
|
||||
var description = doclet.description;
|
||||
const reqSnippet = '<span class="required-option">Required.</span></p>';
|
||||
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];
|
||||
for (let i = doclets.length - 1; i >= 0; --i) {
|
||||
const doclet = doclets[i];
|
||||
if (doclet.kind === 'typedef') {
|
||||
var types = doclet.type.names;
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/*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);
|
||||
@@ -28,25 +28,26 @@ function getAncestorLinks(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 '<a href="' + url + '">' + hash + '</a>';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
// typedefs that contain functions get a signature, too
|
||||
else if (doclet.kind === 'typedef' && doclet.type && doclet.type.names &&
|
||||
} 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++) {
|
||||
// typedefs that contain functions get a signature, too
|
||||
for (let i = 0, l = doclet.type.names.length; i < l; i++) {
|
||||
if (doclet.type.names[i].toLowerCase() === 'function') {
|
||||
needsSig = true;
|
||||
break;
|
||||
@@ -58,13 +59,13 @@ function needsSignature(doclet) {
|
||||
}
|
||||
|
||||
function addSignatureParams(f) {
|
||||
var params = helper.getSignatureParams(f, 'optional');
|
||||
const params = helper.getSignatureParams(f, 'optional');
|
||||
|
||||
f.signature = (f.signature || '') + '(' + params.join(', ') + ')';
|
||||
}
|
||||
|
||||
function addSignatureReturns(f) {
|
||||
var returnTypes = helper.getSignatureReturns(f);
|
||||
const returnTypes = helper.getSignatureReturns(f);
|
||||
|
||||
f.signature = '<span class="signature">' + (f.signature || '') + '</span>';
|
||||
|
||||
@@ -74,14 +75,14 @@ function addSignatureReturns(f) {
|
||||
}
|
||||
|
||||
function addSignatureTypes(f) {
|
||||
var types = helper.getSignatureTypes(f);
|
||||
const types = helper.getSignatureTypes(f);
|
||||
|
||||
f.signature = (f.signature || '') + '<span class="type-signature">' + (types.length ? ' :' + types.join('|') : '') + ' </span>';
|
||||
}
|
||||
|
||||
function shortenPaths(files, commonPrefix) {
|
||||
// always use forward slashes
|
||||
var regexp = new RegExp('\\\\', 'g');
|
||||
const regexp = new RegExp('\\\\', 'g');
|
||||
|
||||
Object.keys(files).forEach(function(file) {
|
||||
files[file].shortened = files[file].resolved.replace(commonPrefix, '')
|
||||
@@ -100,7 +101,7 @@ function getPathFromDoclet(doclet) {
|
||||
return;
|
||||
}
|
||||
|
||||
var filepath = doclet.meta.path && doclet.meta.path !== 'null' ?
|
||||
const filepath = doclet.meta.path && doclet.meta.path !== 'null' ?
|
||||
doclet.meta.path + '/' + doclet.meta.filename.split(/[\/\\]/).pop() :
|
||||
doclet.meta.filename;
|
||||
|
||||
@@ -110,15 +111,15 @@ function getPathFromDoclet(doclet) {
|
||||
function generate(title, docs, filename, resolveLinks) {
|
||||
resolveLinks = resolveLinks === false ? false : true;
|
||||
|
||||
var docData = {
|
||||
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 <a href="foodoc.html">foo</a>
|
||||
@@ -129,9 +130,9 @@ function generate(title, docs, filename, resolveLinks) {
|
||||
|
||||
function generateSourceFiles(sourceFiles) {
|
||||
Object.keys(sourceFiles).forEach(function(file) {
|
||||
var source;
|
||||
let source;
|
||||
// links are keyed to the shortened path in each doclet's `meta.filename` property
|
||||
var sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
|
||||
const sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
|
||||
helper.registerLink(sourceFiles[file].shortened, sourceOutfile);
|
||||
|
||||
try {
|
||||
@@ -139,8 +140,7 @@ function generateSourceFiles(sourceFiles) {
|
||||
kind: 'source',
|
||||
code: helper.htmlsafe(fs.readFileSync(sourceFiles[file].resolved, 'utf8'))
|
||||
};
|
||||
}
|
||||
catch(e) {
|
||||
} catch (e) {
|
||||
handle(e);
|
||||
}
|
||||
|
||||
@@ -161,14 +161,14 @@ function generateSourceFiles(sourceFiles) {
|
||||
* @param {Array.<module:jsdoc/doclet.Doclet>} 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;
|
||||
});
|
||||
|
||||
return modules.map(function(module) {
|
||||
modules.forEach(function(module) {
|
||||
if (symbols[module.longname]) {
|
||||
module.module = symbols[module.longname];
|
||||
module.module.name = module.module.name.replace('module:', 'require("') + '")';
|
||||
@@ -179,25 +179,27 @@ function attachModuleSymbols(doclets, modules) {
|
||||
/**
|
||||
* Create the navigation sidebar.
|
||||
* @param {object} members The members that will be used to create the sidebar.
|
||||
* @param {array<object>} members.classes
|
||||
* @param {array<object>} members.externals
|
||||
* @param {array<object>} members.globals
|
||||
* @param {array<object>} members.mixins
|
||||
* @param {array<object>} members.modules
|
||||
* @param {array<object>} members.namespaces
|
||||
* @param {array<object>} members.tutorials
|
||||
* @param {array<object>} members.events
|
||||
* @param {Array<Object>} members.classes Classes.
|
||||
* @param {Array<Object>} members.externals Externals.
|
||||
* @param {Array<Object>} members.globals Globals.
|
||||
* @param {Array<Object>} members.mixins Mixins.
|
||||
* @param {Array<Object>} members.modules Modules.
|
||||
* @param {Array<Object>} members.namespaces Namespaces.
|
||||
* @param {Array<Object>} members.tutorials Tutorials.
|
||||
* @param {Array<Object>} members.events Events.
|
||||
* @return {string} The HTML for the navigation sidebar.
|
||||
*/
|
||||
function buildNav(members) {
|
||||
var nav = [];
|
||||
const nav = [];
|
||||
// merge namespaces and classes, then sort
|
||||
var merged = members.namespaces.concat(members.classes);
|
||||
const merged = members.namespaces.concat(members.classes);
|
||||
merged.sort(function(a, b) {
|
||||
if (a.longname > b.longname)
|
||||
if (a.longname > b.longname) {
|
||||
return 1;
|
||||
if (a.longname < b.longname)
|
||||
}
|
||||
if (a.longname < b.longname) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
_.each(merged, function(v) {
|
||||
@@ -257,25 +259,25 @@ function buildNav(members) {
|
||||
|
||||
|
||||
/**
|
||||
@param {TAFFY} taffyData See <http://taffydb.com/>.
|
||||
@param {object} opts
|
||||
@param {Tutorial} tutorials
|
||||
* @param {Object} taffyData See <http://taffydb.com/>.
|
||||
* @param {Object} opts Options.
|
||||
* @param {Object} tutorials Tutorials.
|
||||
*/
|
||||
exports.publish = function(taffyData, opts, tutorials) {
|
||||
data = taffyData;
|
||||
|
||||
var conf = env.conf.templates || {};
|
||||
const conf = env.conf.templates || {};
|
||||
conf['default'] = conf['default'] || {};
|
||||
|
||||
var templatePath = opts.template;
|
||||
const templatePath = opts.template;
|
||||
view = new template.Template(templatePath + '/tmpl');
|
||||
|
||||
// claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
|
||||
// doesn't try to hand them out later
|
||||
var indexUrl = helper.getUniqueFilename('index');
|
||||
const indexUrl = helper.getUniqueFilename('index');
|
||||
// don't call registerLink() on this one! 'index' is also a valid longname
|
||||
|
||||
var globalUrl = helper.getUniqueFilename('global');
|
||||
const globalUrl = helper.getUniqueFilename('global');
|
||||
helper.registerLink('global', globalUrl);
|
||||
|
||||
// set up templating
|
||||
@@ -288,14 +290,14 @@ exports.publish = function(taffyData, opts, tutorials) {
|
||||
data.sort('longname, version, since');
|
||||
helper.addEventListeners(data);
|
||||
|
||||
var sourceFiles = {};
|
||||
var sourceFilePaths = [];
|
||||
let sourceFiles = {};
|
||||
const sourceFilePaths = [];
|
||||
data().each(function(doclet) {
|
||||
doclet.attribs = '';
|
||||
|
||||
if (doclet.examples) {
|
||||
doclet.examples = doclet.examples.map(function(example) {
|
||||
var caption, code;
|
||||
let caption, code;
|
||||
|
||||
if (example.match(/^\s*<caption>([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) {
|
||||
caption = RegExp.$1;
|
||||
@@ -315,8 +317,8 @@ exports.publish = function(taffyData, opts, tutorials) {
|
||||
}
|
||||
|
||||
// build a list of source files
|
||||
var sourcePath;
|
||||
var resolvedSourcePath;
|
||||
let sourcePath;
|
||||
let resolvedSourcePath;
|
||||
if (doclet.meta) {
|
||||
sourcePath = getPathFromDoclet(doclet);
|
||||
resolvedSourcePath = resolveSourcePath(sourcePath);
|
||||
@@ -331,31 +333,31 @@ exports.publish = function(taffyData, opts, tutorials) {
|
||||
fs.mkPath(outdir);
|
||||
|
||||
// copy the template's static files to outdir
|
||||
var fromDir = path.join(templatePath, 'static');
|
||||
var staticFiles = fs.ls(fromDir, 3);
|
||||
const fromDir = path.join(templatePath, 'static');
|
||||
const staticFiles = fs.ls(fromDir, 3);
|
||||
|
||||
staticFiles.forEach(function(fileName) {
|
||||
var toDir = fs.toDir( fileName.replace(fromDir, outdir) );
|
||||
const toDir = fs.toDir(fileName.replace(fromDir, outdir));
|
||||
fs.mkPath(toDir);
|
||||
fs.copyFileSync(fileName, toDir);
|
||||
});
|
||||
|
||||
// copy user-specified static files to outdir
|
||||
var staticFilePaths;
|
||||
var staticFileFilter;
|
||||
var staticFileScanner;
|
||||
let staticFilePaths;
|
||||
let staticFileFilter;
|
||||
let staticFileScanner;
|
||||
if (conf['default'].staticFiles) {
|
||||
staticFilePaths = conf['default'].staticFiles.paths || [];
|
||||
staticFileFilter = new (require('jsdoc/lib/jsdoc/src/filter')).Filter(conf['default'].staticFiles);
|
||||
staticFileScanner = new (require('jsdoc/lib/jsdoc/src/scanner')).Scanner();
|
||||
|
||||
staticFilePaths.forEach(function(filePath) {
|
||||
var extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter);
|
||||
const extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter);
|
||||
|
||||
extraStaticFiles.forEach(function(fileName) {
|
||||
var sourcePath = fs.statSync(filePath).isDirectory() ? filePath :
|
||||
const sourcePath = fs.statSync(filePath).isDirectory() ? filePath :
|
||||
path.dirname(filePath);
|
||||
var toDir = fs.toDir( fileName.replace(sourcePath, outdir) );
|
||||
const toDir = fs.toDir(fileName.replace(sourcePath, outdir));
|
||||
fs.mkPath(toDir);
|
||||
fs.copyFileSync(fileName, toDir);
|
||||
});
|
||||
@@ -366,11 +368,11 @@ exports.publish = function(taffyData, opts, tutorials) {
|
||||
sourceFiles = shortenPaths(sourceFiles, path.commonPrefix(sourceFilePaths));
|
||||
}
|
||||
data().each(function(doclet) {
|
||||
var url = helper.createLink(doclet);
|
||||
const url = helper.createLink(doclet);
|
||||
helper.registerLink(doclet.longname, url);
|
||||
|
||||
// replace the filename with a shortened version of the full path
|
||||
var docletPath;
|
||||
let docletPath;
|
||||
if (doclet.meta) {
|
||||
docletPath = getPathFromDoclet(doclet);
|
||||
docletPath = sourceFiles[docletPath].shortened;
|
||||
@@ -381,12 +383,11 @@ exports.publish = function(taffyData, opts, tutorials) {
|
||||
});
|
||||
|
||||
data().each(function(doclet) {
|
||||
var url = helper.longnameToUrl[doclet.longname];
|
||||
const url = helper.longnameToUrl[doclet.longname];
|
||||
|
||||
if (url.indexOf('#') > -1) {
|
||||
doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
doclet.id = doclet.name;
|
||||
}
|
||||
|
||||
@@ -410,7 +411,7 @@ exports.publish = function(taffyData, opts, tutorials) {
|
||||
}
|
||||
});
|
||||
|
||||
var members = helper.getMembers(data);
|
||||
const members = helper.getMembers(data);
|
||||
members.tutorials = tutorials.children;
|
||||
|
||||
// add template helpers
|
||||
@@ -432,45 +433,47 @@ exports.publish = function(taffyData, opts, tutorials) {
|
||||
generateSourceFiles(sourceFiles);
|
||||
}
|
||||
|
||||
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
|
||||
var files = find({kind: 'file'});
|
||||
const files = find({kind: 'file'});
|
||||
|
||||
generate('Index',
|
||||
[{kind: 'mainpage', readme: opts.readme, longname: (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'}].concat(files),
|
||||
indexUrl);
|
||||
|
||||
// set up the lists that we'll use to generate pages
|
||||
var classes = taffy(members.classes);
|
||||
var modules = taffy(members.modules);
|
||||
var namespaces = taffy(members.namespaces);
|
||||
var mixins = taffy(members.mixins);
|
||||
var externals = taffy(members.externals);
|
||||
const classes = taffy(members.classes);
|
||||
const modules = taffy(members.modules);
|
||||
const namespaces = taffy(members.namespaces);
|
||||
const mixins = taffy(members.mixins);
|
||||
const externals = taffy(members.externals);
|
||||
|
||||
for (var longname in helper.longnameToUrl) {
|
||||
for (const longname in helper.longnameToUrl) {
|
||||
if (hasOwnProp.call(helper.longnameToUrl, longname)) {
|
||||
var myClasses = helper.find(classes, {longname: longname});
|
||||
const myClasses = helper.find(classes, {longname: longname});
|
||||
if (myClasses.length) {
|
||||
generate('Class: ' + myClasses[0].name, myClasses, helper.longnameToUrl[longname]);
|
||||
}
|
||||
|
||||
var myModules = helper.find(modules, {longname: longname});
|
||||
const myModules = helper.find(modules, {longname: longname});
|
||||
if (myModules.length) {
|
||||
generate('Module: ' + myModules[0].name, myModules, helper.longnameToUrl[longname]);
|
||||
}
|
||||
|
||||
var myNamespaces = helper.find(namespaces, {longname: longname});
|
||||
const myNamespaces = helper.find(namespaces, {longname: longname});
|
||||
if (myNamespaces.length) {
|
||||
generate('Namespace: ' + myNamespaces[0].name, myNamespaces, helper.longnameToUrl[longname]);
|
||||
}
|
||||
|
||||
var myMixins = helper.find(mixins, {longname: longname});
|
||||
const myMixins = helper.find(mixins, {longname: longname});
|
||||
if (myMixins.length) {
|
||||
generate('Mixin: ' + myMixins[0].name, myMixins, helper.longnameToUrl[longname]);
|
||||
}
|
||||
|
||||
var myExternals = helper.find(externals, {longname: longname});
|
||||
const myExternals = helper.find(externals, {longname: longname});
|
||||
if (myExternals.length) {
|
||||
generate('External: ' + myExternals[0].name, myExternals, helper.longnameToUrl[longname]);
|
||||
}
|
||||
@@ -479,19 +482,18 @@ exports.publish = function(taffyData, opts, tutorials) {
|
||||
|
||||
// TODO: move the tutorial functions to templateHelper.js
|
||||
function generateTutorial(title, tutorial, filename) {
|
||||
var tutorialData = {
|
||||
const tutorialData = {
|
||||
title: title,
|
||||
header: tutorial.title,
|
||||
content: tutorial.parse(),
|
||||
children: tutorial.children
|
||||
};
|
||||
|
||||
var tutorialPath = path.join(outdir, filename),
|
||||
html = view.render('tutorial.tmpl', tutorialData);
|
||||
|
||||
let html = view.render('tutorial.tmpl', tutorialData);
|
||||
// yes, you can use {@link} in tutorials too!
|
||||
html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
|
||||
|
||||
const tutorialPath = path.join(outdir, filename);
|
||||
fs.writeFileSync(tutorialPath, html, 'utf8');
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
|
||||
var DEFAULT_VALUE = /default\s+is\s+`?(true|false)`?/i;
|
||||
const DEFAULT_VALUE = /default\s+is\s+`?(true|false)`?/i;
|
||||
|
||||
|
||||
/**
|
||||
@@ -19,9 +19,9 @@ exports.defineTags = function(dictionary) {
|
||||
canHaveType: true,
|
||||
mustHaveValue: true,
|
||||
onTagged: function(doclet, tag) {
|
||||
var types = tag.value.type.names;
|
||||
const types = tag.value.type.names;
|
||||
if (types.length === 1 && types[0] === 'boolean') {
|
||||
var match = tag.value.description.match(DEFAULT_VALUE);
|
||||
const match = tag.value.description.match(DEFAULT_VALUE);
|
||||
if (match) {
|
||||
doclet.define = {
|
||||
default: match[1] === 'true'
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
exports.defineTags = function(dictionary) {
|
||||
|
||||
var classTag = dictionary.lookUp('class');
|
||||
const classTag = dictionary.lookUp('class');
|
||||
dictionary.defineTag('interface', {
|
||||
mustHaveValue: false,
|
||||
onTagged: function(doclet, tag) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
],
|
||||
"homepage": "https://openlayers.org/",
|
||||
"scripts": {
|
||||
"lint": "eslint tasks test src/ol examples",
|
||||
"lint": "eslint tasks test src/ol examples config",
|
||||
"pretest": "npm run lint",
|
||||
"posttest": "npm run typecheck",
|
||||
"test": "npm run karma -- --single-run",
|
||||
|
||||
Reference in New Issue
Block a user