File tree 4 files changed +39
-4
lines changed
packages/prettier-plugin-liquid/src
4 files changed +39
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @shopify/prettier-plugin-liquid ' : minor
3
+ ---
4
+
5
+ Add formatting support for optional liquidDoc parameters (e.g. ` @param [optional-parameter] - paramDescription ` ).
6
+ Whitespace is now stripped around the parameter name and the optional delimiters.
Original file line number Diff line number Diff line change @@ -520,8 +520,10 @@ export function printLiquidDocParam(
520
520
parts . push ( ' ' , `{${ node . paramType . value } }` ) ;
521
521
}
522
522
523
- if ( node . paramName . value ) {
523
+ if ( node . required ) {
524
524
parts . push ( ' ' , node . paramName . value ) ;
525
+ } else {
526
+ parts . push ( ' ' , `[${ node . paramName . value } ]` ) ;
525
527
}
526
528
527
529
if ( node . paramDescription ?. value ) {
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ It should format the param description with a dash separator
19
19
{% enddoc %}
20
20
21
21
It should respect the liquidDocParamDash option liquidDocParamDash: false
22
+ liquidDocParamDash: false
22
23
{% doc %}
23
24
@param paramName param with description
24
25
{% enddoc %}
@@ -28,6 +29,19 @@ It should normalize the param description
28
29
@param paramName - param with description
29
30
{% enddoc %}
30
31
32
+ It should strip whitespace between optional param delimiters
33
+ {% doc %}
34
+ @param [paramName] - param with description
35
+ {% enddoc %}
36
+
37
+ It should not break params with malformed optional delimiters
38
+ {% doc %}
39
+ @param [missingTail - param with description
40
+ @param missingHead - ] - param with description
41
+ @param [too many words no desc]
42
+ @param [too many words] - param with description
43
+ {% enddoc %}
44
+
31
45
It should push example content to the next line
32
46
{% doc %}
33
47
@example
Original file line number Diff line number Diff line change @@ -28,6 +28,19 @@ It should normalize the param description
28
28
@param paramName - param with description
29
29
{% enddoc %}
30
30
31
+ It should strip whitespace between optional param delimiters
32
+ {% doc %}
33
+ @param [ paramName ] - param with description
34
+ {% enddoc %}
35
+
36
+ It should handle params with malformed optional delimiters
37
+ {% doc %}
38
+ @param [missingTail - param with description
39
+ @param missingHead - ] - param with description
40
+ @param [too many words no desc]
41
+ @param [too many words] - param with description
42
+ {% enddoc %}
43
+
31
44
It should push example content to the next line
32
45
{% doc %}
33
46
@example This is a valid example
@@ -65,8 +78,8 @@ It should remove empty lines at the end of the content
65
78
66
79
It should respect example content with param and description
67
80
{% doc %}
68
- @param paramName - param with description
69
- @example
81
+ @param paramName - param with description
82
+ @example
70
83
71
- This is a valid example
84
+ This is a valid example
72
85
{% enddoc %}
You can’t perform that action at this time.
0 commit comments