jsdoc2md / dmd

The default output template for jsdoc2md
MIT License
39 stars 50 forks source link

@event @type is not printed #99

Open borisovg opened 8 years ago

borisovg commented 8 years ago

There's no mention of type in in the output for event (output in jsdoc2md/jsdoc-to-markdown#9 suggests there once was).

Source:

/**
 * Instance of Test
 *
 * @constructor
 */
function Test () {

}

/**
 * Object event
 *
 * @event Test#event1
 * @type {object}
 * @property {boolean} isPacked - Indicates whether the snowball is tightly packed.
 */

/**
 * String event
 *
 * @event Test#event2
 * @type {string}
 */

Output:

<a name="Test"></a>
## Test
**Kind**: global class  

* [Test](#Test)
  * [new Test()](#new_Test_new)
  * ["event1"](#Test+event_event1)
  * ["event2"](#Test+event_event2)

<a name="new_Test_new"></a>
### new Test()
Instance of Test

<a name="Test+event_event1"></a>
### "event1"
Object event

**Kind**: event emitted by <code>[Test](#Test)</code>  
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| isPacked | <code>boolean</code> | Indicates whether the snowball is tightly packed. |

<a name="Test+event_event2"></a>
### "event2"
String event

**Kind**: event emitted by <code>[Test](#Test)</code>
75lb commented 8 years ago

handbrake-js is a project with documented events - the event docs on this project generate fine..

this source

/**
Fired at regular intervals passing a `progress` object.

@event module:handbrake-js~Handbrake#progress
@param progress {object} - details of encode progress
@param progress.taskNumber {number} - current task index
@param progress.taskCount {number} - total tasks in the queue
@param progress.percentComplete {number} - percent complete
@param progress.fps {number} - Frames per second
@param progress.avgFps {number} - Average frames per second
@param progress.eta {string} - Estimated time until completion
@param progress.task {string} - Task description, either "Encoding" or "Muxing"
*/
Handbrake.prototype._emitProgress = function (progress) {
  if (!this._inProgress) this._emitBegin()
  this.emit('progress', progress)
}

...generates this output

75lb commented 8 years ago

yes, i agree the @type field is ignored.. because the event can pass more than 1 type to the event handler.. instead, define the args the the event fires with as @param, as in my example..

borisovg commented 8 years ago

That doesn't seem right though - the data that an event sends in not a parameter - it might be a parameter in the listener callback and be documented there as such, but for the event it is not.

jsdoc documentation specifically uses "type" and "property" in the "event" example:

http://usejsdoc.org/tags-event.html

75lb commented 8 years ago

both the jsdoc and handbrake-js examples are correct.. they should both be supported (both the @type and @param) method.. the @type method isn't supported yet but it will be in future.