Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Apps Script Auto Generated Library Documentation

I am currently developing a Library for Google Apps Script that basically treats a spreadsheet as a database object.

Currently, the library has a two identical functions like

/**
* Opens and creates a query object for a spreadsheet with the given url.
*
* @param {String} the url of the spreadsheet
* @return {SpreadsheetQuery_} a spreadsheet query object for the given spreadsheet
*/
function openByUrl(url) {
    return new SpreadsheetQuery_(SpreadsheetApp.openByUrl(url));
}

now, for the two public functions, the documentation generated only shows the return type and not the parameter nor the instructions attached. I am assuming this is a google issue and not really bothered.

But my main question is this, as the functions are instantiating an object from the private function, how can I get the auto documentation to show methods that exist on that object. All the functionality will be provided by the object and it will be great if GAS could show the methods on it.

NOTE


The methods are all placed on the prototype of the function. eg.

SpreadsheetQuery_.prototype.from = function (sheet) {
    if (_.isNumeric(sheet)) {
        ....
}

Thanks.

like image 486
frostymarvelous Avatar asked Feb 17 '23 08:02

frostymarvelous


2 Answers

The jsdoc variant suported for libraries in Google Apps Script does not support documentation at the level you are looking for, only first-level functions. There is a relevant open bug report on this, but no response from Google.

You can still write your jsdoc tags, and generate your documentation outside of the Google infrastructure. Take a look at How to preview jsdoc comments in google doc scripts for some pointers on how to preview your jsdoc comments. You could take the output of jsdoc3 and publish it on a site to provide your docs to your community.

Other relevant / possible duplicate posts:

  • Creating a namespace-like organization in a google apps script library
  • Writing jsdoc documentation on methods inside a class
like image 63
Mogsdad Avatar answered Mar 12 '23 13:03

Mogsdad


If you are working with TypeScript, we've built a package that aims help on this:

https://github.com/maelcaldas/clasp-types

You can use it to generate autocomplete for our Object Oriented libraries and Client-side API written on Typescript.

like image 29
Mael Avatar answered Mar 12 '23 13:03

Mael