Подтвердить что ты не робот

Как заставить новые строки в описаниях jsdoc в Google Apps

Я не могу понять, как в Google Apps Script отобразить это правильно. Мне нужно, чтобы он отображал новые строки в выводе jsdoc (например, когда окно всплывающей подсказки функции появляется в функциях электронной таблицы). Я пробовал 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) {

Это просто отображает текстовое 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
4b9b3361

Ответ 1

Вот несколько способов управления форматом ваших комментариев jsdoc в Google Apps Script:

<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) { }

<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) { }

Список

/**
 * 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) { }

Таблица

/**
 * 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) { }

Ответ 2

Я не уверен в части Google Apps вашего вопроса, но JSDoc3 позволит некоторым HTML описать, поэтому одним из способов получения нужного вам результата будет использование либерального приложения некоторых тегов разрыва, например:

/**
 * 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
 *

Это даст вам нужный вам результат. Я не уверен, насколько HTML, который позволяет JSDoc, но я использовал p, br, em и т.д. Без каких-либо проблем.

Ответ 3

Тег <pre> не работал для меня в VSCode, но @example работал;

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