hosseinmd / prettier-plugin-jsdoc

A Prettier plugin to format JSDoc comments.
MIT License
232 stars 28 forks source link

Example tag formatting is lost in the second prettier run #103

Closed aminya closed 3 years ago

aminya commented 3 years ago

JsDoc plugin formatted my example to the following, but after the second run, it puts everything into a single line.

/**
 * Allows async function syntax in jasmine beforeEach, etc
 *
 * @example
 *
 *     beforeEach(
 *       waitAsync(async () => {
 *         await atom.packages.activatePackage("language-python");
 *       })
 *     );
 */
export function waitAsync(fn) {
  return (done) => {
    fn().then(done, function rejected(e) {
      fail(e);
      done();
    });
  };
}

After the second run:

/**
 * Allows async function syntax in jasmine beforeEach, etc
 *
 * @example BeforeEach( waitAsync(async () => { await
 * atom.packages.activatePackage("language-python"); }) );
 */
export function waitAsync(fn) {
  return (done) => {
    fn().then(done, function rejected(e) {
      fail(e);
      done();
    });
  };
}
hosseinmd commented 3 years ago

What's your prettier-plugin-jsdoc? Please update to last version I tested your case on last version, it works.

aminya commented 3 years ago

I am using the latest version. This is my configuration. Both jsdoc and tsdoc are enabled (noting that the above code was a JS file). https://github.com/atom-community/prettier-config-atomic/blob/master/prettier.config.js

hosseinmd commented 3 years ago

In tsdoc example is not code, that is a description with md format

/**
 * Allows async function syntax in jasmine beforeEach, etc
 *
 * @example a description
 * ```js
 *     beforeEach(
 *       waitAsync(async () => {
 *         await atom.packages.activatePackage("language-python");
 *       })
 *     );
 * ```
 */
export function waitAsync(fn) {
  return (done) => {
    fn().then(done, function rejected(e) {
      fail(e);
      done();
    });
  };
}