jsdoc-to-markdown
jsdoc-to-markdown copied to clipboard
Unable to specify NaN as a default value
Using jsdoc-to-markdown 4.0.1 on the following sample file (call it "example.js").
/**
* Example function.
*
* @param {number} arg1=-1.23 - An argument
* @param {number} arg2=Infinity - Another argument
* @param {number} arg3=NaN - Yet another argument
* @returns {undefined} nothing
*/
function example (arg1, arg2, arg3) {}
Running jsdoc-to-markdown example.js
produces this output:
| Param | Type | Default | Description | | --- | --- | --- | --- | | arg1 | <code>number</code> | <code>-1.23</code> | An argument | | arg2 | <code>number</code> | <code>Infinity</code> | Another argument | | arg3 | <code>number</code> | <code></code> | Yet another argument |
Note that the default value NaN
for the third argument does not appear in the output.
Interesting. Does this source code document as expected using jsdoc?
Yes, it does. At least with current jsdoc 3.5.5.
Hi, this is an issue with jsdoc which returns null
instead of NaN
in its JSON output. I'm assuming it works in their template because they interpret the combination of type name number
used with default value null
to actually mean default value NaN
. I asked on the jsdoc issue I raised, will get back to you.
This behavior also occurs when specifying null
or undefined
as a default value.
Adding to the last comment: if jsdoc returns null
, I expect jsdoc-to-markdown to output null
, not nothing. So I think there are two issues here:
- jsdoc outputs
null
forNaN
– to be fixed/clarified over on the jsdoc side - jsdoc-to-markdown outputs nothing for
null
orundefined
– to be fixed here