typedoc2md / typedoc-plugin-markdown

A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.
https://typedoc-plugin-markdown.org
MIT License
702 stars 176 forks source link

Option to change prettier options #421

Closed adambergman closed 1 year ago

adambergman commented 1 year ago

First off, thank you for the great plugin!

When using the next build, I noticed that code in our @example tags is being converted to use double quotes due to prettier. Our style guide and ESLint rules enforce single quotes – it feels bad to copy code directly from the API doc and see lint errors. Since prettier is opinionated, it would be great if there was an option to specify any of its many configuration options.

We do not use prettier on the project, but I did try creating a .prettierrc file and setting the 'singleQuotes' option there, which didn't seem to help. I ended up modifying the render function in theme.ts to include the 'singleQuotes' option directly.

Example: The following block comment:

/**
 * @example
 * ```ts
 * console.log('this is an example');
 * ```
 */

Generates markdown like:

console.log("this is an example");
tgreyuk commented 1 year ago

Thanks for this. The plugin will now discover a local prettier config file and apply the options from it. I can't think of a scenario where this would not be desired. Let me know if it works for you. typedoc-plugin-markdown@4.0.0-next.9

adambergman commented 1 year ago

Agreed, @tgreyuk! Thanks again for all of your work on this plugin.

adambergman commented 1 year ago

Just had a chance to try this out and everything is working perfectly using a .prettierrc file. 🍻