我正在研究使用谷歌应用程序脚本构建工具集.这个问题是,据我所知,只允许一个级别的组织.您可以创建一个名为Stopwatch的库,并调用方法Stopwatch.start()和Stopwatch.stop(),这非常酷.
我的想法虽然更像是Utils.Stopwatch().start()和Utils.Timer.start()等.我认为它在javascript中肯定是可能的,但为了不断破坏Apps Script自动完成功能,它需要以某种格式添加.下面是一个例子,它做错了(给出错误),但也许节省了一些时间.它基于这篇文章.
/**
* A stopwatch object.
* @return {Object} The stopwatch methods
*/
function Stopwatch()
{
var current;
/**
* Stop the stopwatch.
* @param {Time} time in miliseconds
*/
function timeInSeconds_(time)
{
return time/1000;
}
return
{
/**
* Start the stopwatch.
*/
start: function()
{
var time = new Date().getTime();
current = timeInSeconds_(time);
},
/**
* Stop the stopwatch.
* @return {decimal} time passed since calling
* start (in seconds)
*/
stop: function()
{ …Run Code Online (Sandbox Code Playgroud) 我知道问题1731已经提出请求在Google脚本编辑器中预览jsdoc.http://code.google.com/p/google-apps-script-issues/issues/detail?id=1731
在我们等待实现的同时,预测我正在添加到我发布的库中的jsdoc注释的最佳方法是什么,而不需要我创建新版本?
我正在尝试在 Google Script 中输入一堆 javascript,并且我已经尝试了以下操作:
/**
* Get (named) range given by name
*
* @param {String} name
* @return {Range}
*
*/
function getRange(name) {
return SpreadsheetApp.getActiveSpreadsheet().getRangeByName(name);
}
Run Code Online (Sandbox Code Playgroud)
它显示良好,并提供与内置 getRangeByName 相同的类型提示,但它实际上不起作用,即,当我输入类似 之类的内容时,自动完成脚本编辑器不会自动完成getRange("hello").get",就像它应该的那样。我应该使用名称间隔Range还是我做错了什么?