[ACCEPTED]-How to document an event handler in JSDoc?-jsdoc

Accepted answer
Score: 26

The keyword is @listens

Usage example:

/**
 * Outputs the event that happened
 *
 * @param {MyEvent} e - The observable event.
 * @listens MyEvent
 */
function myEventLogger(e) {
    console.log(e);
}

The corollary 1 is the @fires keyword for raising the event.

Score: 0

No, there is no way to document an event handler.

So the best way is to document it as a normal 7 function maybe writing in its description 6 in bold text or upper case that is an "EVENT 5 HANDLER".

You probably already now this, but 4 just in case: you can write it in bold by 3 simply wrapping the text into html tags 2 <strong></strong>.

This answer is now deprecated but it does 1 not let me delete it.

More Related questions