Skip to content

Commit 2b9e2d6

Browse files
committed
Prettier: Support Param Type Formatting
1 parent c8e185d commit 2b9e2d6

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

packages/prettier-plugin-liquid/src/printer/print/liquid.ts

+15-6
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,21 @@ export function printLiquidDocParam(
513513
_args: LiquidPrinterArgs,
514514
): Doc {
515515
const node = path.getValue();
516-
return [
517-
node.name,
518-
' ',
519-
node.paramName.value,
520-
node.paramDescription.value ? ' ' + node.paramDescription.value : '',
521-
];
516+
const parts: Doc[] = ['@param'];
517+
518+
if (node.paramType.value) {
519+
parts.push(' ', `{${node.paramType.value}}`);
520+
}
521+
522+
if (node.paramName.value) {
523+
parts.push(' ', node.paramName.value);
524+
}
525+
526+
if (node.paramDescription.value) {
527+
parts.push(' ', node.paramDescription.value);
528+
}
529+
530+
return parts;
522531
}
523532

524533
function innerLeadingWhitespace(node: LiquidTag | LiquidBranch) {

packages/prettier-plugin-liquid/src/test/liquid-doc/fixed.liquid

+5
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ It should trim whitespace between nodes
1212
{% doc %}
1313
@param paramName param with description
1414
{% enddoc %}
15+
16+
It should format the param type
17+
{% doc %}
18+
@param {string} paramName param with description
19+
{% enddoc %}

packages/prettier-plugin-liquid/src/test/liquid-doc/index.liquid

+5
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ It should trim whitespace between nodes
1212
{% doc %}
1313
@param paramName param with description
1414
{% enddoc %}
15+
16+
It should format the param type
17+
{% doc %}
18+
@param { string } paramName param with description
19+
{% enddoc %}

0 commit comments

Comments
 (0)