google-apps-script - 评论谷歌表格自定义函数
问题描述
我有一个在 Google 表格中工作的自定义函数 - 但是,该函数有许多可选参数 - 在帮助中,我想拆分任何可选参数的描述,以便它们出现在多行上 - 可能吗?
此功能供同事使用 - 可选参数需要清晰的描述 - 将输入期间出现在工作表上的支持注释拆分为多行非常有帮助。
这是我今天拥有的自定义函数文本。
/**
* Creates a section of random text based on parameters entered.
*
* @param {number} len The total number paragraphs to return.
* @param {number} size Average size of paragraphs (0 - Short > 3 - v.Long).
* @param {string} optional TEXT I WOULD LIKE TO RETURN OVER MULTIPLE LINES:
* LINE 1
* LINE 2
* LINE 3
* @return an array of random letters
* @customfunction
*/
function HelpMePlease(len, size, optional) {
注意:我不想在这里评论代码 > 这是对 CustomFunction 的评论 > 当用户使用该功能时,我需要的文本将出现在工作表中。
解决方案
来自 js 文档:
带有属性的参数 如果期望参数具有特定属性,您可以通过提供额外的@param 标记来记录该属性。例如,如果期望员工参数具有名称和部门属性,则可以按如下方式记录它:
/**
* Assign the project to an employee.
* @param {Object} employee - The employee who is responsible for the project.
* @param {string} employee.name - The name of the employee.
* @param {string} employee.department - The employee's department.
*/
Project.prototype.assign = function(employee) {
// ...
};
推荐阅读
- java - 如何在构造函数中传递数组元素?
- tcl - 如何将鼠标移动到所有比例小部件?
- python - Python设置字符串的差异
- python - 如何访问 pytest 中的整体运行时?
- lua - 如何使用这个 LUA 表?
- android - 只要应用程序不可见,就暂停 CountDownTimer
- kubernetes - Getting "CrashLoopBackOff" as status of deployed pod
- php - 生成 500 万个唯一代码
- arrays - 我如何在猫鼬中查询以获得“答案”数组,其中“答案”数组中的“目标”是“意识”
- powershell - Start-Service cmdlet:在失败的情况下获取基础错误