diff --git a/apidoc/conf.json b/apidoc/conf.json index 4b06ee9790..fc2f7b1db8 100644 --- a/apidoc/conf.json +++ b/apidoc/conf.json @@ -25,6 +25,7 @@ "apidoc/plugins/typedefs", "apidoc/plugins/api", "apidoc/plugins/todo", + "apidoc/plugins/events", "apidoc/plugins/observable" ], "markdown": { diff --git a/apidoc/plugins/events.js b/apidoc/plugins/events.js new file mode 100644 index 0000000000..d7332ad58d --- /dev/null +++ b/apidoc/plugins/events.js @@ -0,0 +1,47 @@ +var events = {}; +var classes = {}; + +exports.handlers = { + + newDoclet: function(e) { + var doclet = e.doclet; + var cls; + if (doclet.kind == 'event') { + cls = doclet.longname.split('#')[0]; + if (!(cls in events)) { + events[cls] = []; + } + events[cls].push(doclet.longname); + } else if (doclet.kind == 'class') { + classes[doclet.longname] = doclet; + } + }, + + parseComplete: function(e) { + var doclets = e.doclets; + var eventClass, doclet, i, ii, j, jj, event, fires; + for (i = 0, ii = doclets.length - 1; i < ii; ++i) { + doclet = doclets[i]; + if (doclet.fires) { + if (doclet.kind == 'class') { + fires = []; + for (j = 0, jj = doclet.fires.length; j < jj; ++j) { + event = doclet.fires[j].replace('event:', ''); + if (events[event]) { + fires.push.apply(fires, events[event]); + } + } + doclet.fires = fires; + } else { + eventClass = classes[doclet.longname.split('#')[0]]; + if (!(fires in eventClass)) { + eventClass.fires = []; + } + eventClass.fires.push.apply(eventClass.fires, doclet.fires); + } + } + } + } + +}; + diff --git a/apidoc/template/tmpl/container.tmpl b/apidoc/template/tmpl/container.tmpl index 309b1195b5..99465b373b 100644 --- a/apidoc/template/tmpl/container.tmpl +++ b/apidoc/template/tmpl/container.tmpl @@ -1,27 +1,36 @@ = 0; --i) { - var parent = parents[i]; - while (parent) { - parent = self.find({longname: parent})[0]; - if (!parent) { break; } - if (parent.observables) { - observables = observables.concat(parent.observables); - } - if (parent.fires) { - fires = fires.concat(parent.fires); - } - parent = parent.augments; + 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) { @@ -146,10 +155,10 @@ -

Fires

- +

Fires

+ +
  • - + + () + + + +

    +

  • \ No newline at end of file diff --git a/apidoc/template/tmpl/method.tmpl b/apidoc/template/tmpl/method.tmpl index 088e5f46ef..bd4161a401 100644 --- a/apidoc/template/tmpl/method.tmpl +++ b/apidoc/template/tmpl/method.tmpl @@ -40,10 +40,10 @@ var self = this; - +
    Fires: