I'm trying to document mongoose model methods with jsdoc. A model's method belongs to the model, thus I would like to see it as it's member method.
The file contains a top level @module models
line as well.
/**
* @constructor
*/
var MySchema = new Schema({
title: {
type: String,
required: true
}
});
/**
* My method
*
* @function myMethod
* @memberof MySchema
* @this MySchema
* @param {ObjectId} object
* @params {Array} roles, defaults to all
* @returns Participant or null
*/
MySchema.method('myMethod', function(object, roles) {
// ...
});
Currently I receive a module page that contains a link to my class definition, and a page documenting the class definition, but the method does not appear on any of these pages. When I remove @memberof
, then the method appears on the module page. I would like to have it on the class page though.
What part of the jsdoc docs am I missing?
You have to be explicit about the module:
@memberof module:models~MySchema
The fact is that jsdoc is not going to infer that when you specify MySchema
you mean the MySchema
entity which is in the current module.
Same with @this
, actually. If you modify it to have the module name, then in the documentation the part about this
will have a link to the definition of MySchema
.