Merge pull request #2785 from ahocevar/export-goog

Use goog.* types in externs
This commit is contained in:
Andreas Hocevar
2014-10-06 16:50:02 +02:00
2 changed files with 5 additions and 30 deletions
+1 -18
View File
@@ -22,14 +22,6 @@ exports.publish = function(data, opts) {
return types; return types;
} }
function replaceUnknownTypes(item) {
item.types.forEach(function(type, index) {
if (!(type in names)) {
item.types[index] = '*';
}
});
}
// get all doclets with the "api" property or define (excluding events) or // get all doclets with the "api" property or define (excluding events) or
// with olx namespace // with olx namespace
var classes = {}; var classes = {};
@@ -168,16 +160,7 @@ exports.publish = function(data, opts) {
}); });
base = base.filter(function(symbol) { base = base.filter(function(symbol) {
var pass = symbol.name in augments || symbol.virtual; return (symbol.name in augments || symbol.virtual);
if (pass) {
if (symbol.params) {
symbol.params.forEach(replaceUnknownTypes);
}
if (symbol.returns) {
symbol.returns.forEach(replaceUnknownTypes);
}
}
return pass;
}); });
process.stdout.write( process.stdout.write(
+4 -12
View File
@@ -67,14 +67,6 @@ function generateExterns(typedefs, symbols, externs, base) {
return name; return name;
} }
function noGoogTypes(typesWithGoog) {
var typesWithoutGoog = [];
typesWithGoog.forEach(function(type) {
typesWithoutGoog.push(type.replace(googRegEx, '*'));
});
return typesWithoutGoog;
}
// Store in "constructorOptionsTypes" type names that start // Store in "constructorOptionsTypes" type names that start
// with "ol." and end with "Options". // with "ol." and end with "Options".
function findConstructorOptionsTypes(types) { function findConstructorOptionsTypes(types) {
@@ -111,7 +103,7 @@ function generateExterns(typedefs, symbols, externs, base) {
} }
} }
if (symbol.types) { if (symbol.types) {
lines.push(' * @type {' + noGoogTypes(symbol.types).join('|') + '}'); lines.push(' * @type {' + symbol.types.join('|') + '}');
} }
var args = []; var args = [];
if (symbol.params) { if (symbol.params) {
@@ -120,7 +112,7 @@ function generateExterns(typedefs, symbols, externs, base) {
args.push(param.name); args.push(param.name);
lines.push(' * @param {' + lines.push(' * @param {' +
(param.variable ? '...' : '') + (param.variable ? '...' : '') +
noGoogTypes(param.types).join('|') + param.types.join('|') +
(param.optional ? '=' : '') + (param.nullable ? '!' : '') + (param.optional ? '=' : '') + (param.nullable ? '!' : '') +
'} ' + param.name); '} ' + param.name);
}); });
@@ -128,7 +120,7 @@ function generateExterns(typedefs, symbols, externs, base) {
if (symbol.returns) { if (symbol.returns) {
lines.push(' * @return {' + lines.push(' * @return {' +
(symbol.returns.nullable ? '!' : '') + (symbol.returns.nullable ? '!' : '') +
noGoogTypes(symbol.returns.types).join('|') + '}'); symbol.returns.types.join('|') + '}');
} }
if (symbol.template) { if (symbol.template) {
lines.push(' * @template ' + symbol.template); lines.push(' * @template ' + symbol.template);
@@ -155,7 +147,7 @@ function generateExterns(typedefs, symbols, externs, base) {
addNamespaces(typedef.name); addNamespaces(typedef.name);
lines.push('/**'); lines.push('/**');
lines.push(' * @typedef {' + noGoogTypes(typedef.types).join('|') + '}'); lines.push(' * @typedef {' + typedef.types.join('|') + '}');
lines.push(' */'); lines.push(' */');
lines.push(nameToJS(typedef.name) + ';'); lines.push(nameToJS(typedef.name) + ';');
lines.push('\n'); lines.push('\n');