Marco Demaio Marco Demaio - 6 months ago 31
Javascript Question

JSDoc adding real code in documentation

Do you know if there is a some sort of <code> tag in JSDoc?
I need to add pieces of code in my documentation like this:

/**
* This function does something see example below:
*
* var x = foo("test"); //it will show "test" message
*
* @param {string} str: string argumnet that will be shown in message
*/
function foo(str)
{
alert(str);
}


I need the code in the comments to be displaied by JSDoc as code (if not sintax highlighetd, at least like preformatted or something with grey background)

Thanks.

Answer

Use

<pre><code>

....

</code></pre>

This is whats used in many official docs, and will for instance receive syntax hightlighting with some tools