@@ -1220,56 +1220,72 @@ describe('Unit: Stage 2 (AST)', () => {
1220
1220
expectPath ( ast , 'children.0.markup.1.children.0.children.1.markup.name' ) . to . eql ( 'var3' ) ;
1221
1221
} ) ;
1222
1222
1223
- it ( `should parse doc tags` , ( ) => {
1224
- ast = toLiquidAST ( `{% doc %}{% enddoc %}` ) ;
1225
- expectPath ( ast , 'children.0.type' ) . to . eql ( 'LiquidRawTag' ) ;
1226
- expectPath ( ast , 'children.0.name' ) . to . eql ( 'doc' ) ;
1227
- expectPath ( ast , 'children.0.markup' ) . toEqual ( '' ) ;
1228
- expectPath ( ast , 'children.0.body.value' ) . to . eql ( '' ) ;
1229
- expectPath ( ast , 'children.0.body.type' ) . toEqual ( 'RawMarkup' ) ;
1230
- expectPath ( ast , 'children.0.body.nodes' ) . toEqual ( [ ] ) ;
1231
-
1232
- ast = toLiquidAST ( `
1223
+ describe ( 'LiquidDoc' , ( ) => {
1224
+ it ( `should parse liquid doc tags` , ( ) => {
1225
+ ast = toLiquidAST ( `{% doc %}{% enddoc %}` ) ;
1226
+ expectPath ( ast , 'children.0.type' ) . to . eql ( 'LiquidRawTag' ) ;
1227
+ expectPath ( ast , 'children.0.name' ) . to . eql ( 'doc' ) ;
1228
+ expectPath ( ast , 'children.0.markup' ) . toEqual ( '' ) ;
1229
+ expectPath ( ast , 'children.0.body.value' ) . to . eql ( '' ) ;
1230
+ expectPath ( ast , 'children.0.body.type' ) . toEqual ( 'RawMarkup' ) ;
1231
+ expectPath ( ast , 'children.0.body.nodes' ) . toEqual ( [ ] ) ;
1232
+
1233
+ ast = toLiquidAST ( `
1233
1234
{% doc -%}
1234
- @param paramWithNoType
1235
+ @param requiredParamWithNoType
1236
+ @param [optionalParameter] - optional parameter description
1235
1237
@param {String} paramWithDescription - param with description and \`punctation\`. This is still a valid param description.
1236
1238
@param {String} paramWithNoDescription
1237
1239
@unsupported this node falls back to a text node
1240
+ @param [optionalParameterWithDefault=defaultValue] - optional parameter description with default
1241
+ @param {String} [optionalParameterWithDefaultAndType=defaultValue]
1238
1242
{%- enddoc %}
1239
1243
` ) ;
1240
- expectPath ( ast , 'children.0.type' ) . to . eql ( 'LiquidRawTag' ) ;
1241
- expectPath ( ast , 'children.0.name' ) . to . eql ( 'doc' ) ;
1242
-
1243
- expectPath ( ast , 'children.0.body.nodes.0.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1244
- expectPath ( ast , 'children.0.body.nodes.0.name' ) . to . eql ( 'param' ) ;
1245
- 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' ) ;
1247
- expectPath ( ast , 'children.0.body.nodes.0.paramType' ) . to . be . null ;
1248
- expectPath ( ast , 'children.0.body.nodes.0.paramDescription' ) . to . be . null ;
1249
-
1250
- expectPath ( ast , 'children.0.body.nodes.1.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1251
- expectPath ( ast , 'children.0.body.nodes.1.name' ) . to . eql ( 'param' ) ;
1252
- 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' ) ;
1254
- expectPath ( ast , 'children.0.body.nodes.1.paramDescription.type' ) . to . eql ( 'TextNode' ) ;
1255
- expectPath ( ast , 'children.0.body.nodes.1.paramDescription.value' ) . to . eql (
1256
- 'param with description and `punctation`. This is still a valid param description.' ,
1257
- ) ;
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' ) ;
1260
-
1261
- expectPath ( ast , 'children.0.body.nodes.2.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1262
- expectPath ( ast , 'children.0.body.nodes.2.name' ) . to . eql ( 'param' ) ;
1263
- 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 ;
1266
- expectPath ( ast , 'children.0.body.nodes.2.paramType.type' ) . to . eql ( 'TextNode' ) ;
1267
- expectPath ( ast , 'children.0.body.nodes.2.paramType.value' ) . to . eql ( 'String' ) ;
1268
-
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
- ) ;
1244
+ expectPath ( ast , 'children.0.type' ) . to . eql ( 'LiquidRawTag' ) ;
1245
+ expectPath ( ast , 'children.0.name' ) . to . eql ( 'doc' ) ;
1246
+
1247
+ expectPath ( ast , 'children.0.body.nodes.0.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1248
+ expectPath ( ast , 'children.0.body.nodes.0.name' ) . to . eql ( 'param' ) ;
1249
+ expectPath ( ast , 'children.0.body.nodes.0.required' ) . to . eql ( true ) ;
1250
+ expectPath ( ast , 'children.0.body.nodes.0.paramName.type' ) . to . eql ( 'TextNode' ) ;
1251
+ expectPath ( ast , 'children.0.body.nodes.0.paramName.value' ) . to . eql (
1252
+ 'requiredParamWithNoType' ,
1253
+ ) ;
1254
+ expectPath ( ast , 'children.0.body.nodes.0.paramType' ) . to . be . null ;
1255
+ expectPath ( ast , 'children.0.body.nodes.0.paramDescription' ) . to . be . null ;
1256
+
1257
+ expectPath ( ast , 'children.0.body.nodes.1.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1258
+ expectPath ( ast , 'children.0.body.nodes.1.name' ) . to . eql ( 'param' ) ;
1259
+ expectPath ( ast , 'children.0.body.nodes.1.required' ) . to . eql ( false ) ;
1260
+ expectPath ( ast , 'children.0.body.nodes.1.paramName.type' ) . to . eql ( 'TextNode' ) ;
1261
+ expectPath ( ast , 'children.0.body.nodes.1.paramName.value' ) . to . eql ( 'optionalParameter' ) ;
1262
+ expectPath ( ast , 'children.0.body.nodes.1.paramDescription.type' ) . to . eql ( 'TextNode' ) ;
1263
+ expectPath ( ast , 'children.0.body.nodes.1.paramDescription.value' ) . to . eql (
1264
+ 'optional parameter description' ,
1265
+ ) ;
1266
+ expectPath ( ast , 'children.0.body.nodes.1.paramType' ) . to . be . null ;
1267
+ expectPath ( ast , 'children.0.body.nodes.1.paramType' ) . to . be . null ;
1268
+
1269
+ expectPath ( ast , 'children.0.body.nodes.2.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1270
+ expectPath ( ast , 'children.0.body.nodes.2.name' ) . to . eql ( 'param' ) ;
1271
+ expectPath ( ast , 'children.0.body.nodes.2.required' ) . to . eql ( true ) ;
1272
+ expectPath ( ast , 'children.0.body.nodes.2.paramName.type' ) . to . eql ( 'TextNode' ) ;
1273
+ expectPath ( ast , 'children.0.body.nodes.2.paramName.value' ) . to . eql ( 'paramWithDescription' ) ;
1274
+ expectPath ( ast , 'children.0.body.nodes.2.paramDescription.type' ) . to . eql ( 'TextNode' ) ;
1275
+ expectPath ( ast , 'children.0.body.nodes.2.paramDescription.value' ) . to . eql (
1276
+ 'param with description and `punctation`. This is still a valid param description.' ,
1277
+ ) ;
1278
+ expectPath ( ast , 'children.0.body.nodes.2.paramType.type' ) . to . eql ( 'TextNode' ) ;
1279
+ expectPath ( ast , 'children.0.body.nodes.2.paramType.value' ) . to . eql ( 'String' ) ;
1280
+
1281
+ expectPath ( ast , 'children.0.body.nodes.3.type' ) . to . eql ( 'LiquidDocParamNode' ) ;
1282
+ expectPath ( ast , 'children.0.body.nodes.3.name' ) . to . eql ( 'param' ) ;
1283
+ expectPath ( ast , 'children.0.body.nodes.2.paramName.type' ) . to . eql ( 'TextNode' ) ;
1284
+ expectPath ( ast , 'children.0.body.nodes.3.paramName.value' ) . to . eql ( 'paramWithNoDescription' ) ;
1285
+ expectPath ( ast , 'children.0.body.nodes.3.paramDescription' ) . to . be . null ;
1286
+ expectPath ( ast , 'children.0.body.nodes.3.paramType.type' ) . to . eql ( 'TextNode' ) ;
1287
+ expectPath ( ast , 'children.0.body.nodes.3.paramType.value' ) . to . eql ( 'String' ) ;
1288
+ } ) ;
1273
1289
} ) ;
1274
1290
1275
1291
it ( 'should parse unclosed tables with assignments' , ( ) => {
0 commit comments