I'm trying to use jsDoc on my js code in which I want to define: - A Namespace. - A Class. - A Static Method. Note that the code does exactly what I expect at runtime, but I have problems to getting started with jsDoc, so I question myself if code is correct...
/** @namespace
* @name myNamespace
* @description myNamespace description.
*/
if (typeof (myNamespace) == "undefined") myNamespace = { };
/** @class
* @name myClass
* @description myClass description.
* @memberof myNamespace
* @inner
*/
myNamespace.myClass = function () { };
/** @method
* @name myStaticMethod
* @description myStaticMethod description.
* @param {String} myParam. Required. myParam description.
* @return myReturnValue description.
* @remarks remarks description.
* @memberof myNamespace.myClass
* @inner
*/
myNamespace.myClass.myStaticMethod = function (myParam) {
var myReturnValue = myParam;
return myReturnValue;
};
When I generate with jsDoc I see in the index: - Correct myNamespace definition. - Correct myClass definition. When I go inside myClass I cannot see myStaticMethod... myStaticMethod is not present anywhere. My JS is coded correctly? If is correctly coded... Is the ments correctly written? What's wrong?
Thanks a lot...
I'm trying to use jsDoc on my js code in which I want to define: - A Namespace. - A Class. - A Static Method. Note that the code does exactly what I expect at runtime, but I have problems to getting started with jsDoc, so I question myself if code is correct...
/** @namespace
* @name myNamespace
* @description myNamespace description.
*/
if (typeof (myNamespace) == "undefined") myNamespace = { };
/** @class
* @name myClass
* @description myClass description.
* @memberof myNamespace
* @inner
*/
myNamespace.myClass = function () { };
/** @method
* @name myStaticMethod
* @description myStaticMethod description.
* @param {String} myParam. Required. myParam description.
* @return myReturnValue description.
* @remarks remarks description.
* @memberof myNamespace.myClass
* @inner
*/
myNamespace.myClass.myStaticMethod = function (myParam) {
var myReturnValue = myParam;
return myReturnValue;
};
When I generate with jsDoc I see in the index: - Correct myNamespace definition. - Correct myClass definition. When I go inside myClass I cannot see myStaticMethod... myStaticMethod is not present anywhere. My JS is coded correctly? If is correctly coded... Is the ments correctly written? What's wrong?
Thanks a lot...
Share asked Sep 19, 2014 at 8:51 FalcoFalco 1,6063 gold badges21 silver badges53 bronze badges 3-
Side note:
typeof
is an operator, not a function; there's no need for parens around the value, for the same reason you can just write1 + 2
rather than(1) + (2)
andnew ClassName()
rather thannew (ClassName())
. – T.J. Crowder Commented Sep 19, 2014 at 9:00 -
Separately, your code relies on The Horror of Implicit Globals to create
myNamespace
. The better way is:var myNamespace;
(which has no effect at all if it already exists) followed by yourtypeof
test. – T.J. Crowder Commented Sep 19, 2014 at 9:01 - Thanks I'll take in mind and will try to refactor the code... – Falco Commented Sep 19, 2014 at 9:10
2 Answers
Reset to default 3If you're going to use @name
, you need to tell JsDoc what the member is; using @name
tells JsDoc to pletely ignore context.
In your case, I think you need to add @static
(you already have @memberof
, so that's good).
T.J. Crowder was right, I cannot vote becouse I'm young in munity, this is the corrected code ments for jsDoc if someone need:
/** @namespace
* @name myNamespace
* @description myNamespace description.
*/
if (typeof (myNamespace) == "undefined") myNamespace = { };
/** @class
* @name myNamespace.myClass
* @description myClass description.
* @memberof myNamespace
* @inner
*/
myNamespace.myClass = function () { };
/** @function
* @static
* @name myNamespace.myClass.myStaticMethod
* @description myStaticMethod description.
* @param {String} myParam. Required. myParam description.
* @return myReturnValue description.
* @remarks remarks description.
* @memberof myNamespace.myClass
* @inner
*/
myNamespace.myClass.myStaticMethod = function (myParam) {
var myReturnValue = myParam;
return myReturnValue;
};