From 959e14c31a7ed95cd97d116be2105d55c96b2a13 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Tue, 6 May 2014 10:14:28 -0500 Subject: [PATCH] Handle observables and fires augments in plugins This makes it easier to switch themes. --- apidoc/conf.json | 11 ++++--- apidoc/plugins/api.js | 45 +++++++++++++++++++++----- apidoc/plugins/events.js | 2 +- apidoc/plugins/observable.js | 9 +++++- apidoc/plugins/typedefs.js | 2 +- apidoc/template/tmpl/container.tmpl | 49 +++-------------------------- 6 files changed, 59 insertions(+), 59 deletions(-) diff --git a/apidoc/conf.json b/apidoc/conf.json index fc2f7b1db8..732f32ae9e 100644 --- a/apidoc/conf.json +++ b/apidoc/conf.json @@ -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 } diff --git a/apidoc/plugins/api.js b/apidoc/plugins/api.js index 2072e09526..6d653f993f 100644 --- a/apidoc/plugins/api.js +++ b/apidoc/plugins/api.js @@ -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; } diff --git a/apidoc/plugins/events.js b/apidoc/plugins/events.js index d7332ad58d..741ea88965 100644 --- a/apidoc/plugins/events.js +++ b/apidoc/plugins/events.js @@ -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); diff --git a/apidoc/plugins/observable.js b/apidoc/plugins/observable.js index be4bb10729..b3bcd4a918 100644 --- a/apidoc/plugins/observable.js +++ b/apidoc/plugins/observable.js @@ -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); + } } } } diff --git a/apidoc/plugins/typedefs.js b/apidoc/plugins/typedefs.js index a1a6a1df4f..af6215e915 100644 --- a/apidoc/plugins/typedefs.js +++ b/apidoc/plugins/typedefs.js @@ -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; diff --git a/apidoc/template/tmpl/container.tmpl b/apidoc/template/tmpl/container.tmpl index 99465b373b..c1baaef3ce 100644 --- a/apidoc/template/tmpl/container.tmpl +++ b/apidoc/template/tmpl/container.tmpl @@ -1,45 +1,6 @@ @@ -147,16 +108,16 @@

Observable Properties

-
+
- +

Fires

-