Skip to content

Commit 40ad9c4

Browse files
committed
Add optional param delimiters to liquid doc printer
1 parent 720b222 commit 40ad9c4

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,10 @@ export function printLiquidDocParam(
519519
parts.push(' ', `{${node.paramType.value}}`);
520520
}
521521

522-
if (node.paramName.value) {
522+
if (node.required) {
523523
parts.push(' ', node.paramName.value);
524+
} else {
525+
parts.push(' ', `[${node.paramName.value}]`);
524526
}
525527

526528
if (node.paramDescription?.value) {

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

+11
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,14 @@ It should normalize the param description
2727
{% doc %}
2828
@param paramName - param with description
2929
{% enddoc %}
30+
31+
It should strip whitespace between optional param delimiters
32+
{% doc %}
33+
@param [paramName] - param with description
34+
{% enddoc %}
35+
36+
It should remove incomplete optional param delimiters
37+
{% doc %}
38+
@param paramName - param with description
39+
@param paramName - param with description
40+
{% enddoc %}

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

+11
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,14 @@ It should normalize the param description
2727
{% doc %}
2828
@param paramName - param with description
2929
{% enddoc %}
30+
31+
It should strip whitespace between optional param delimiters
32+
{% doc %}
33+
@param [ paramName ] - param with description
34+
{% enddoc %}
35+
36+
It should remove incomplete optional param delimiters
37+
{% doc %}
38+
@param paramName] - param with description
39+
@param [paramName - param with description
40+
{% enddoc %}

0 commit comments

Comments
 (0)