31

I can't figure out how in a Google Apps Script to display this correctly. I need it to display new lines in the jsdoc output(e.g. when the function tooltip window comes up in a Spreadheet functions.) I have tried html like
however it is just rendered as text and not a line break.

For example:

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

This just renders a text blob like:

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
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
masshuu
  • 471
  • 1
  • 4
  • 6

5 Answers5

29

This method worked for me. In markdown (or in StackOverflow), you need to have two line breaks (ie an additional one) to start new line (or paragraph). same method worked for 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;
}

proof:

original case

original

with additional line:

new

ps

  • Tested on Typescript + tslint + prettier on vscode latest (idk the version, all are updated).
  • This is Loopback 4 project
Salitha
  • 1,022
  • 1
  • 12
  • 32
  • It seems that the items (`0b ... , 0q ...`) need to have additional line breaks too, otherwise they will be displayed in single line not as your screenshot! – S.Serpooshan Feb 14 '23 at 06:13
26

Here are a few ways to control the format of your jsdoc comments in 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> paragraphs

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

List

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

Table

/**
 * 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) { }
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
  • 4
    for some reason none of this worked for me. Don't they support HTML anymore? – Max Makhrov Dec 01 '16 at 09:30
  • @Mogsdad https://stackoverflow.com/questions/61711660/what-amount-of-jsdoc-is-supported-in-google-sheets-custom-functions – Magne May 10 '20 at 16:34
16

The <pre> tag did not work for me in VSCode, but @example did;

/**
 * Fn description
 * @example
 * fn(1);
 * fn(3);
 * fn(10000000);
 **/
function fn(a: number): void {
   //...
}
Ivan Koshelev
  • 3,830
  • 2
  • 30
  • 50
10

I'm trilled this is my first time helping out on Stack !!!

I'm using Google App Script here. and the way I found do to that's description with line brake is:

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

And This is How it shows UP

Hope it's helpful Tnks

Ian Thomaz
  • 111
  • 1
  • 2
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30962083) – taylor.2317 Feb 07 '22 at 13:34
  • This worked for me. It created a bulleted list. None of the other solutions provided here seem to work in Apps Script. – Trashman Nov 21 '22 at 22:14
8

I'm not sure about the Google Apps part of your question, but JSDoc3 will allow some HTML in descriptions, so one way of getting the output you want would be with the liberal application of some break tags, like so:

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

That should get you the output you want. I'm not sure as to the extent of the HTML that JSDoc allows through, but I've used p, br, em etc without any problems.

BinarySolo
  • 606
  • 7
  • 19
  • 1
    I don't think at this time its possible. I tried a bunch of other things and given the 2 week lapse and a lack of answer. As far as I can tell they escape all html and newlines/spaces. It makes sense as they don't want people to stick arbitrary HTML into it, even though the allowed tags defined by JSDoc3 are limited. – masshuu Feb 14 '15 at 05:38