Loading doc_comment.rb +18 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ module JsDuck name = name_chain.last tagname = (name[0,1] == name[0,1].upcase) ? :class : :function if !@tags[:class] && !@tags[:function] then if !@tags[:class] && !@tags[:function] && !@tags[:event] && !@tags[:cfg] then @tags[tagname] = {:name => (tagname == :function) ? name : name_chain.join(".")} @tags[tagname][:doc] = @tags[:default][:doc] end Loading Loading @@ -87,6 +87,8 @@ module JsDuck at_param elsif look(/@return\b/) then at_return elsif look(/@cfg\b/) then at_cfg elsif look(/@/) then @current_tag[:doc] += @input.scan(/@/) elsif look(/[^@]/) then Loading Loading @@ -195,6 +197,21 @@ module JsDuck skip_white end # matches @cfg {type} name ... def at_cfg match(/@cfg/) @current_tag = @tags[:cfg] = {:doc => ""} skip_white if look(/\{/) then @current_tag[:type] = typedef end skip_white if look(/\w/) then @current_tag[:name] = ident end skip_white end # matches {...} and returns text inside brackets def typedef match(/\{/) Loading tc_doc_comment.rb +10 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,16 @@ class TestDocComment < Test::Unit::TestCase assert_equal("Fires when the mouse button is depressed.", doc[:event][:doc]) end def test_cfg doc = JsDuck::DocComment.new("/** * @cfg {Boolean} enabled * True to enable this. */") assert_equal("enabled", doc[:cfg][:name]) assert_equal("Boolean", doc[:cfg][:type]) assert_equal("True to enable this.", doc[:cfg][:doc]) end def test_long_docs doc = JsDuck::DocComment.new("/** * @function foo Loading Loading
doc_comment.rb +18 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ module JsDuck name = name_chain.last tagname = (name[0,1] == name[0,1].upcase) ? :class : :function if !@tags[:class] && !@tags[:function] then if !@tags[:class] && !@tags[:function] && !@tags[:event] && !@tags[:cfg] then @tags[tagname] = {:name => (tagname == :function) ? name : name_chain.join(".")} @tags[tagname][:doc] = @tags[:default][:doc] end Loading Loading @@ -87,6 +87,8 @@ module JsDuck at_param elsif look(/@return\b/) then at_return elsif look(/@cfg\b/) then at_cfg elsif look(/@/) then @current_tag[:doc] += @input.scan(/@/) elsif look(/[^@]/) then Loading Loading @@ -195,6 +197,21 @@ module JsDuck skip_white end # matches @cfg {type} name ... def at_cfg match(/@cfg/) @current_tag = @tags[:cfg] = {:doc => ""} skip_white if look(/\{/) then @current_tag[:type] = typedef end skip_white if look(/\w/) then @current_tag[:name] = ident end skip_white end # matches {...} and returns text inside brackets def typedef match(/\{/) Loading
tc_doc_comment.rb +10 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,16 @@ class TestDocComment < Test::Unit::TestCase assert_equal("Fires when the mouse button is depressed.", doc[:event][:doc]) end def test_cfg doc = JsDuck::DocComment.new("/** * @cfg {Boolean} enabled * True to enable this. */") assert_equal("enabled", doc[:cfg][:name]) assert_equal("Boolean", doc[:cfg][:type]) assert_equal("True to enable this.", doc[:cfg][:doc]) end def test_long_docs doc = JsDuck::DocComment.new("/** * @function foo Loading