bitovi / documentjs

The sophisticated documentation engine
https://documentjs.com/
MIT License
598 stars 381 forks source link

Type expressions for variadic functions have malformed output #217

Open rjgotten opened 9 years ago

rjgotten commented 9 years ago

According to documentation for type expressions it should be possible to express a type annotation for a variadic function such as {function(string, ...[number])}.

A parameter of this form, with the straight brackets used to indicate optionality, is eventually output into documentation as a malformed {function(string, [...)} annotation. The closing bracket and parameter name are both missing.

There seems to be a bug in how the variadic notations are parsed when optional parameter brackets are tossed into the mix as a variadic function annotated as {function(string, ...number)} is correctly transformed and output as {function(string, number...)}

The variadic annotation {function(...*)} that is output as {function(*...)} should probably be changed to drop the asterisk though: {function(...)} has less noise and is, afaik, an accepted convention for functions that can take any amount of parameters of any mixed type.


Also, a nitpick: The documentation incorrectly uses the term 'variable parameters'. Parameters are always variable. It's the function that may be variadic. (see also: Variadic function - Wikipedia)