Skip to content

Commit

Permalink
Merge pull request #708 from OpenGeoscience/jsdoc-events-plugin
Browse files Browse the repository at this point in the history
Add a new jsdoc plugin to fix event names
  • Loading branch information
jbeezley authored Jun 14, 2017
2 parents 03d8fce + 0c5c8ff commit 6a5a1a2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions jsdoc.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"template": "node_modules/jaguarjs-jsdoc"
},
"plugins": [
"jsdoc/plugins/events",
"node_modules/jsdoc-autoprivate/autoprivate.js",
"plugins/markdown"
],
Expand Down
34 changes: 34 additions & 0 deletions jsdoc/plugins/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function fixEventName(event) {
return event.replace('event:', '');
}

/**
* Define a jsdoc plugin to replace the `longname` of
* event doclets from `geo.event.event:pan` to `geo.event.pan`.
*/
exports.handlers = {
/**
* Replace the `longname` of all event doclets.
*/
newDoclet: function (e) {
var doclet = e.doclet;
if (doclet.kind === 'event') {
doclet.longname = fixEventName(doclet.longname);
}
},

/**
* Replace the displayed name of events to match the changed
* doclet names.
*/
parseComplete: function (e) {
e.doclets.forEach(function (doclet) {
if (doclet.fires) {
doclet.fires = doclet.fires.map(fixEventName);
}
if (doclet.listens) {
doclet.listens = doclet.listens.map(fixEventName);
}
});
}
};

0 comments on commit 6a5a1a2

Please sign in to comment.