How do I jsdoc a script that has functions that have functions.

80 views
Skip to first unread message

RTS...@gmail.com

unread,
May 11, 2009, 4:13:17 PM5/11/09
to JsDoc Toolkit Users
How do I jsdoc a script that has functions that contain functions?
When I try it seems to only doc the top level function like it is not
expecting a function to have functions. I don't know if this is
something that is not supported because web centric javascript doesn't
use functions that contain functions. I am working in an environment
where we are using javascript as a programming language and we have a
javascript virtual machine that compiles and runs the code as if it
were not a script. An example of this code is below. This code is
treated as if it were a java class and the first function
FunctionCollection is the "Class" and the "SubFunctions" are the class
"Methods".

/************************************************************
* FunctionCollection()
* @author rtstone
*
*************************************************************/
function FunctionCollection(){
var globalVarOne;

/************************************************************
* SubFunctionOne()
*
* @param paramOne
* @param paramTwo
* @return retVal1
*
*************************************************************/
function SubFunctionOne(var paramOne, var paramTwo){
return retVal1;
}

/************************************************************
* SubFunctionTwo()
*
* @param paramThree
* @param paramFour
* @return retVal2
*
*************************************************************/
function SubFunctionTwo(var paramThree, var paramFour){
return retVal2;
}

/
************************************************************
* SubFunctionThree()
*
* @param paramFive
* @param paramSix
* @return retVal3
*
*************************************************************/
function SubFunctionThree(var paramFive, var paramSix){
return retVal3;
}


}

Much Thanks,
rtstone

Michael Mathews

unread,
May 12, 2009, 5:37:57 AM5/12/09
to jsd...@googlegroups.com, RTS...@gmail.com
Inner functions are supported (and are used quite frequently in "web
centric" JavaScript), they are just considered "private" by default
and so require the -p option to appear in your output. What you are
trying to do is slightly different however, because you want inner
functions to appear as if they are actually public methods, that's
cool too but you'll need to use the -n option: it will cause JsDoc
Toolkit to ignore what it *thinks* you are trying to do from its
examination of your code (the "n" stands for nocode), and only
consider what you tell it in the doc comments. Using this option
however requires that you provide more information, such as the @name
of your symbol and whether the symbol is a @class or a @function.

see:
http://code.google.com/p/jsdoc-toolkit/wiki/CommandlineOptions
http://code.google.com/p/jsdoc-toolkit/wiki/TagName


/**
* @name FunctionCollection
* @class
* @author rtstone
*/
function FunctionCollection(){
var globalVarOne;

/**
* @name FunctionCollection#SubFunctionOne
* @function
* @param paramOne
* @param paramTwo
* @return retVal1
*/
function SubFunctionOne(var paramOne, var paramTwo){
return retVal1;
}

/**
* @name FunctionCollection#SubFunctionTwo
* @function
* @param paramThree
* @param paramFour
* @return retVal2
*/
function SubFunctionTwo(var paramThree, var paramFour){
return retVal2;
}

/**
* @name FunctionCollection#SubFunctionThree
* @function
* @param paramFive
* @param paramSix
* @return retVal3
*/
function SubFunctionThree(var paramFive, var paramSix){
return retVal3;
}
}


Regards,
Michael
Reply all
Reply to author
Forward
0 new messages