webdoc-labs / webdoc

Documentation generator for the web
https://www.webdoclabs.com
Other
79 stars 9 forks source link

@example should trim extra empty first line and leading spaces #193

Closed SuperSodaSea closed 2 years ago

SuperSodaSea commented 2 years ago

It seems that in every @example, there is an extra empty line at the begining and a extra space before every line. For example:

/**
 * @example
 * for(let i = 1; i <= 5; ++i)
 *     console.log(`Hello, world! ${i}`);
 */

Expected:

for(let i = 1; i <= 5; ++i)
    console.log(`Hello, world! ${i}`);

Output:


 for(let i = 1; i <= 5; ++i)
     console.log(`Hello, world! ${i}`);

Another example: https://pixijs.download/v6.x/docs/PIXI.Sprite.html#anchor

image

I think webdoc should:

  1. Trim the first empty line
  2. Trim one space at the begining of each line, or maybe trim spaces according to the indent of @example or the left most indent in example code