Loading doc_comment.rb +5 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,11 @@ module JsDuck end end # Sets default type of @cfg or @property def set_default_type(type) @root_tag[:type] = type if @tags[:cfg] || @tags[:property] end def [](tagname) @tags[tagname] end Loading parser.rb +10 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ module JsDuck doc.set_default_params(right[:params]) elsif right[:type] == :ext_extend then doc.set_default_extends(right[:extend]) elsif right[:type] == :literal then doc.set_default_type(right[:class]) end end end Loading Loading @@ -126,6 +128,14 @@ module JsDuck function elsif look("Ext", ".", "extend") then ext_extend elsif look(:string) then {:type => :literal, :class => "String"} elsif look("true") || look("false") then {:type => :literal, :class => "Boolean"} elsif look(:number) then {:type => :literal, :class => "Number"} elsif look(:regex) then {:type => :literal, :class => "RegExp"} end end Loading tc_jsduck.rb +19 −0 Original line number Diff line number Diff line Loading @@ -228,6 +228,7 @@ foo: true, ") assert_equal("foo", docs[0][:cfg][:name]) assert_equal("My comment", docs[0][:cfg][:doc]) assert_equal("Boolean", docs[0][:cfg][:type]) end def test_property Loading @@ -244,5 +245,23 @@ foo: true, assert_equal("My comment", docs[0][:property][:doc]) end def test_implicit_property_type comment = " /** * @property */ " docs = JsDuck.parse(comment + "foo: 'haha',") assert_equal("String", docs[0][:property][:type]) docs = JsDuck.parse(comment + "foo: 123,") assert_equal("Number", docs[0][:property][:type]) docs = JsDuck.parse(comment + "foo: /^123/,") assert_equal("RegExp", docs[0][:property][:type]) docs = JsDuck.parse(comment + "foo: true,") assert_equal("Boolean", docs[0][:property][:type]) docs = JsDuck.parse(comment + "foo: false,") assert_equal("Boolean", docs[0][:property][:type]) end end Loading
doc_comment.rb +5 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,11 @@ module JsDuck end end # Sets default type of @cfg or @property def set_default_type(type) @root_tag[:type] = type if @tags[:cfg] || @tags[:property] end def [](tagname) @tags[tagname] end Loading
parser.rb +10 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ module JsDuck doc.set_default_params(right[:params]) elsif right[:type] == :ext_extend then doc.set_default_extends(right[:extend]) elsif right[:type] == :literal then doc.set_default_type(right[:class]) end end end Loading Loading @@ -126,6 +128,14 @@ module JsDuck function elsif look("Ext", ".", "extend") then ext_extend elsif look(:string) then {:type => :literal, :class => "String"} elsif look("true") || look("false") then {:type => :literal, :class => "Boolean"} elsif look(:number) then {:type => :literal, :class => "Number"} elsif look(:regex) then {:type => :literal, :class => "RegExp"} end end Loading
tc_jsduck.rb +19 −0 Original line number Diff line number Diff line Loading @@ -228,6 +228,7 @@ foo: true, ") assert_equal("foo", docs[0][:cfg][:name]) assert_equal("My comment", docs[0][:cfg][:doc]) assert_equal("Boolean", docs[0][:cfg][:type]) end def test_property Loading @@ -244,5 +245,23 @@ foo: true, assert_equal("My comment", docs[0][:property][:doc]) end def test_implicit_property_type comment = " /** * @property */ " docs = JsDuck.parse(comment + "foo: 'haha',") assert_equal("String", docs[0][:property][:type]) docs = JsDuck.parse(comment + "foo: 123,") assert_equal("Number", docs[0][:property][:type]) docs = JsDuck.parse(comment + "foo: /^123/,") assert_equal("RegExp", docs[0][:property][:type]) docs = JsDuck.parse(comment + "foo: true,") assert_equal("Boolean", docs[0][:property][:type]) docs = JsDuck.parse(comment + "foo: false,") assert_equal("Boolean", docs[0][:property][:type]) end end