JSDoc and Dojo and @memberof/@member/global

404 views
Skip to first unread message

Walid Bakkar

unread,
Feb 27, 2012, 8:40:26 AM2/27/12
to JSDoc Users
How would i document a class like this one in JSDoc3?
-----------------------------------------------------
dojo.provide("SomeClass");

dojo.declare("SomeClass,
null,
{
//some private member
_props: null,

constructor: function() {
//some constructor code
},
//some function
meth: function(args) {
//the function body
}
});
-----------------------------------------------------
In JSDoc-toolkit, it would like this:
/**
* SomeClass is used for x, y and z
* @fileOverview
*/

dojo.provide("SomeClass");

dojo.declare("SomeClass",
null,
{

/**
* @lends SomeClass.prototype
*/

/**
* doc for the property
* @field
*/
_props: null,

/**
* constructor documentation
* @constructs
*/
constructor: function() {
this._connections = [];
},


/**
* @param {Object} args, passed argument...
* @function
*/
meth: function(args) {
//the function body
}
});
-----------------------------------------------------
problem with this version (in jsdoc-toolkit-2.4) is that it can't
document the "args" variable, where args is an object containing other
objects (http://groups.google.com/group/jsdoc-users/browse_thread/
thread/7e65c3027646bb07) which is not supported in jsdoc-toolkit
-----------------------------------------------------
In JSDoc3, using the same code as before, the following breaks:
@construtor (needs to be @class name or @constructs name)
but most Importantly, no methods appear as part of the class, "meth"
and "_props" are all parts of "global".

Adding an @module to this file will transform the output to a "module"
which will contain all the methods.

The only way I got the methods and properties as part of the Object
was by adding:
@class className to the constructor
and then i needed to add
@memeberof className to every method/property (@member wasn't enough,
i had to use memberof and explicitly set the membership of the method/
property to the class)
and
@instance (to avoid <inner> and <static>)



Any suggestions?

thank you.



Royston Shufflebotham

unread,
May 14, 2012, 10:24:29 AM5/14/12
to jsdoc...@googlegroups.com
I'm getting Dojo-declared classes documenting happily without needing memberof everywhere, but you need to move your @lends directive - it applies to the object that's passed into declare:

dojo.declare("SomeClass", 
    null, 
/** 
 * @lends SomeClass.prototype 
 */

       /** 
        * doc for the property 
        * @field 
        */ 
    _props: null,  

...

You'll also need either a @class declaring the existence of the 'lent' class or a @constructs applied to your constructor function. Don't do both - you'll get the class contents appearing twice!

Royston.
Reply all
Reply to author
Forward
0 new messages