質問

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?

役に立ちましたか?

解決

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) {};

他のヒント

I also saw on github/js3doc:

@param {jQuery object} obj The jQuery object you're looking for.

or github/js3doc

@param {module:jquery} jquery Some desc...
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top