Deon Tan
Deon Tan

Reputation: 21

How do I edit the description that shows when you use a function?

When you use functions from public repositories, they show the variable name followed by the variable type as shown below.

Repo's Function Description

How do I make my own functions display as such because it currently displays it as variable name followed by variable type 'any', as shown below.

My Function Description

Upvotes: 1

Views: 830

Answers (2)

John Haddadian
John Haddadian

Reputation: 51

As above, I think the editor is using the @params found in the comments above each function to define parameters of a function providing you use the Javascript documentation standards you can find here:

https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/javascript/

/**
 * Summary. (use period)
 *
 * Description. (use period)
 *
 * @since      x.x.x
 * @deprecated x.x.x Use new_function_name() instead.
 * @access     private
 *
 * @class
 * @augments parent
 * @mixes    mixin
 * 
 * @alias    realName
 * @memberof namespace
 *
 * @see  Function/class relied on
 * @link URL
 * @global
 *
 * @fires   eventName
 * @fires   className#eventName
 * @listens event:eventName
 * @listens className~event:eventName
 *
 * @param {type}   var           Description.
 * @param {type}   [var]         Description of optional variable.
 * @param {type}   [var=default] Description of optional variable with default variable.
 * @param {Object} objectVar     Description.
 * @param {type}   objectVar.key Description of a key in the objectVar parameter.
 * 
 * @return {type} Description.
 */

Upvotes: 4

froghramar
froghramar

Reputation: 315

Here is an example of what you can do -

/**
* Add two numbers together, then returns the result
*
* @function addStuff
* @param {number} x - An integer.
* @param {number} y - An integer.
* @return {number} - An integer
*/
function addStuff(x, y) {
  return x + y;
}

Upvotes: 2

Related Questions