Polymorphic function documentation in Google Apps Script -


i want library function work in 2 ways, depending on whether second parameter provided.
example:

function sheet_to_dict(a, b) {   var array = (     b ? spreadsheetapp.openbyid(a).getsheetbyname(b) :   ).getdatarange().getvalues(); 

now how should document make like:

enter image description here

this article doesn't cover problem: http://googleappsdeveloper.blogspot.de/2012/05/introducing-versions-and-libraries-in.html

you've got limited subset of jsdoc tags work in apps-script, , 1 example there's no way duplicate results see in services documentation. here's list of reported issues support of jsdoc in apps-script.

the thing you'll able in apps-script provide detailed documentation optional parameters in comments. won't auto-completion @ all, unfortunately.

here's example based on how preview jsdoc comments in google doc scripts uses html tables simulate output of @param tags, , documents 2 variants of method. screenshot library documentation url, https://script.google.com/macros/library/d/<library-id>/<ver>.

enter image description here

/**  * incredible things, in number of amazing ways.  *  * <pre>  * jsdoctest( var1, var2 )  * </pre>  * description of first variant.  * <table><tbody>  * <tr><td style="width: 20%"><b>parameter</b></td><td style="width: 15%"><b>type</b></td><td style="width: 65%"><b>description</b></td></tr>  * <tr><td> var1 </td><td> number </td><td> description of number parameter </td></tr>  * <tr><td> var2 </td><td> string </td><td> description of string parameter </td></tr>  * </tbody></table>  *  * <pre>  * jsdoctest( var3, var4 )  * </pre>  * description of second variant.  * <table><tbody>  * <tr><td style="width: 20%"><b>parameter</b></td><td style="width: 15%"><b>type</b></td><td style="width: 65%"><b>description</b></td></tr>  * <tr><td> var3 </td><td> object </td><td> description of object parameter </td></tr>  * <tr><td> var4 </td><td> string [] </td><td> description of string array </td></tr>  * </tbody></table>  */ function jsdoctest () {   // handle parameters via arguments[] } 

Comments