Skip to content

Commit

Permalink
Prettier: Support Param Type Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmengo committed Dec 11, 2024
1 parent fc16617 commit 60f93b8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
21 changes: 15 additions & 6 deletions packages/prettier-plugin-liquid/src/printer/print/liquid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,21 @@ export function printLiquidDocParam(
_args: LiquidPrinterArgs,
): Doc {
const node = path.getValue();
return [
node.name,
' ',
node.paramName.value,
node.paramDescription.value ? ' ' + node.paramDescription.value : '',
];
const parts: Doc[] = ['@param'];

if (node.paramType.value) {
parts.push(' ', `{${node.paramType.value}}`);
}

if (node.paramName.value) {
parts.push(' ', node.paramName.value);
}

if (node.paramDescription.value) {
parts.push(' ', node.paramDescription.value);
}

return parts;
}

function innerLeadingWhitespace(node: LiquidTag | LiquidBranch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ It should trim whitespace between nodes
{% doc %}
@param paramName param with description
{% enddoc %}

It should format the param type
{% doc %}
@param {string} paramName param with description
{% enddoc %}
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ It should trim whitespace between nodes
{% doc %}
@param paramName param with description
{% enddoc %}

It should format the param type
{% doc %}
@param { string } paramName param with description
{% enddoc %}

0 comments on commit 60f93b8

Please sign in to comment.