diff --git a/config/jsdoc/info/conf.json b/config/jsdoc/info/conf.json index 51c3048bc5..b40d1d7c43 100644 --- a/config/jsdoc/info/conf.json +++ b/config/jsdoc/info/conf.json @@ -12,6 +12,6 @@ "plugins": [ "config/jsdoc/info/api-plugin", "config/jsdoc/info/define-plugin", - "config/jsdoc/info/interface-plugin" + "config/jsdoc/info/virtual-plugin" ] } diff --git a/config/jsdoc/info/publish.js b/config/jsdoc/info/publish.js index 1c390bb43f..b7988f4dbe 100644 --- a/config/jsdoc/info/publish.js +++ b/config/jsdoc/info/publish.js @@ -14,9 +14,6 @@ var path = require('path'); */ exports.publish = function(data, opts) { - var exportables = {}; - var classes = {}; - function getTypes(data) { var types = []; data.forEach(function(name) { @@ -25,18 +22,29 @@ exports.publish = function(data, opts) { 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 // with olx namespace + var classes = {}; var docs = data( [ {define: {isObject: true}}, - {api: {isString: true}}, - {'interface': {is: true}}, function() { if (this.kind == 'class') { - classes[this.longname] = this; + if (!('extends' in this) || typeof this.api == 'string') { + classes[this.longname] = this; + return true; + } } - return this.meta && (/[\\\/]externs$/).test(this.meta.path); + return (typeof this.api == 'string' || + this.meta && (/[\\\/]externs$/).test(this.meta.path)); } ], {kind: {'!is': 'file'}}, @@ -47,7 +55,9 @@ exports.publish = function(data, opts) { var defines = []; var typedefs = []; var externs = []; - var interfaces = []; + var base = []; + var augments = {}; + var names = {}; docs.filter(function(doc) { var include = true; var constructor = doc.memberof; @@ -97,6 +107,9 @@ exports.publish = function(data, opts) { if (doc.augments) { symbol.extends = doc.augments[0]; } + if (doc.virtual) { + symbol.virtual = true; + } if (doc.type) { symbol.types = getTypes(doc.type.names); } @@ -137,28 +150,43 @@ exports.publish = function(data, opts) { return true; }); } - var target = isExterns ? externs : (doc.interface ? interfaces : symbols); - target.push(symbol); - if (symbol.stability && symbol.kind == 'class') { - exportables[symbol.name] = true; - } - if (symbol.extends) { - while (!(symbol.extends in exportables) && - symbol.extends in classes && classes[symbol.extends].augments) { + var target = isExterns ? externs : (doc.api ? symbols : base); + target.push(symbol); + names[symbol.name] = true; + + 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) { + var pass = 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( JSON.stringify({ symbols: symbols, defines: defines, typedefs: typedefs, externs: externs, - interfaces: interfaces + base: base }, null, 2)); }; diff --git a/config/jsdoc/info/interface-plugin.js b/config/jsdoc/info/virtual-plugin.js similarity index 79% rename from config/jsdoc/info/interface-plugin.js rename to config/jsdoc/info/virtual-plugin.js index 1da619a3fe..52cc894cef 100644 --- a/config/jsdoc/info/interface-plugin.js +++ b/config/jsdoc/info/virtual-plugin.js @@ -1,5 +1,5 @@ /** - * Handle the interface annotation. + * Handle the interface and abstract annotations. * @param {Object} dictionary The tag dictionary. */ exports.defineTags = function(dictionary) { @@ -9,7 +9,7 @@ exports.defineTags = function(dictionary) { mustHaveValue: false, onTagged: function(doclet, tag) { classTag.onTagged.apply(this, arguments); - doclet.interface = true; + doclet.virtual = true; } }); diff --git a/tasks/generate-externs.js b/tasks/generate-externs.js index ecb9b8f216..81af5d2b82 100644 --- a/tasks/generate-externs.js +++ b/tasks/generate-externs.js @@ -21,7 +21,7 @@ function getInfo(callback) { return; } var info = require('../build/info.json'); - callback(null, info.typedefs, info.symbols, info.externs, info.interfaces); + callback(null, info.typedefs, info.symbols, info.externs, info.base); }); } @@ -31,11 +31,11 @@ function getInfo(callback) { * @param {Array.} typedefs List of typedefs. * @param {Array.} symbols List of symbols. * @param {Array.} externs List of externs. - * @param {Array.} externs List of interfaces. + * @param {Array.} base List of base. * @param {string|undefined} namespace Target object for exported symbols. * @return {string} Export code. */ -function generateExterns(typedefs, symbols, externs, interfaces) { +function generateExterns(typedefs, symbols, externs, base) { var lines = []; var processedSymbols = {}; var constructors = {}; @@ -132,7 +132,7 @@ function generateExterns(typedefs, symbols, externs, interfaces) { externs.forEach(processSymbol); - interfaces.forEach(processSymbol); + base.forEach(processSymbol); symbols.forEach(processSymbol); @@ -158,10 +158,10 @@ function generateExterns(typedefs, symbols, externs, interfaces) { function main(callback) { async.waterfall([ getInfo, - function(typedefs, symbols, externs, interfaces, done) { + function(typedefs, symbols, externs, base, done) { var code, err; try { - code = generateExterns(typedefs, symbols, externs, interfaces); + code = generateExterns(typedefs, symbols, externs, base); } catch (e) { err = e; }