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

@emits links to method if the event has the same name #30

Open
VividVisions opened this issue Dec 28, 2023 · 3 comments
Open

@emits links to method if the event has the same name #30

VividVisions opened this issue Dec 28, 2023 · 3 comments
Assignees
Labels
future Will be fixed/implemented in future version of ESDoc

Comments

@VividVisions
Copy link

Is there a way to differentiate an event from a method if they have the same name (other than renaming one or both)?
How to document the event itself?

@EnterTheNameHere
Copy link
Owner

If you have a simple example of code of such situation, it would be appreciated.

@VividVisions
Copy link
Author

import { EventEmitter } from 'node:events';

/**
 * Test class
 */
class Test extends EventEmitter {
   /**
    * Foo function.
    * @emits {bar}
    */
   foo(str) {
      this.emit('bar', str);
      return str + '!';
   }

   /**
    * Bar function.
    */
   bar(num) {
      return num + 1;
   }
}

This would link the event bar to the method bar in the rendered HTML.

And there don't seem to be a way to document events as their own symbols.
Something like that:

/**
 * Event bar.
 * Gets fired when foo() is called.
 *
 * @event bar
 * @param {String} - The string
 */

@EnterTheNameHere
Copy link
Owner

Yes, this should be easily detected by ESDoc as two different kinds, The @variation tag should also work, but it's not implemented. This can be hacked in, if needed, otherwise updated JSDoc parsing and detection will fix it in future.

@EnterTheNameHere EnterTheNameHere self-assigned this Jan 11, 2024
@EnterTheNameHere EnterTheNameHere added the future Will be fixed/implemented in future version of ESDoc label Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
future Will be fixed/implemented in future version of ESDoc
Projects
None yet
Development

No branches or pull requests

2 participants