@@ -1231,7 +1231,8 @@ describe('Unit: Stage 2 (AST)', () => {
1231
1231
1232
1232
ast = toLiquidAST ( `
1233
1233
{% doc -%}
1234
- @param paramWithNoType
1234
+ @param requiredParamWithNoType
1235
+ @param [optionalParameter] - optional parameter description
1235
1236
@param {String} paramWithDescription - param with description and \`punctation\`. This is still a valid param description.
1236
1237
@param {String} paramWithNoDescription
1237
1238
@unsupported this node falls back to a text node
@@ -1242,34 +1243,43 @@ describe('Unit: Stage 2 (AST)', () => {
1242
1243
1243
1244
expectPath ( ast , 'children.0.body.nodes.0.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1244
1245
expectPath ( ast , 'children.0.body.nodes.0.name' ) . to . eql ( 'param' ) ;
1246
+ expectPath ( ast , 'children.0.body.nodes.0.required' ) . to . eql ( true ) ;
1245
1247
expectPath ( ast , 'children.0.body.nodes.0.paramName.type' ) . to . eql ( 'TextNode' ) ;
1246
- expectPath ( ast , 'children.0.body.nodes.0.paramName.value' ) . to . eql ( 'paramWithNoType ' ) ;
1248
+ expectPath ( ast , 'children.0.body.nodes.0.paramName.value' ) . to . eql ( 'requiredParamWithNoType ' ) ;
1247
1249
expectPath ( ast , 'children.0.body.nodes.0.paramType' ) . to . be . null ;
1248
1250
expectPath ( ast , 'children.0.body.nodes.0.paramDescription' ) . to . be . null ;
1249
1251
1250
1252
expectPath ( ast , 'children.0.body.nodes.1.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1251
1253
expectPath ( ast , 'children.0.body.nodes.1.name' ) . to . eql ( 'param' ) ;
1254
+ expectPath ( ast , 'children.0.body.nodes.1.required' ) . to . eql ( false ) ;
1252
1255
expectPath ( ast , 'children.0.body.nodes.1.paramName.type' ) . to . eql ( 'TextNode' ) ;
1253
- expectPath ( ast , 'children.0.body.nodes.1.paramName.value' ) . to . eql ( 'paramWithDescription ' ) ;
1256
+ expectPath ( ast , 'children.0.body.nodes.1.paramName.value' ) . to . eql ( 'optionalParameter ' ) ;
1254
1257
expectPath ( ast , 'children.0.body.nodes.1.paramDescription.type' ) . to . eql ( 'TextNode' ) ;
1255
1258
expectPath ( ast , 'children.0.body.nodes.1.paramDescription.value' ) . to . eql (
1256
- 'param with description and `punctation`. This is still a valid param description. ' ,
1259
+ 'optional parameter description' ,
1257
1260
) ;
1258
- expectPath ( ast , 'children.0.body.nodes.1.paramType.type ' ) . to . eql ( 'TextNode' ) ;
1259
- expectPath ( ast , 'children.0.body.nodes.1.paramType.value ' ) . to . eql ( 'String' ) ;
1261
+ expectPath ( ast , 'children.0.body.nodes.1.paramType' ) . to . be . null ;
1262
+ expectPath ( ast , 'children.0.body.nodes.1.paramType' ) . to . be . null ;
1260
1263
1261
1264
expectPath ( ast , 'children.0.body.nodes.2.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1262
1265
expectPath ( ast , 'children.0.body.nodes.2.name' ) . to . eql ( 'param' ) ;
1266
+ expectPath ( ast , 'children.0.body.nodes.2.required' ) . to . eql ( true ) ;
1263
1267
expectPath ( ast , 'children.0.body.nodes.2.paramName.type' ) . to . eql ( 'TextNode' ) ;
1264
- expectPath ( ast , 'children.0.body.nodes.2.paramName.value' ) . to . eql ( 'paramWithNoDescription' ) ;
1265
- expectPath ( ast , 'children.0.body.nodes.2.paramDescription' ) . to . be . null ;
1268
+ expectPath ( ast , 'children.0.body.nodes.2.paramName.value' ) . to . eql ( 'paramWithDescription' ) ;
1269
+ expectPath ( ast , 'children.0.body.nodes.2.paramDescription.type' ) . to . eql ( 'TextNode' ) ;
1270
+ expectPath ( ast , 'children.0.body.nodes.2.paramDescription.value' ) . to . eql (
1271
+ 'param with description and `punctation`. This is still a valid param description.' ,
1272
+ ) ;
1266
1273
expectPath ( ast , 'children.0.body.nodes.2.paramType.type' ) . to . eql ( 'TextNode' ) ;
1267
1274
expectPath ( ast , 'children.0.body.nodes.2.paramType.value' ) . to . eql ( 'String' ) ;
1268
1275
1269
- expectPath ( ast , 'children.0.body.nodes.3.type' ) . to . eql ( 'TextNode' ) ;
1270
- expectPath ( ast , 'children.0.body.nodes.3.value' ) . to . eql (
1271
- '@unsupported this node falls back to a text node' ,
1272
- ) ;
1276
+ expectPath ( ast , 'children.0.body.nodes.3.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1277
+ expectPath ( ast , 'children.0.body.nodes.3.name' ) . to . eql ( 'param' ) ;
1278
+ expectPath ( ast , 'children.0.body.nodes.2.paramName.type' ) . to . eql ( 'TextNode' ) ;
1279
+ expectPath ( ast , 'children.0.body.nodes.3.paramName.value' ) . to . eql ( 'paramWithNoDescription' ) ;
1280
+ expectPath ( ast , 'children.0.body.nodes.3.paramDescription' ) . to . be . null ;
1281
+ expectPath ( ast , 'children.0.body.nodes.3.paramType.type' ) . to . eql ( 'TextNode' ) ;
1282
+ expectPath ( ast , 'children.0.body.nodes.3.paramType.value' ) . to . eql ( 'String' ) ;
1273
1283
} ) ;
1274
1284
1275
1285
it ( 'should parse unclosed tables with assignments' , ( ) => {
0 commit comments