Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new jsdoc plugin to fix event names #708

Merged
merged 1 commit into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
});
}
};