相关疑难解决方法(0)

Google Sheets 自定义函数支持多少 JsDoc?

Google 暗示支持 JsDoc:

如果自定义函数的脚本包含 JsDoc @customfunction 标记,则自定义函数将出现在此列表中,如下面的 DOUBLE() 示例所示。

https://developers.google.com/apps-script/guides/sheets/functions

但似乎并没有完全支持 JsDoc,而且我找不到显示支持和不支持的文档。

我特别寻找一种方法来记录自定义函数的参数是可选的。像这样,对于 value2:

在此输入图像描述

图片提供:https://yagisanatode.com/2018/08/24/google-apps-script-how-to-make-a-custom-function-to-use-in-google-sheets/

使用 JsDoc,您应该能够根据此源执行以下操作: https ://jsdoc.app/tags-param.html#optical-parameters-and-default-values

/**
 * @param {number} [value2] - Additional numbers or ranges to add to value1.
 */
Run Code Online (Sandbox Code Playgroud)

并且,使用默认值:

/**
 * @param {number} [value2=100] - Additional numbers or ranges to add to value1.
 */
Run Code Online (Sandbox Code Playgroud)

但我在谷歌表格中对此进行了测试,但这些都不起作用。甚至没有建议的 Google Closure Compiler 语法(如果可以的话):

/**
 * @param {number=} value2 - Additional numbers or ranges to add to value1.
 */
Run Code Online (Sandbox Code Playgroud)

目前我已经采取了不太优雅的方法:

/**
 * @param {number} value2 - …
Run Code Online (Sandbox Code Playgroud)

google-sheets jsdoc google-apps-script custom-function

7
推荐指数
1
解决办法
2589
查看次数