As we are starting to use JSDoc to document functions, to set a type/name/description to params... what about using that information to automatically naming the arguments? and even set default values!!
this would make argument[0] be optional, named "somebody" (as local var), and set its default value to "John Doe" if it's missing!
this could even be done like before compiling (like macros).
the above documentation would be translated into:
I could be very very very wrong but I think this is pretty easy to do... (and as the JSDoc is already interpreted by the editor... it could add the local variables to the autocomplete). even the param type real/string is there and could be used!!
Non-optional params would translate into:
just needed to add some "keywords" to represent defaults like undefined and noone.
What do you think!?!?
Code:
/// @description Function test
/// @param {string} [somebody=John Doe] - Somebody's name.
/// @param {real} [number=232] - Somebody's name.
this could even be done like before compiling (like macros).
the above documentation would be translated into:
Code:
var somebody = argument_count > 0 ? argument[0] : "John Doe";
var number = argument_count > 1 ? argument[1] : 232;
Non-optional params would translate into:
Code:
var non_optional = argument[0];
What do you think!?!?
Last edited: