syavorsky/comment-parser

feat: { spacing: 'dedent' }

Opened this issue · 1 comments

Let's give users a middle ground between 'compact' and 'preserve':

/**
 * @fires {CustomEvent<{ component: PfeClipboard }>} copied
 *        Fires when the current url is successfully copied the user's system clipboard.
 *
 *        ```js
 *        detail: {
 *          url: string
 *        }
 *        ```
 *
 */
console.log(parse(comment, { spacing: 'dedent' }.tags[0].description)
Fires when the current url is successfully copied the user's system clipboard.

```js
detail: {
  url: string
}
```

this shouldn't be hard to implement, it's basically:

  1. get the value if spacing was 'preserve'
  2. run dedent from 'dedent' npm package on the result

If the maintainers wish, I'm happy to make a PR

@bennypowers that is definitely a reasonable suggestion. There is an alternative, more flexible approach though. The spacing option was intentionally kept limited to avoid complexity. But all the variation one may need can be done as in this example. PR for the dedent transform would be very much welcome