Handle observables and fires augments in plugins
This makes it easier to switch themes.
This commit is contained in:
@@ -23,10 +23,10 @@
|
||||
"apidoc/plugins/inheritdoc",
|
||||
"apidoc/plugins/interface",
|
||||
"apidoc/plugins/typedefs",
|
||||
"apidoc/plugins/api",
|
||||
"apidoc/plugins/todo",
|
||||
"apidoc/plugins/events",
|
||||
"apidoc/plugins/observable"
|
||||
"apidoc/plugins/observable",
|
||||
"apidoc/plugins/api"
|
||||
],
|
||||
"markdown": {
|
||||
"parser": "gfm"
|
||||
@@ -35,11 +35,12 @@
|
||||
"levels": ["deprecated","experimental","unstable","stable","frozen","locked"]
|
||||
},
|
||||
"templates": {
|
||||
"cleverLinks": false,
|
||||
"monospaceLinks": false,
|
||||
"cleverLinks": true,
|
||||
"monospaceLinks": true,
|
||||
"default": {
|
||||
"outputSourceFiles": true
|
||||
}
|
||||
},
|
||||
"applicationName": "OpenLayers 3"
|
||||
},
|
||||
"jsVersion": 180
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,45 +1,6 @@
|
||||
<?js
|
||||
var self = this;
|
||||
|
||||
docs.forEach(function(doc, i) {
|
||||
|
||||
var observables, fires;
|
||||
if (doc.kind == 'class') {
|
||||
observables = doc.observables || [];
|
||||
fires = doc.fires || [];
|
||||
var parents = [].concat(doc.augments);
|
||||
var parent = parents.pop();
|
||||
while (parent) {
|
||||
parent = self.find({longname: parent})[0];
|
||||
if (parent) {
|
||||
if (parent.observables) {
|
||||
parent.observables.forEach(function(o) {
|
||||
if (observables.indexOf(o) == -1) {
|
||||
observables.push(o);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (parent.fires) {
|
||||
parent.fires.forEach(function(f) {
|
||||
if (fires.indexOf(f) == -1) {
|
||||
fires.push(f);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (parent.augments) {
|
||||
parents.push.apply(parents, parent.augments);
|
||||
}
|
||||
}
|
||||
parent = parents.pop();
|
||||
}
|
||||
observables.sort();
|
||||
observables.forEach(function(o) {
|
||||
fires.push('ol.ObjectEvent#event:change:' + o.name.toLowerCase());
|
||||
});
|
||||
fires.sort(function(a, b) {
|
||||
return a.split('event:')[1] < b.split('event:')[1] ? -1 : 1;
|
||||
});
|
||||
}
|
||||
?>
|
||||
|
||||
<?js if (doc.kind === 'mainpage' || (doc.kind === 'package')) { ?>
|
||||
@@ -147,16 +108,16 @@
|
||||
<?js } ?>
|
||||
|
||||
<?js
|
||||
if (observables && observables.length && observables.forEach) {
|
||||
if (doc.observables && doc.observables.length && doc.observables.forEach) {
|
||||
?>
|
||||
<h3 class="subsection-title">Observable Properties</h3>
|
||||
<dl><?js= self.partial('observables.tmpl', observables) ?></dl>
|
||||
<dl><?js= self.partial('observables.tmpl', doc.observables) ?></dl>
|
||||
|
||||
<?js } ?>
|
||||
|
||||
<?js if (fires && fires.length) { ?>
|
||||
<?js if (doc.fires && doc.fires.length) { ?>
|
||||
<h3 class="subsection-title">Fires</h3>
|
||||
<ul><?js fires.forEach(function(f) { ?>
|
||||
<ul><?js doc.fires.forEach(function(f) { ?>
|
||||
<?js= self.partial('fires.tmpl', f) ?>
|
||||
<?js }); ?></ul>
|
||||
<?js } ?>
|
||||
@@ -166,7 +127,7 @@
|
||||
if (events && events.length && events.forEach) {
|
||||
?>
|
||||
<h3 class="subsection-title">Events</h3>
|
||||
<?js if (observables && observables.length) { ?>
|
||||
<?js if (doc.observables && doc.observables.length) { ?>
|
||||
<p>These events are available in addition to the <b>Observable Properties</b> events listed above.</p>
|
||||
<?js } ?>
|
||||
<dl><?js= self.partial('events.tmpl', events) ?></dl>
|
||||
|
||||
Reference in New Issue
Block a user