3

I am creating a library for use in google apps script and am having some trouble with the JSDoc Style Documentation so that the IDE autocomplete will work for the end user.

All of the methods entered as User.prototype.METHODNAME should show up in the autocomplete for this library. Currently only the .getEmail() method appears in the autocomplete for a User object. The .getName() .getPassword() .hasPaid() etc. methods should also appear but do not. What's particularly strange is that when I swap the method names (and only the method names) of .getEmail() and .getId() the IDE still shows .getEmail() as the only option, and runs the original .getId() method.

Here is the library key to a mock library without sensitive information for testing purposes: M1TqnX8hyIa1H8ikAojXirsqqTKXVxxXC

/** 
*@param {Number} id
*@param {String} email
*@param {String} name
*@param {String} password
*@return {User} User
*/
function User(id, email, name, password){
  var ss = SpreadsheetApp.openById("INSERT SPREADSHEET HERE").getSheetByName("Users");
  var data = ss.getRange(1, 1, ss.getLastRow(), ss.getLastColumn()).getValues();
  for (var i = 1; i < data.length; i++){
    if (data[i][0] == id){
      this.id = id;
      this.email = data[i][1];
      this.name = data[i][2];
      this.password = data[i][3];
      this.picks = data[i][4];
      this.paid = data[i][5];   
    }
  }
  return this;
}
/**
* @param {Number} id ID of the user
* @return {User} User
*/
function getUserById(id){
  var user = new User(id, null, null, null);
  return user;
}
/**
* @param {String} email email of the user
* @param {String} name name of the user
* @return {User} User
*/
function getUserByEmailAndName(email, name){
  return new User(null, email, name, null);
}
/** 
*@return {Boolean} isCorrect
*/
User.prototype.checkPassword = function (password){ return this.password == Utilities.base64Encode(password); }

User.prototype.getEmail = function (){return this.email;}
/** 
*@return {Number} id 
*/
User.prototype.getId = function (){return this.id;}
/** 
*@return {String} name 
*/
User.prototype.getName = function (){return this.name;}
/** 
*@return {String} encodedPassword 
*/
User.prototype.getPassword = function (){return this.password;}
/** 
*@return {String} jsonPicks 
*/
User.prototype.getPicksAsString = function (){return this.picks;}
/** 
*@return {JSON} jsonPicks 
*/
User.prototype.getPicksAsJson = function (){return Utilities.jsonParse(this.picks);}
/** 
*@return {Boolean} hasPaid
*/
User.prototype.hasPaid = function (){return this.paid;}
ECWyne
  • 423
  • 3
  • 8
  • Tried to use your library, but it seems the permissions aren't set for public use: "You do not have access to library BowlApp, used by your script, or it has been deleted." – Mogsdad Jul 03 '13 at 13:16
  • This question is a duplicate, see [this](http://stackoverflow.com/questions/15158745/google-apps-script-auto-generated-library-documentation) and [this](http://stackoverflow.com/questions/14893927/writing-jsdoc-documentation-on-methods-inside-a-class). – Mogsdad Jul 03 '13 at 13:21

2 Answers2

0

If you are working with TypeScript - or intend to migrate to - 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.

Mael
  • 427
  • 3
  • 11
-1

I think the autocomplete only works for the functions that were in the first Library version. So I found that creating a new first library kinda solve that problem (but you now have to save your versions yourself).

Try this (everything is in French here, but I'll try to translate) :

1) Copy your Project to a new Project (File-Create a Copy) 2) Create a new Library in this new Project (File-Manage Versions) 3) Get the new project library Key (File-Project Properties) 4) Link this new Library to your Projects with the Key (Ressources-Libraries)

Sheb
  • 1