Make code prettier
This updates ESLint and our shared eslint-config-openlayers to use Prettier. Most formatting changes were automatically applied with this:
npm run lint -- --fix
A few manual changes were required:
* In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
* In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason. While editing this, I reworked `ExampleBuilder` to be a class.
* In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
|
||||
|
||||
/**
|
||||
* Handle the api annotation.
|
||||
* @param {Object} dictionary The tag dictionary.
|
||||
*/
|
||||
exports.defineTags = function(dictionary) {
|
||||
|
||||
exports.defineTags = function (dictionary) {
|
||||
dictionary.defineTag('api', {
|
||||
onTagged: function(doclet, tag) {
|
||||
onTagged: function (doclet, tag) {
|
||||
doclet.api = true;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -5,31 +5,27 @@
|
||||
* insensitive, with or without ticks).
|
||||
*/
|
||||
|
||||
|
||||
const DEFAULT_VALUE = /default\s+is\s+`?(true|false)`?/i;
|
||||
|
||||
|
||||
/**
|
||||
* Hook to define new tags.
|
||||
* @param {Object} dictionary The tag dictionary.
|
||||
*/
|
||||
exports.defineTags = function(dictionary) {
|
||||
|
||||
exports.defineTags = function (dictionary) {
|
||||
dictionary.defineTag('define', {
|
||||
canHaveType: true,
|
||||
mustHaveValue: true,
|
||||
onTagged: function(doclet, tag) {
|
||||
onTagged: function (doclet, tag) {
|
||||
const types = tag.value.type.names;
|
||||
if (types.length === 1 && types[0] === 'boolean') {
|
||||
const match = tag.value.description.match(DEFAULT_VALUE);
|
||||
if (match) {
|
||||
doclet.define = {
|
||||
default: match[1] === 'true'
|
||||
default: match[1] === 'true',
|
||||
};
|
||||
doclet.description = tag.value.description;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
+127
-110
@@ -5,18 +5,16 @@
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
|
||||
|
||||
/**
|
||||
* Publish hook for the JSDoc template. Writes to JSON stdout.
|
||||
* @param {function} data The root of the Taffy DB containing doclet records.
|
||||
* @param {Object} opts Options.
|
||||
* @return {Promise} A promise that resolves when writing is complete.
|
||||
*/
|
||||
exports.publish = function(data, opts) {
|
||||
|
||||
exports.publish = function (data, opts) {
|
||||
function getTypes(data) {
|
||||
const types = [];
|
||||
data.forEach(function(name) {
|
||||
data.forEach(function (name) {
|
||||
types.push(name.replace(/^function$/, 'Function'));
|
||||
});
|
||||
return types;
|
||||
@@ -27,19 +25,22 @@ exports.publish = function(data, opts) {
|
||||
const docs = data(
|
||||
[
|
||||
{define: {isObject: true}},
|
||||
function() {
|
||||
function () {
|
||||
if (this.kind == 'class') {
|
||||
if (!('extends' in this) || typeof this.api == 'boolean') {
|
||||
classes[this.longname] = this;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return (typeof this.api == 'boolean' ||
|
||||
this.meta && (/[\\\/]externs$/).test(this.meta.path));
|
||||
}
|
||||
return (
|
||||
typeof this.api == 'boolean' ||
|
||||
(this.meta && /[\\\/]externs$/.test(this.meta.path))
|
||||
);
|
||||
},
|
||||
],
|
||||
{kind: {'!is': 'file'}},
|
||||
{kind: {'!is': 'event'}}).get();
|
||||
{kind: {'!is': 'event'}}
|
||||
).get();
|
||||
|
||||
// get symbols data, filter out those that are members of private classes
|
||||
const symbols = [];
|
||||
@@ -49,117 +50,133 @@ exports.publish = function(data, opts) {
|
||||
let base = [];
|
||||
const augments = {};
|
||||
const symbolsByName = {};
|
||||
docs.filter(function(doc) {
|
||||
let include = true;
|
||||
const constructor = doc.memberof;
|
||||
if (constructor && constructor.substr(-1) === '_' && constructor.indexOf('module:') === -1) {
|
||||
assert.strictEqual(doc.inherited, true,
|
||||
'Unexpected export on private class: ' + doc.longname);
|
||||
include = false;
|
||||
}
|
||||
return include;
|
||||
}).forEach(function(doc) {
|
||||
const isExterns = (/[\\\/]externs$/).test(doc.meta.path);
|
||||
if (doc.define) {
|
||||
defines.push({
|
||||
name: doc.longname,
|
||||
description: doc.description,
|
||||
path: path.join(doc.meta.path, doc.meta.filename),
|
||||
default: doc.define.default
|
||||
});
|
||||
} else if (doc.kind == 'typedef' || doc.isEnum === true) {
|
||||
typedefs.push({
|
||||
name: doc.longname,
|
||||
types: getTypes(doc.type.names)
|
||||
});
|
||||
} else {
|
||||
const symbol = {
|
||||
name: doc.longname,
|
||||
kind: doc.kind,
|
||||
description: doc.classdesc || doc.description,
|
||||
path: path.join(doc.meta.path, doc.meta.filename)
|
||||
};
|
||||
if (doc.augments) {
|
||||
symbol.extends = doc.augments[0];
|
||||
docs
|
||||
.filter(function (doc) {
|
||||
let include = true;
|
||||
const constructor = doc.memberof;
|
||||
if (
|
||||
constructor &&
|
||||
constructor.substr(-1) === '_' &&
|
||||
constructor.indexOf('module:') === -1
|
||||
) {
|
||||
assert.strictEqual(
|
||||
doc.inherited,
|
||||
true,
|
||||
'Unexpected export on private class: ' + doc.longname
|
||||
);
|
||||
include = false;
|
||||
}
|
||||
if (doc.virtual) {
|
||||
symbol.virtual = true;
|
||||
}
|
||||
if (doc.type) {
|
||||
symbol.types = getTypes(doc.type.names);
|
||||
}
|
||||
if (doc.params) {
|
||||
const params = [];
|
||||
doc.params.forEach(function(param) {
|
||||
const paramInfo = {
|
||||
name: param.name
|
||||
};
|
||||
params.push(paramInfo);
|
||||
paramInfo.types = getTypes(param.type.names);
|
||||
if (typeof param.variable == 'boolean') {
|
||||
paramInfo.variable = param.variable;
|
||||
}
|
||||
if (typeof param.optional == 'boolean') {
|
||||
paramInfo.optional = param.optional;
|
||||
}
|
||||
if (typeof param.nullable == 'boolean') {
|
||||
paramInfo.nullable = param.nullable;
|
||||
}
|
||||
return include;
|
||||
})
|
||||
.forEach(function (doc) {
|
||||
const isExterns = /[\\\/]externs$/.test(doc.meta.path);
|
||||
if (doc.define) {
|
||||
defines.push({
|
||||
name: doc.longname,
|
||||
description: doc.description,
|
||||
path: path.join(doc.meta.path, doc.meta.filename),
|
||||
default: doc.define.default,
|
||||
});
|
||||
symbol.params = params;
|
||||
}
|
||||
if (doc.returns) {
|
||||
symbol.returns = {
|
||||
types: getTypes(doc.returns[0].type.names)
|
||||
} else if (doc.kind == 'typedef' || doc.isEnum === true) {
|
||||
typedefs.push({
|
||||
name: doc.longname,
|
||||
types: getTypes(doc.type.names),
|
||||
});
|
||||
} else {
|
||||
const symbol = {
|
||||
name: doc.longname,
|
||||
kind: doc.kind,
|
||||
description: doc.classdesc || doc.description,
|
||||
path: path.join(doc.meta.path, doc.meta.filename),
|
||||
};
|
||||
if (typeof doc.returns[0].nullable == 'boolean') {
|
||||
symbol.returns.nullable = doc.returns[0].nullable;
|
||||
if (doc.augments) {
|
||||
symbol.extends = doc.augments[0];
|
||||
}
|
||||
}
|
||||
if (doc.tags) {
|
||||
doc.tags.every(function(tag) {
|
||||
if (tag.title == 'template') {
|
||||
symbol.template = tag.value;
|
||||
return false;
|
||||
if (doc.virtual) {
|
||||
symbol.virtual = true;
|
||||
}
|
||||
if (doc.type) {
|
||||
symbol.types = getTypes(doc.type.names);
|
||||
}
|
||||
if (doc.params) {
|
||||
const params = [];
|
||||
doc.params.forEach(function (param) {
|
||||
const paramInfo = {
|
||||
name: param.name,
|
||||
};
|
||||
params.push(paramInfo);
|
||||
paramInfo.types = getTypes(param.type.names);
|
||||
if (typeof param.variable == 'boolean') {
|
||||
paramInfo.variable = param.variable;
|
||||
}
|
||||
if (typeof param.optional == 'boolean') {
|
||||
paramInfo.optional = param.optional;
|
||||
}
|
||||
if (typeof param.nullable == 'boolean') {
|
||||
paramInfo.nullable = param.nullable;
|
||||
}
|
||||
});
|
||||
symbol.params = params;
|
||||
}
|
||||
if (doc.returns) {
|
||||
symbol.returns = {
|
||||
types: getTypes(doc.returns[0].type.names),
|
||||
};
|
||||
if (typeof doc.returns[0].nullable == 'boolean') {
|
||||
symbol.returns.nullable = doc.returns[0].nullable;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
const target = isExterns ? externs : (doc.api ? symbols : base);
|
||||
const existingSymbol = symbolsByName[symbol.name];
|
||||
if (existingSymbol) {
|
||||
const idx = target.indexOf(existingSymbol);
|
||||
target.splice(idx, 1);
|
||||
}
|
||||
target.push(symbol);
|
||||
symbolsByName[symbol.name] = symbol;
|
||||
|
||||
if (doc.api && symbol.extends) {
|
||||
while (symbol.extends in classes && !classes[symbol.extends].api &&
|
||||
classes[symbol.extends].augments) {
|
||||
symbol.extends = classes[symbol.extends].augments[0];
|
||||
}
|
||||
if (symbol.extends) {
|
||||
augments[symbol.extends] = true;
|
||||
if (doc.tags) {
|
||||
doc.tags.every(function (tag) {
|
||||
if (tag.title == 'template') {
|
||||
symbol.template = tag.value;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
const target = isExterns ? externs : doc.api ? symbols : base;
|
||||
const existingSymbol = symbolsByName[symbol.name];
|
||||
if (existingSymbol) {
|
||||
const idx = target.indexOf(existingSymbol);
|
||||
target.splice(idx, 1);
|
||||
}
|
||||
target.push(symbol);
|
||||
symbolsByName[symbol.name] = symbol;
|
||||
|
||||
if (doc.api && symbol.extends) {
|
||||
while (
|
||||
symbol.extends in classes &&
|
||||
!classes[symbol.extends].api &&
|
||||
classes[symbol.extends].augments
|
||||
) {
|
||||
symbol.extends = classes[symbol.extends].augments[0];
|
||||
}
|
||||
if (symbol.extends) {
|
||||
augments[symbol.extends] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
base = base.filter(function (symbol) {
|
||||
return symbol.name in augments || symbol.virtual;
|
||||
});
|
||||
|
||||
base = base.filter(function(symbol) {
|
||||
return (symbol.name in augments || symbol.virtual);
|
||||
});
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
process.stdout.write(
|
||||
JSON.stringify({
|
||||
symbols: symbols,
|
||||
defines: defines,
|
||||
typedefs: typedefs,
|
||||
externs: externs,
|
||||
base: base
|
||||
}, null, 2));
|
||||
JSON.stringify(
|
||||
{
|
||||
symbols: symbols,
|
||||
defines: defines,
|
||||
typedefs: typedefs,
|
||||
externs: externs,
|
||||
base: base,
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -2,15 +2,13 @@
|
||||
* Handle the interface and abstract annotations.
|
||||
* @param {Object} dictionary The tag dictionary.
|
||||
*/
|
||||
exports.defineTags = function(dictionary) {
|
||||
|
||||
exports.defineTags = function (dictionary) {
|
||||
const classTag = dictionary.lookUp('class');
|
||||
dictionary.defineTag('interface', {
|
||||
mustNotHaveValue: true,
|
||||
onTagged: function(doclet, tag) {
|
||||
onTagged: function (doclet, tag) {
|
||||
classTag.onTagged.apply(this, arguments);
|
||||
doclet.virtual = true;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user