首页 > 解决方案 > 评论谷歌表格自定义函数

问题描述

我有一个在 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 的评论 > 当用户使用该功能时,我需要的文本将出现在工作表中。

标签: google-apps-scriptgoogle-sheetsjsdoccustom-function

解决方案


来自 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) {
    // ...
};

https://jsdoc.app/tags-param.html


推荐阅读