@@ -196,6 +196,80 @@ def test_doc_tag_visitor
196196 )
197197 end
198198
199+ def test_doc_tag_blank_with_empty_content
200+ template_source = "{% doc %}{% enddoc %}"
201+
202+ doc_tag = nil
203+ ParseTreeVisitor
204+ . for ( Template . parse ( template_source ) . root )
205+ . add_callback_for ( Liquid ::Doc ) do |tag |
206+ doc_tag = tag
207+ end
208+ . visit
209+
210+ assert_equal ( true , doc_tag . blank? )
211+ end
212+
213+ def test_doc_tag_blank_with_content
214+ template_source = "{% doc %}Some documentation{% enddoc %}"
215+
216+ doc_tag = nil
217+ ParseTreeVisitor
218+ . for ( Template . parse ( template_source ) . root )
219+ . add_callback_for ( Liquid ::Doc ) do |tag |
220+ doc_tag = tag
221+ end
222+ . visit
223+
224+ assert_equal ( false , doc_tag . blank? )
225+ end
226+
227+ def test_doc_tag_blank_with_whitespace_only
228+ template_source = "{% doc %} {% enddoc %}"
229+
230+ doc_tag = nil
231+ ParseTreeVisitor
232+ . for ( Template . parse ( template_source ) . root )
233+ . add_callback_for ( Liquid ::Doc ) do |tag |
234+ doc_tag = tag
235+ end
236+ . visit
237+
238+ assert_equal ( false , doc_tag . blank? )
239+ end
240+
241+ def test_doc_tag_nodelist_returns_array_with_body
242+ doc_content = "Documentation content\n @param {string} foo"
243+ template_source = "{% doc %}#{ doc_content } {% enddoc %}"
244+
245+ doc_tag = nil
246+ ParseTreeVisitor
247+ . for ( Template . parse ( template_source ) . root )
248+ . add_callback_for ( Liquid ::Doc ) do |tag |
249+ doc_tag = tag
250+ end
251+ . visit
252+
253+ assert_equal ( [ doc_content ] , doc_tag . nodelist )
254+ assert_equal ( 1 , doc_tag . nodelist . length )
255+ assert_equal ( doc_content , doc_tag . nodelist . first )
256+ end
257+
258+ def test_doc_tag_nodelist_with_empty_content
259+ template_source = "{% doc %}{% enddoc %}"
260+
261+ doc_tag = nil
262+ ParseTreeVisitor
263+ . for ( Template . parse ( template_source ) . root )
264+ . add_callback_for ( Liquid ::Doc ) do |tag |
265+ doc_tag = tag
266+ end
267+ . visit
268+
269+ assert_equal ( [ "" ] , doc_tag . nodelist )
270+ assert_equal ( 1 , doc_tag . nodelist . length )
271+ end
272+
199273 private
200274
201275 def traversal ( template )
0 commit comments