Open mech-tools opened 1 week ago
Hey @mech-tools 👋
I'll try and take a look today and see if there's an easy fix, but I won't promise you anything, the jsdocExperimentalFormatCommentsWithoutTags
is not something I plan to get out of experimental; it was a request that was easy enough to add, but not a use case I plan to support nor expand on it.
Hi @homer0
Thanks! Here is my workaround for the time being:
import { get, override } from "@homer0/prettier-plugin-jsdoc/src/fns/app.js";
import { loadFns } from "@homer0/prettier-plugin-jsdoc/src/loader.js";
import { getPlugin } from "@homer0/prettier-plugin-jsdoc/src/fns/getPlugin.js";
import { getRenderer } from "@homer0/prettier-plugin-jsdoc/src/fns/getParsers.js";
import { render } from "@homer0/prettier-plugin-jsdoc/src/fns/render.js";
loadFns();
const customGetRenderer = (options) => {
const renderer = get(render)(options);
return (column, block) => {
const padding = " ".repeat(column + 1);
const prefix = `${padding}* `;
const lines = renderer(column, block);
if (
lines.length === 1 &&
block.tags.length > 0 && //<------ Added this line
options.jsdocUseInlineCommentForASingleTagBlock
) {
return `* ${lines[0]} `;
}
const useLines = lines.map((line) => `${prefix}${line}`).join("\n");
return `*\n${useLines}\n${padding}`;
};
};
override(getRenderer, customGetRenderer);
export default get(getPlugin)();
Hi,
When both
jsdocUseInlineCommentForASingleTagBlock
andjsdocExperimentalFormatCommentsWithoutTags
are true Comments without tags are collapsed to a single line if able.That's ok and more readable for quick type def like
/** @type {string} */
But for a simple description, we get something like this:
This feels (to me) much more readable:
Another example with class:
Do you think this is smt that can be changed or added as a setting?