Loading doc_comment_parser.rb +14 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ module JsDuck at_class elsif look(/@extends\b/) then at_extends elsif look(/@singleton\b/) then at_singleton elsif look(/@event\b/) then at_event elsif look(/@function\b/) then Loading Loading @@ -95,7 +97,7 @@ module JsDuck def at_extends match(/@extends/) unless @tags[:class] @tags[:class] = {:doc => ""} @tags[:class] = @tags[:default] end @current_tag = @tags[:class] skip_horiz_white Loading @@ -105,6 +107,17 @@ module JsDuck skip_white end # matches @singleton def at_singleton match(/@singleton/) unless @tags[:class] @tags[:class] = @tags[:default] end @current_tag = @tags[:class] @current_tag[:singleton] = true skip_white end # matches @event name ... def at_event match(/@event/) Loading tc_doc_comment_parser.rb +20 −0 Original line number Diff line number Diff line Loading @@ -46,10 +46,30 @@ class TestDocCommentParser < Test::Unit::TestCase * @class my.package.Foo * @extends my.Bar * Some docs. * @singleton */") assert_equal("my.package.Foo", doc[:class][:name]) assert_equal("my.Bar", doc[:class][:extends]) assert_equal("Some docs.", doc[:class][:doc]) assert_equal(true, doc[:class][:singleton]) end def test_extends_implies_class doc = parse_single("/** * Class description * @extends my.Bar */") assert_equal("my.Bar", doc[:class][:extends]) assert_equal("Class description", doc[:class][:doc]) end def test_singleton_implies_class doc = parse_single("/** * Class description * @singleton */") assert_equal(true, doc[:class][:singleton]) assert_equal("Class description", doc[:class][:doc]) end def test_event Loading Loading
doc_comment_parser.rb +14 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ module JsDuck at_class elsif look(/@extends\b/) then at_extends elsif look(/@singleton\b/) then at_singleton elsif look(/@event\b/) then at_event elsif look(/@function\b/) then Loading Loading @@ -95,7 +97,7 @@ module JsDuck def at_extends match(/@extends/) unless @tags[:class] @tags[:class] = {:doc => ""} @tags[:class] = @tags[:default] end @current_tag = @tags[:class] skip_horiz_white Loading @@ -105,6 +107,17 @@ module JsDuck skip_white end # matches @singleton def at_singleton match(/@singleton/) unless @tags[:class] @tags[:class] = @tags[:default] end @current_tag = @tags[:class] @current_tag[:singleton] = true skip_white end # matches @event name ... def at_event match(/@event/) Loading
tc_doc_comment_parser.rb +20 −0 Original line number Diff line number Diff line Loading @@ -46,10 +46,30 @@ class TestDocCommentParser < Test::Unit::TestCase * @class my.package.Foo * @extends my.Bar * Some docs. * @singleton */") assert_equal("my.package.Foo", doc[:class][:name]) assert_equal("my.Bar", doc[:class][:extends]) assert_equal("Some docs.", doc[:class][:doc]) assert_equal(true, doc[:class][:singleton]) end def test_extends_implies_class doc = parse_single("/** * Class description * @extends my.Bar */") assert_equal("my.Bar", doc[:class][:extends]) assert_equal("Class description", doc[:class][:doc]) end def test_singleton_implies_class doc = parse_single("/** * Class description * @singleton */") assert_equal(true, doc[:class][:singleton]) assert_equal("Class description", doc[:class][:doc]) end def test_event Loading