File tree 4 files changed +51
-1
lines changed
packages/prettier-plugin-liquid/src
4 files changed +51
-1
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 params and default values. Whitespace is now stripped between the optional delimiter and the param name, and around the default value if it exists.
Original file line number Diff line number Diff line change @@ -519,8 +519,14 @@ export function printLiquidDocParam(
519
519
parts . push ( ' ' , `{${ node . paramType . value } }` ) ;
520
520
}
521
521
522
- if ( node . paramName . value ) {
522
+ if ( node . required ) {
523
523
parts . push ( ' ' , node . paramName . value ) ;
524
+ } else {
525
+ if ( node . defaultValue ?. value ) {
526
+ parts . push ( ' ' , `[${ node . paramName . value } =${ node . defaultValue . value } ]` ) ;
527
+ } else {
528
+ parts . push ( ' ' , `[${ node . paramName . value } ]` ) ;
529
+ }
524
530
}
525
531
526
532
if ( node . paramDescription ?. value ) {
Original file line number Diff line number Diff line change @@ -27,3 +27,23 @@ It should normalize the param description
27
27
{% doc %}
28
28
@param paramName - param with description
29
29
{% enddoc %}
30
+
31
+ It should strip whitespace between optional param delimiters
32
+ {% doc %}
33
+ @param [paramName] - param with description
34
+ @param [paramName =defaultValue] - param with description
35
+ @param [paramName =defaultValue] - param with description
36
+ {% enddoc %}
37
+
38
+
39
+ It should not break params with malformed optional delimiters
40
+ {% doc %}
41
+ @param [ missingTail - param with description
42
+ @param missingHead ] - param with description
43
+ @param [ too many words no type no desc]
44
+ @param [too many words no type ] - param with description
45
+ @param {String} [too many words no desc ]
46
+ @param {String} [ too many words = default value] - description
47
+ @param {String} [ too many words = default value no desc ]
48
+ @param {String} [ too many words = default value no type ]
49
+ {% enddoc %}
Original file line number Diff line number Diff line change @@ -27,3 +27,22 @@ It should normalize the param description
27
27
{% doc %}
28
28
@param paramName - param with description
29
29
{% enddoc %}
30
+
31
+ It should strip whitespace between optional param delimiters
32
+ {% doc %}
33
+ @param [ paramName ] - param with description
34
+ @param [ paramName = defaultValue] - param with description
35
+ @param [paramName =defaultValue ] - param with description
36
+ {% enddoc %}
37
+
38
+ It should handle params with malformed optional delimiters
39
+ {% doc %}
40
+ @param [ missingTail - param with description
41
+ @param missingHead ] - param with description
42
+ @param [ too many words no type no desc]
43
+ @param [too many words no type ] - param with description
44
+ @param {String} [too many words no desc ]
45
+ @param {String} [ too many words = default value] - description
46
+ @param {String} [ too many words = default value no desc ]
47
+ @param {String} [ too many words = default value no type ]
48
+ {% enddoc %}
You can’t perform that action at this time.
0 commit comments