I am new to using JSDocs and couldn't find an answer to this question.
Suppose I wanted to write this simple function:
function hasQ(array, item) {return array.includes(item);}
which with JSDoc's I would mark-up like:
/**
* Another way to call array.includes(item);
* @param {Array} array
* @param {*} item to test if contained in array
* @returns
*/
Is there a way for me to markup the word array
in the second @param
statement such that it references the first @param
?
This is just a toy example, but I hope it makes the concept clear.
There is no way to do that. Source: https://github.com/jsdoc/jsdoc/issues/1145
Regarding @param
as far as I know, there's no way to cross-reference parameters. As suggested here you can use plain English.
As a partial solution, you can use markdown's backticks to highlight the param
name (as described here), for example:
/**
* @param {*} item to test if contained in `array`
*/
There's a concept of inline @link
to external
resources in JSDoc
that I guess would be useful here. You can make it clear in your description that for example your talking about the function includes
of Array
:
/**
* Another way to call [Array's includes function]{@link external:Array#includes}
* @param {Array} array
* @param {*} item to test if contained in array
* @returns
*/
function hasQ(array, item) {
return array.includes(item);
}
Or if you prefer a link without a text
, just remove the part inside []
in the first line:
/**
* Another way to call {@link external:Array#includes}
*/
In case you're interested to read more:
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