如何在Google Apps jsdoc说明中强制换行

mas*_*huu 10 google-docs google-sheets jsdoc google-apps-script

我无法弄清楚Google Apps脚本中如何正确显示这一点.我需要它在jsdoc输出中显示新行(例如,当函数工具提示窗口出现在Spreadheet函数中时.)我尝试过html,
但它只是呈现为文本而不是换行符.

例如:

/**
 * Converts the prefixed value to the specified base.
 * Requires one of the following prefixes: 
 *    '0b' Base 2:   binary 
 *    '0q' Base 4:   quaternary 
 *    '0o' Base 8:   octal
 *    '0x' Base 16:  hexadecimal
 *
 * @param {string} Value The prefixed value to convert.
 * @param {number} To The base to convert to.
 * @return The converted base.
 * @customfunction
 */
function BASEP(Value, To) {
Run Code Online (Sandbox Code Playgroud)

这只是呈现一个文本blob:

Summary:
  Converts the prefixed value to the specified base. Requires
  one of the following prefixes: 0b Base 2: binary 0q Base 4:
  quaternary 0o Base 8:  octal 0x Base 16:  hexadecimal
Run Code Online (Sandbox Code Playgroud)

Iva*_*lev 17

<pre>标签在 VSCode 中对我不起作用,但@example确实有效;

/**
 * Fn description
 * @example
 * fn(1);
 * fn(3);
 * fn(10000000);
 **/
function fn(a: number): void {
   //...
}
Run Code Online (Sandbox Code Playgroud)


Mog*_*dad 14

以下是一些控制Google Apps脚本中jsdoc评论格式的方法:

<pre>

/**
 * Converts the prefixed value to the specified base.
 * Requires one of the following prefixes: 
 * <pre>
 *    '0b' Base 2:   binary 
 *    '0q' Base 4:   quaternary 
 *    '0o' Base 8:   octal
 *    '0x' Base 16:  hexadecimal
 * </pre>
 *
 * @param {string} Value The prefixed value to convert.
 * @param {number} To The base to convert to.
 * @return The converted base.
 * @customfunction
 */
function BASEP(Value, To) { }
Run Code Online (Sandbox Code Playgroud)

<p> 段落

/**
 * Converts the prefixed value to the specified base.
 * Requires one of the following prefixes: 
 * <p>'0b' Base 2:   binary </p>
 * <p>'0q' Base 4:   quaternary  </p>
 * <p>'0o' Base 8:   octal </p>
 * <p>'0x' Base 16:  hexadecimal </p>
 *
 * @param {string} Value The prefixed value to convert.
 * @param {number} To The base to convert to.
 * @return The converted base.
 * @customfunction
 */
function BASEP2(Value, To) { }
Run Code Online (Sandbox Code Playgroud)

名单

/**
 * Converts the prefixed value to the specified base.
 * Requires one of the following prefixes: 
 * <ul style="list-style: none;">
 *  <li> '0b' Base 2:   binary 
 *  <li> '0q' Base 4:   quaternary 
 *  <li> '0o' Base 8:   octal
 *  <li> '0x' Base 16:  hexadecimal
 * </ul>
 *
 * @param {string} Value The prefixed value to convert.
 * @param {number} To The base to convert to.
 * @return The converted base.
 * @customfunction
 */
function BASEP3(Value, To) { }
Run Code Online (Sandbox Code Playgroud)

/**
 * Converts the prefixed value to the specified base.
 * Requires one of the following prefixes: 
 * <table style="width:30%;">
 *  <tr><td>'0b'</td><td>Base 2:</td><td>binary</td></tr>
 *  <tr><td>'0q'</td><td>Base 4:</td><td>quaternary</td></tr>
 *  <tr><td>'0o'</td><td>Base 8:</td><td>octal</td></tr>
 *  <tr><td>'0x'</td><td>Base 16:</td><td>hexadecimal</td></tr>
 * </table>
 *
 * @param {string} Value The prefixed value to convert.
 * @param {number} To The base to convert to.
 * @return The converted base.
 * @customfunction
 */
function BASEP4(Value, To) { }
Run Code Online (Sandbox Code Playgroud)

  • 由于某种原因,这些都不适合我。他们不再支持HTML吗? (2认同)

Sal*_*tha 13

这种方法对我有用。在markdown(或在 StackOverflow)中,您需要有两个换行符(即额外的一个)来开始新的行(或段落)。同样的方法适用于JSDoc

/**
 * Converts the prefixed value to the specified base.
 * 
 * Requires one of the following prefixes:
 * 
 *    '0b' Base 2:   binary<br> 
 *    '0q' Base 4:   quaternary
 *    '0o' Base 8:   octal<
 *    '0x' Base 16:  hexadecimal
 * 
 */
async function test() {
  return;
}
Run Code Online (Sandbox Code Playgroud)

证明:

原案

原来的

附加行:

新的

ps

  • 在最新的 vscode 上在 Typescript + tslint + prettier 上测试(idk 版本,全部更新)。
  • 这是 Loopback 4 项目


小智 10

我在这里使用谷歌应用程序脚本。我发现对线路制动的描述的方法是:

/**
* Fn description
* 
* @param number {number} chose one of following:
* * fn(1);
* * fn(3);
* * fn(10000000);
**/
function fn(number) {
var mult = 4  
var result = mult*number
return result
}
Run Code Online (Sandbox Code Playgroud)

这就是它的显示方式


Bin*_*olo 7

我不确定您的问题的Google Apps部分,但JSDoc3将允许一些HTML描述,因此获得所需输出的一种方法是使用一些break标记的自由应用,如下所示:

/**
 * Converts the prefixed value to the specified base.<br>
 * Requires one of the following prefixes:<br> 
 *    '0b' Base 2:   binary<br> 
 *    '0q' Base 4:   quaternary<br> 
 *    '0o' Base 8:   octal<br>
 *    '0x' Base 16:  hexadecimal
 *
Run Code Online (Sandbox Code Playgroud)

那应该可以得到你想要的输出.我不确定JSDoc允许的HTML的范围,但我已经使用了p,br,em等没有任何问题.