diff --git a/config/jsdoc/api/conf.json b/config/jsdoc/api/conf.json index c710dd9453..7b44b8f119 100644 --- a/config/jsdoc/api/conf.json +++ b/config/jsdoc/api/conf.json @@ -11,8 +11,7 @@ "excludePattern": "(^|\\/|\\\\)_", "include": [ "src", - "externs/oli.js", - "externs/olx.js" + "externs/oli.js" ] }, "plugins": [ diff --git a/config/jsdoc/api/plugins/api.js b/config/jsdoc/api/plugins/api.js index 8204835459..fbb26b0a37 100644 --- a/config/jsdoc/api/plugins/api.js +++ b/config/jsdoc/api/plugins/api.js @@ -86,7 +86,6 @@ function includeTypes(doclet) { types[doclet.meta.code.name] = true; } if (doclet.type && doclet.meta.code.type == 'MemberExpression') { - // types in olx.js extractTypes(doclet); } } @@ -95,11 +94,6 @@ exports.handlers = { newDoclet: function(e) { 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) { api.push(doclet); } diff --git a/config/jsdoc/api/plugins/typedefs.js b/config/jsdoc/api/plugins/typedefs.js index d2ff907286..66227c3c04 100644 --- a/config/jsdoc/api/plugins/typedefs.js +++ b/config/jsdoc/api/plugins/typedefs.js @@ -1,42 +1,18 @@ /* - * Converts olx.js @type annotations into properties of the previous @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 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 - * option of an olxTypeName. + * Changes the description of the param if it is required. * @param {Object} doclet The doclet. * @returns {Object} The modified doclet. */ function markRequiredIfNeeded(doclet) { const memberof = doclet.memberof; - // only check doclets that belong to an olxTypeName - if (!memberof || olxTypeNames.indexOf(memberof) == -1) { + if (!memberof) { return doclet; } @@ -91,19 +67,7 @@ exports.handlers = { newDoclet: function(e) { const doclet = e.doclet; - if (doclet.meta.filename == 'olx.js') { - 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) { + if (doclet.isEnum) { // We never export enums, so we document them like typedefs doclet.kind = 'typedef'; delete doclet.isEnum; @@ -114,12 +78,7 @@ exports.handlers = { const doclets = e.doclets; findTypesLikeUndefined(doclets); for (let i = doclets.length - 1; i >= 0; --i) { - const doclet = doclets[i]; - const params = doclet.params; - if (params) { - addSubparams(params); - } - markRequiredIfNeeded(doclet); + markRequiredIfNeeded(doclets[i]); } } diff --git a/config/jsdoc/api/template/publish.js b/config/jsdoc/api/template/publish.js index aa17a11b8a..a5d5de68b1 100644 --- a/config/jsdoc/api/template/publish.js +++ b/config/jsdoc/api/template/publish.js @@ -203,8 +203,8 @@ function buildNav(members) { return 0; }); _.each(merged, function(v) { - // exclude 'olx' and interfaces from sidebar - if (v.longname.indexOf('olx') !== 0 && v.interface !== true) { + // exclude interfaces from sidebar + if (v.interface !== true) { if (v.kind == 'namespace') { nav.push({ type: 'namespace', diff --git a/config/jsdoc/info/publish.js b/config/jsdoc/info/publish.js index e1d514265c..bc01c31f89 100644 --- a/config/jsdoc/info/publish.js +++ b/config/jsdoc/info/publish.js @@ -22,8 +22,7 @@ exports.publish = function(data, opts) { return types; } - // get all doclets with the "api" property or define (excluding events) or - // with olx namespace + // get all doclets with the "api" property or define (excluding events) const classes = {}; const docs = data( [ @@ -61,24 +60,7 @@ exports.publish = function(data, opts) { return include; }).forEach(function(doc) { const isExterns = (/[\\\/]externs$/).test(doc.meta.path); - if (isExterns && doc.longname.indexOf('olx.') === 0) { - 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) { + if (doc.define) { defines.push({ name: doc.longname, description: doc.description, diff --git a/doc/tutorials/closure.md b/doc/tutorials/closure.md index f1c56d62ac..d3422b8ae3 100644 --- a/doc/tutorials/closure.md +++ b/doc/tutorials/closure.md @@ -177,7 +177,6 @@ The minimum config file looks like this: ], "js": [ "node_modules/openlayers/src/ol/typedefs.js", - "node_modules/openlayers/externs/olx.js", "node_modules/openlayers/externs/oli.js" ], "extra_annotation_name": [ @@ -229,7 +228,6 @@ Here is a version of `config.json` with more compilation checks enabled: ], "js": [ "node_modules/openlayers/src/ol/typedefs.js", - "node_modules/openlayers/externs/olx.js", "node_modules/openlayers/externs/oli.js" ], "jscomp_error": [ diff --git a/doc/tutorials/custom-builds.md b/doc/tutorials/custom-builds.md index 13b09d8ee3..adc3195811 100644 --- a/doc/tutorials/custom-builds.md +++ b/doc/tutorials/custom-builds.md @@ -56,7 +56,6 @@ Creating a custom build requires writing a build configuration file. The format "externs/esrijson.js", "externs/geojson.js", "externs/oli.js", - "externs/olx.js", "externs/proj4js.js", "externs/tilejson.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. -`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 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/esrijson.js", "externs/geojson.js", - "externs/olx.js", "externs/oli.js", "externs/proj4js.js", "externs/tilejson.js", diff --git a/externs/olx.js b/externs/olx.js deleted file mode 100644 index 5f4c83b8e3..0000000000 --- a/externs/olx.js +++ /dev/null @@ -1,6 +0,0 @@ - -/** - * @type {Object} - */ -let olx; - diff --git a/externs/readme.md b/externs/readme.md index a05104ef2e..579c782c98 100644 --- a/externs/readme.md +++ b/externs/readme.md @@ -2,9 +2,9 @@ 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 @@ -82,39 +82,3 @@ ol.control.Control.prototype.setMap = function(map) { }; ``` 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) { - // ... -}; -``` diff --git a/tasks/generate-info.js b/tasks/generate-info.js index ba328d9b6d..c3eeca4fba 100644 --- a/tasks/generate-info.js +++ b/tasks/generate-info.js @@ -9,7 +9,6 @@ const isWindows = process.platform.indexOf('win') === 0; const sourceDir = path.join(__dirname, '..', 'src'); const externsDir = path.join(__dirname, '..', 'externs'); const externsPaths = [ - path.join(externsDir, 'olx.js'), path.join(externsDir, 'geojson.js') ]; const infoPath = path.join(__dirname, '..', 'build', 'info.json');