I am trying to document my code using JSDoc-toolkit. My code starts by being wrapped with a self-executing anonymous function. How in the world do I document this? I've spent nearly all day on this. JS Docs will not recognize anything inside of the anonymous function closure due to it not knowing what to do with it. It breaks and none of my comments come through.
My code looks something like this.
/**
* @fileoverview BLA BLA BLA
*/
/**
* This is where I don't know what to put.
*/
(function () {
"use strict";
/** or here */
var stlib = function (param, param, param) {
/** or here */
var share = {
/** or here */
config: {
button: DOM Element,
property: blablabla
},
init: function () { ...some init code here}
};
share.init();
};
widgets.add("share", stlib);
}());
Thank you!
You can't document nested functions directly. But you can do something like this:
Here I'm setting
checkString
as private and inner to be descriptive (since nested functions can't be described), And then I pass in-p
to document private functions. Finally, I add a link to the parent function for reference.I think
jsdoc
is unnecessarily finicky and needs to be replaced with something better. It's a port ofjavadoc
, so it has a lot of things that are relevant to Java but not JS, and vice versa. There are very common JS idioms, like closures or nested functions, that are hard or impossible to document.I always check my namepaths and debug using the
--explain
flag.You can use @namespace with @name and @lends like this: