I'm trying to document my program with the JSDoc syntax for myself and the people that will have to look at my code. I'm also trying to improve my skills.
For a parameter of the jQuery type, I'm a little puzzled. I know that's an object, but it's fairly common in my program, so I think I should first declare a typedef for the jQuery type, then use it as my parameter type. So I ask, would it be the correct way to do it?
/** * DOM object referenced by jQuery * @typedef {jQuery} $jQueryDomObject */ /** * SOAP call that does ... * * @param {string} code Some desc ... * @param {callback} fnctVa Some desc ... * @param {$jQueryDomObject} $attrib Input field that ... */ myfunction = function (code, fnctVa, $attrib) {};
I also found on SO this question, somewhat similar:
How can I get JSDoc to mark my param as a jQuery object?
The @param tag provides the name, type, and description of a function parameter. The @param tag requires you to specify the name of the parameter you are documenting.
$ sign is just a valid javascript identifier which is used as an alias for jQuery. Prototype, jQuery, and most javascript libraries use the $ as the primary base object (or function). Most of them also have a way to relinquish the $ so that it can be used with another library that uses it.
For a parameter that is a jQuery object, I often just do:
@param {jQuery} foo
And do not further define what jQuery is. It is known well enough. However, if you want, you can do this with jsdoc 3:
/** * jQuery object * @external jQuery * @see {@link http://api.jquery.com/jQuery/} */ /** * SOAP call that does ... * * @param {string} code Some desc ... * @param {callback} fnctVa Some desc ... * @param {external:jQuery} $attrib Input field that ... */ var myfunction = function (code, fnctVa, $attrib) {};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With