Loading doc_comment.rb +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ module JsDuck def initialize(tags) @tags = tags [:class, :method, :event, :cfg].each do |name| [:class, :method, :event, :cfg, :property].each do |name| if @tags[name] then @root_tag = @tags[name] end Loading doc_comment_parser.rb +22 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,8 @@ module JsDuck at_return elsif look(/@cfg\b/) then at_cfg elsif look(/@property\b/) then at_property elsif look(/@/) then @current_tag[:doc] += @input.scan(/@/) elsif look(/[^@]/) then Loading Loading @@ -196,6 +198,26 @@ module JsDuck skip_white end # matches @property {type} name ... # # ext-doc doesn't support {type} and name for @property - name is # inferred from source and @type is required to specify type, # jsdoc-toolkit on the other hand follows the sensible route, and # so do we. def at_property match(/@property/) set_root_tag(:property, {:doc => ""}) skip_horiz_white if look(/\{/) then @current_tag[:type] = typedef end skip_horiz_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_parser.rb +10 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,16 @@ class TestDocCommentParser < Test::Unit::TestCase assert_equal("True to enable this.", doc[:cfg][:doc]) end def test_property doc = parse_single("/** * @property {Boolean} enabled * True when enabled. */") assert_equal("enabled", doc[:property][:name]) assert_equal("Boolean", doc[:property][:type]) assert_equal("True when enabled.", doc[:property][:doc]) end def test_long_docs doc = parse_single("/** * @method foo Loading Loading
doc_comment.rb +1 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ module JsDuck def initialize(tags) @tags = tags [:class, :method, :event, :cfg].each do |name| [:class, :method, :event, :cfg, :property].each do |name| if @tags[name] then @root_tag = @tags[name] end Loading
doc_comment_parser.rb +22 −0 Original line number Diff line number Diff line Loading @@ -61,6 +61,8 @@ module JsDuck at_return elsif look(/@cfg\b/) then at_cfg elsif look(/@property\b/) then at_property elsif look(/@/) then @current_tag[:doc] += @input.scan(/@/) elsif look(/[^@]/) then Loading Loading @@ -196,6 +198,26 @@ module JsDuck skip_white end # matches @property {type} name ... # # ext-doc doesn't support {type} and name for @property - name is # inferred from source and @type is required to specify type, # jsdoc-toolkit on the other hand follows the sensible route, and # so do we. def at_property match(/@property/) set_root_tag(:property, {:doc => ""}) skip_horiz_white if look(/\{/) then @current_tag[:type] = typedef end skip_horiz_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_parser.rb +10 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,16 @@ class TestDocCommentParser < Test::Unit::TestCase assert_equal("True to enable this.", doc[:cfg][:doc]) end def test_property doc = parse_single("/** * @property {Boolean} enabled * True when enabled. */") assert_equal("enabled", doc[:property][:name]) assert_equal("Boolean", doc[:property][:type]) assert_equal("True when enabled.", doc[:property][:doc]) end def test_long_docs doc = parse_single("/** * @method foo Loading