我正在相关的脚本编辑器中创建一个包含大量代码的大型Google电子表格。
当我在LINE 1上编写句点时(参见下面的代码),我获得了自动完成帮助,但是在LINE 2上写句点时没有。当在LINE 2上编写句点时,是否可以使用JSDoc语法获得自动完成帮助?
我还没有成功将其用于普通的javascript对象或Spreadsheet相关对象。我对两者都感兴趣。
/** Failed attempt on getting autocomplete help using JSDoc on a google Range object
* @returns {Range}
*/
function getMyRange() {
return SpreadsheetApp.getActiveSpreadsheet().getRangeByName('myRange');
};
/** Failed attempt on getting autocomplete help using JSDoc on standard JS-object
* @returns {Array}
*/
function getMyArray() {
return SpreadsheetApp.getActiveSpreadsheet().getRangeByName('myRange');
};
function test() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
// Please think of the code below as 4 separate examples, nothing
// of the below is meant to compile as it is. It is just 4 separate
// demonstrations of when I'd like to get autocompletion help and notes
// on when I do and don't
ss.getRangeByName('myRange'). // **** LINE 1 **** I get autocomplete
getMyRange(). // **** LINE 2 **** No autocomplete
[]. // **** LINE 3 **** I get autocomplete
getMyArray(). // **** LINE 4 **** No autocomplete...
};
答案 0 :(得分:6)
使用JSDoc自动完成非GAS功能适用于作为库而不是内联到同一脚本的代码。在这方面,它是一个有限的IDE。
https://developers.google.com/apps-script/guide_libraries#guidelines