Remove olx.js and code that uses it
This commit is contained in:
@@ -11,8 +11,7 @@
|
|||||||
"excludePattern": "(^|\\/|\\\\)_",
|
"excludePattern": "(^|\\/|\\\\)_",
|
||||||
"include": [
|
"include": [
|
||||||
"src",
|
"src",
|
||||||
"externs/oli.js",
|
"externs/oli.js"
|
||||||
"externs/olx.js"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ function includeTypes(doclet) {
|
|||||||
types[doclet.meta.code.name] = true;
|
types[doclet.meta.code.name] = true;
|
||||||
}
|
}
|
||||||
if (doclet.type && doclet.meta.code.type == 'MemberExpression') {
|
if (doclet.type && doclet.meta.code.type == 'MemberExpression') {
|
||||||
// types in olx.js
|
|
||||||
extractTypes(doclet);
|
extractTypes(doclet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,11 +94,6 @@ exports.handlers = {
|
|||||||
|
|
||||||
newDoclet: function(e) {
|
newDoclet: function(e) {
|
||||||
const 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') {
|
|
||||||
doclet.undocumented = false;
|
|
||||||
}
|
|
||||||
if (doclet.stability) {
|
if (doclet.stability) {
|
||||||
api.push(doclet);
|
api.push(doclet);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Converts olx.js @type annotations into properties of the previous @typedef.
|
|
||||||
* Changes @enum annotations into @typedef.
|
* Changes @enum annotations into @typedef.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let lastOlxTypedef = null;
|
|
||||||
const olxTypes = {};
|
|
||||||
// names of the olx typenames
|
|
||||||
const olxTypeNames = [];
|
|
||||||
// types that are undefined or typedefs containing undefined
|
// types that are undefined or typedefs containing undefined
|
||||||
let undefinedLikes = null;
|
let undefinedLikes = null;
|
||||||
|
|
||||||
function addSubparams(params) {
|
|
||||||
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);
|
|
||||||
// TODO Do we need to support multiple object literal types per
|
|
||||||
// param?
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the description of the param, if it is found to be a required
|
* Changes the description of the param if it is required.
|
||||||
* option of an olxTypeName.
|
|
||||||
* @param {Object} doclet The doclet.
|
* @param {Object} doclet The doclet.
|
||||||
* @returns {Object} The modified doclet.
|
* @returns {Object} The modified doclet.
|
||||||
*/
|
*/
|
||||||
function markRequiredIfNeeded(doclet) {
|
function markRequiredIfNeeded(doclet) {
|
||||||
const memberof = doclet.memberof;
|
const memberof = doclet.memberof;
|
||||||
// only check doclets that belong to an olxTypeName
|
if (!memberof) {
|
||||||
if (!memberof || olxTypeNames.indexOf(memberof) == -1) {
|
|
||||||
return doclet;
|
return doclet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,19 +67,7 @@ exports.handlers = {
|
|||||||
|
|
||||||
newDoclet: function(e) {
|
newDoclet: function(e) {
|
||||||
const doclet = e.doclet;
|
const doclet = e.doclet;
|
||||||
if (doclet.meta.filename == 'olx.js') {
|
if (doclet.isEnum) {
|
||||||
if (doclet.kind == 'typedef') {
|
|
||||||
lastOlxTypedef = doclet;
|
|
||||||
olxTypeNames.push(doclet.longname);
|
|
||||||
olxTypes[doclet.longname] = [];
|
|
||||||
doclet.properties = [];
|
|
||||||
} else if (lastOlxTypedef && doclet.memberof == lastOlxTypedef.longname) {
|
|
||||||
lastOlxTypedef.properties.push(doclet);
|
|
||||||
olxTypes[lastOlxTypedef.longname].push(doclet);
|
|
||||||
} else {
|
|
||||||
lastOlxTypedef = null;
|
|
||||||
}
|
|
||||||
} else if (doclet.isEnum) {
|
|
||||||
// We never export enums, so we document them like typedefs
|
// We never export enums, so we document them like typedefs
|
||||||
doclet.kind = 'typedef';
|
doclet.kind = 'typedef';
|
||||||
delete doclet.isEnum;
|
delete doclet.isEnum;
|
||||||
@@ -114,12 +78,7 @@ exports.handlers = {
|
|||||||
const doclets = e.doclets;
|
const doclets = e.doclets;
|
||||||
findTypesLikeUndefined(doclets);
|
findTypesLikeUndefined(doclets);
|
||||||
for (let i = doclets.length - 1; i >= 0; --i) {
|
for (let i = doclets.length - 1; i >= 0; --i) {
|
||||||
const doclet = doclets[i];
|
markRequiredIfNeeded(doclets[i]);
|
||||||
const params = doclet.params;
|
|
||||||
if (params) {
|
|
||||||
addSubparams(params);
|
|
||||||
}
|
|
||||||
markRequiredIfNeeded(doclet);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -203,8 +203,8 @@ function buildNav(members) {
|
|||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
_.each(merged, function(v) {
|
_.each(merged, function(v) {
|
||||||
// exclude 'olx' and interfaces from sidebar
|
// exclude interfaces from sidebar
|
||||||
if (v.longname.indexOf('olx') !== 0 && v.interface !== true) {
|
if (v.interface !== true) {
|
||||||
if (v.kind == 'namespace') {
|
if (v.kind == 'namespace') {
|
||||||
nav.push({
|
nav.push({
|
||||||
type: 'namespace',
|
type: 'namespace',
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ exports.publish = function(data, opts) {
|
|||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get all doclets with the "api" property or define (excluding events) or
|
// get all doclets with the "api" property or define (excluding events)
|
||||||
// with olx namespace
|
|
||||||
const classes = {};
|
const classes = {};
|
||||||
const docs = data(
|
const docs = data(
|
||||||
[
|
[
|
||||||
@@ -61,24 +60,7 @@ exports.publish = function(data, opts) {
|
|||||||
return include;
|
return include;
|
||||||
}).forEach(function(doc) {
|
}).forEach(function(doc) {
|
||||||
const isExterns = (/[\\\/]externs$/).test(doc.meta.path);
|
const isExterns = (/[\\\/]externs$/).test(doc.meta.path);
|
||||||
if (isExterns && doc.longname.indexOf('olx.') === 0) {
|
if (doc.define) {
|
||||||
if (doc.kind == 'typedef') {
|
|
||||||
typedefs.push({
|
|
||||||
name: doc.longname,
|
|
||||||
types: ['{}']
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const typedef = typedefs[typedefs.length - 1];
|
|
||||||
if (!typedef) {
|
|
||||||
throw new Error(`Expected to see a typedef before ${doc.longname} at ${doc.meta.filename}:${doc.meta.lineno}`);
|
|
||||||
}
|
|
||||||
const type = typedef.types[0];
|
|
||||||
typedef.types[0] = type
|
|
||||||
.replace(/\}$/, ', ' + doc.longname.split('#')[1] +
|
|
||||||
': (' + getTypes(doc.type.names).join('|') + ')}')
|
|
||||||
.replace('{, ', '{');
|
|
||||||
}
|
|
||||||
} else if (doc.define) {
|
|
||||||
defines.push({
|
defines.push({
|
||||||
name: doc.longname,
|
name: doc.longname,
|
||||||
description: doc.description,
|
description: doc.description,
|
||||||
|
|||||||
@@ -177,7 +177,6 @@ The minimum config file looks like this:
|
|||||||
],
|
],
|
||||||
"js": [
|
"js": [
|
||||||
"node_modules/openlayers/src/ol/typedefs.js",
|
"node_modules/openlayers/src/ol/typedefs.js",
|
||||||
"node_modules/openlayers/externs/olx.js",
|
|
||||||
"node_modules/openlayers/externs/oli.js"
|
"node_modules/openlayers/externs/oli.js"
|
||||||
],
|
],
|
||||||
"extra_annotation_name": [
|
"extra_annotation_name": [
|
||||||
@@ -229,7 +228,6 @@ Here is a version of `config.json` with more compilation checks enabled:
|
|||||||
],
|
],
|
||||||
"js": [
|
"js": [
|
||||||
"node_modules/openlayers/src/ol/typedefs.js",
|
"node_modules/openlayers/src/ol/typedefs.js",
|
||||||
"node_modules/openlayers/externs/olx.js",
|
|
||||||
"node_modules/openlayers/externs/oli.js"
|
"node_modules/openlayers/externs/oli.js"
|
||||||
],
|
],
|
||||||
"jscomp_error": [
|
"jscomp_error": [
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ Creating a custom build requires writing a build configuration file. The format
|
|||||||
"externs/esrijson.js",
|
"externs/esrijson.js",
|
||||||
"externs/geojson.js",
|
"externs/geojson.js",
|
||||||
"externs/oli.js",
|
"externs/oli.js",
|
||||||
"externs/olx.js",
|
|
||||||
"externs/proj4js.js",
|
"externs/proj4js.js",
|
||||||
"externs/tilejson.js",
|
"externs/tilejson.js",
|
||||||
"externs/topojson.js"
|
"externs/topojson.js"
|
||||||
@@ -169,8 +168,6 @@ and re-run the build script. The build size should now be smaller.
|
|||||||
|
|
||||||
The Closure documentation explains that "externs" are for external names used in the code being compiled. The compiler includes externs for built-ins such as `document`. The `externs` directory of the OpenLayers code includes files for all those used in some part of the library. For example, if you use Bing Maps, you should include the Bing externs file in the `externs` section of the config file.
|
The Closure documentation explains that "externs" are for external names used in the code being compiled. The compiler includes externs for built-ins such as `document`. The `externs` directory of the OpenLayers code includes files for all those used in some part of the library. For example, if you use Bing Maps, you should include the Bing externs file in the `externs` section of the config file.
|
||||||
|
|
||||||
`oli.js` and `olx.js` are externs files for the OpenLayers API. For example `olx.js` includes extern definitions for OpenLayers's constructor options. `closure-compiler.js` fixes any issues that may arise with a specific compiler version. You should always use these three files as externs when creating custom builds.
|
|
||||||
|
|
||||||
### Other compiler options
|
### Other compiler options
|
||||||
|
|
||||||
There are a couple of other compiler options in the config file above. `manage_closure_dependencies` and `rewrite_polyfills` should always be used.
|
There are a couple of other compiler options in the config file above. `manage_closure_dependencies` and `rewrite_polyfills` should always be used.
|
||||||
@@ -208,7 +205,6 @@ Now let's try a more complicated example: [`heatmaps-earthquakes`](https://openl
|
|||||||
"externs/closure-compiler.js",
|
"externs/closure-compiler.js",
|
||||||
"externs/esrijson.js",
|
"externs/esrijson.js",
|
||||||
"externs/geojson.js",
|
"externs/geojson.js",
|
||||||
"externs/olx.js",
|
|
||||||
"externs/oli.js",
|
"externs/oli.js",
|
||||||
"externs/proj4js.js",
|
"externs/proj4js.js",
|
||||||
"externs/tilejson.js",
|
"externs/tilejson.js",
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
/**
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
let olx;
|
|
||||||
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
This directory contains externs files, which tell the Closure compiler about symbols and properties that it should not rename.
|
This directory contains externs files, which tell the Closure compiler about symbols and properties that it should not rename.
|
||||||
|
|
||||||
## oli.js and olx.js
|
## oli.js
|
||||||
|
|
||||||
These two files are special externs that belong to OpenLayers, and this document explains their purpose and how they are used.
|
These are special externs that belong to OpenLayers, and this document explains their purpose and how they are used.
|
||||||
|
|
||||||
### Prevent class properties from being renamed
|
### Prevent class properties from being renamed
|
||||||
|
|
||||||
@@ -82,39 +82,3 @@ ol.control.Control.prototype.setMap = function(map) {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
See Custom controls example for an example of how this can be used.
|
See Custom controls example for an example of how this can be used.
|
||||||
|
|
||||||
### Export object literals
|
|
||||||
|
|
||||||
Object literals cannot be exported like classes. To make sure that their properties do not get renamed, they go in `olx.js`:
|
|
||||||
```js
|
|
||||||
/**
|
|
||||||
* @typedef {{element: (Element|undefined),
|
|
||||||
* target: (Element|string|undefined)}}
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
olx.control.ControlOptions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The element is the control's container element. This only needs to be
|
|
||||||
* specified if you're developing a custom control.
|
|
||||||
* @type {Element|undefined}
|
|
||||||
*/
|
|
||||||
olx.control.ControlOptions.prototype.element;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specify a target if you want the control to be rendered outside of the map's
|
|
||||||
* viewport.
|
|
||||||
* @type {Element|string|undefined}
|
|
||||||
*/
|
|
||||||
olx.control.ControlOptions.prototype.target;
|
|
||||||
```
|
|
||||||
In the source code, the name used for the typedef is used as type whenever this object literal is expected:
|
|
||||||
```js
|
|
||||||
/**
|
|
||||||
* ...
|
|
||||||
* @param {olx.control.ControlOptions} options Control options.
|
|
||||||
*/
|
|
||||||
ol.control.Control = function(options) {
|
|
||||||
// ...
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ const isWindows = process.platform.indexOf('win') === 0;
|
|||||||
const sourceDir = path.join(__dirname, '..', 'src');
|
const sourceDir = path.join(__dirname, '..', 'src');
|
||||||
const externsDir = path.join(__dirname, '..', 'externs');
|
const externsDir = path.join(__dirname, '..', 'externs');
|
||||||
const externsPaths = [
|
const externsPaths = [
|
||||||
path.join(externsDir, 'olx.js'),
|
|
||||||
path.join(externsDir, 'geojson.js')
|
path.join(externsDir, 'geojson.js')
|
||||||
];
|
];
|
||||||
const infoPath = path.join(__dirname, '..', 'build', 'info.json');
|
const infoPath = path.join(__dirname, '..', 'build', 'info.json');
|
||||||
|
|||||||
Reference in New Issue
Block a user