@function constructor
Specifies the comment block is for a function. To specify function parameters, use @param.
@function [NAME] [TITLE]
/**
* @module {{}} lib.component Component
*/
/**
* @function lib.Component.prototype.update update
* @parent lib.Component
*/
C.p.update = function(){ /* ... */ }
// resulting docObject
{
"type": "function",
"name": "lib.Component.prototype.update",
"params": [],
"parent": "lib.Component",
"description": "\n",
"title": "update",
"pathToRoot": ".."
}
Parameters
- NAME
{String}
:The name of the function. It should be supplied if it cannot be determined from the code block following the comment.
- TITLE
{String}
:The title to be used for display purposes.
Code Matching
The @function
type can be inferred from code like the following:
/**
* The foo function exists
*/
foo: function(){}
/**
* The bar function exists
*/
bar = function(buz, baz){
return 'a string';
}
The comment block above foo
will automatically be associated with the
function foo
. Essentially, as if it had been explicitly written as:
/**
* @function lib.foo foo
* @description The foo function exists
*/
foo: function(){}
The same is true for the comment block above bar
, which translates to:
/**
* @function lib.bar bar
* @param {*} buz
* @param {*} baz
* @return {String}
* @description The bar function exists
*/
bar = function(buz, baz){
return 'a string';
}
Furthermore, the code matching can handle prototypes and methods like:
/**
* @module {function} foo-bar
*/
Foo = function(){};
Object.assign(Foo.prototype, {
bar: function(arg1){}
});
module.exports = Foo;
Which translates to:
/**
* @module {function} foo-bar
*/
Foo = function(){};
/**
* @prototype
*/
Object.assign(Foo.prototype, {
/**
* The bar function exists
*/
bar: function(arg1){}
});
module.exports = Foo;