Handle observables and fires augments in plugins
This makes it easier to switch themes.
This commit is contained in:
+38
-7
@@ -27,9 +27,7 @@ exports.defineTags = function(dictionary) {
|
||||
/*
|
||||
* Based on @stability annotations, and assuming that items with no @stability
|
||||
* annotation should not be documented, this plugin removes undocumented symbols
|
||||
* from the documentation. Undocumented classes with documented members get a
|
||||
* 'hideConstructur' property, which is read by the template so it can hide the
|
||||
* constructor.
|
||||
* from the documentation.
|
||||
*/
|
||||
|
||||
function hasApiMembers(doclet) {
|
||||
@@ -37,15 +35,38 @@ function hasApiMembers(doclet) {
|
||||
}
|
||||
|
||||
function includeAugments(doclet) {
|
||||
if (doclet.longname == 'ol.View2D') {
|
||||
debugger
|
||||
}
|
||||
var augments = doclet.augments;
|
||||
if (augments) {
|
||||
var cls;
|
||||
for (var i = augments.length - 1; i >= 0; --i) {
|
||||
cls = classes[augments[i]];
|
||||
if (cls) {
|
||||
cls.hideConstructor = true;
|
||||
delete cls.undocumented;
|
||||
includeAugments(cls);
|
||||
if (cls.fires) {
|
||||
if (!doclet.fires) {
|
||||
doclet.fires = [];
|
||||
}
|
||||
cls.fires.forEach(function(f) {
|
||||
if (doclet.fires.indexOf(f) == -1) {
|
||||
doclet.fires.push(f);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (cls.observables) {
|
||||
if (!doclet.observables) {
|
||||
doclet.observables = [];
|
||||
}
|
||||
cls.observables.forEach(function(f) {
|
||||
if (doclet.observables.indexOf(f) == -1) {
|
||||
doclet.observables.push(f);
|
||||
}
|
||||
});
|
||||
}
|
||||
cls._hideConstructor = true;
|
||||
delete cls.undocumented;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,6 +103,16 @@ exports.handlers = {
|
||||
if (doclet.kind == 'class') {
|
||||
includeAugments(doclet);
|
||||
}
|
||||
if (doclet.fires) {
|
||||
doclet.fires.sort(function(a, b) {
|
||||
return a.split(/#?event:/)[1] < b.split(/#?event:/)[1] ? -1 : 1;
|
||||
});
|
||||
}
|
||||
if (doclet.observables) {
|
||||
doclet.observables.sort(function(a, b) {
|
||||
return a.name < b.name ? -1 : 1;
|
||||
});
|
||||
}
|
||||
// Always document namespaces and items with stability annotation
|
||||
continue;
|
||||
}
|
||||
@@ -89,9 +120,9 @@ exports.handlers = {
|
||||
// Mark undocumented classes with documented members as unexported.
|
||||
// This is used in ../template/tmpl/container.tmpl to hide the
|
||||
// constructor from the docs.
|
||||
doclet.hideConstructor = true;
|
||||
doclet._hideConstructor = true;
|
||||
includeAugments(doclet);
|
||||
} else if (!doclet.hideConstructor) {
|
||||
} else if (!doclet._hideConstructor) {
|
||||
// Remove all other undocumented symbols
|
||||
doclet.undocumented = true;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ exports.handlers = {
|
||||
doclet.fires = fires;
|
||||
} else {
|
||||
eventClass = classes[doclet.longname.split('#')[0]];
|
||||
if (!(fires in eventClass)) {
|
||||
if (!eventClass.fires) {
|
||||
eventClass.fires = [];
|
||||
}
|
||||
eventClass.fires.push.apply(eventClass.fires, doclet.fires);
|
||||
|
||||
@@ -12,7 +12,7 @@ exports.handlers = {
|
||||
|
||||
parseComplete: function(e) {
|
||||
var doclets = e.doclets;
|
||||
var cls, doclet, i, ii, observable;
|
||||
var cls, doclet, event, i, ii, observable;
|
||||
for (i = 0, ii = doclets.length - 1; i < ii; ++i) {
|
||||
doclet = doclets[i];
|
||||
cls = classes[doclet.longname.split('#')[0]];
|
||||
@@ -41,6 +41,13 @@ exports.handlers = {
|
||||
if (cls.observables.indexOf(observable) == -1) {
|
||||
cls.observables.push(observable);
|
||||
}
|
||||
if (!cls.fires) {
|
||||
cls.fires = [];
|
||||
}
|
||||
var event = 'ol.ObjectEvent#event:change:' + name;
|
||||
if (cls.fires.indexOf(event) == -1) {
|
||||
cls.fires.push(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ function addSubparams(params) {
|
||||
var name = types[k];
|
||||
if (name in olxTypes) {
|
||||
param.subparams = olxTypes[name];
|
||||
addSubparams(param.subparams);
|
||||
// TODO addSubparams(param.subparams);
|
||||
// TODO Do we need to support multiple object literal types per
|
||||
// param?
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user