Loading lib/jsduck/doc_parser.rb +6 −3 Original line number Diff line number Diff line Loading @@ -23,11 +23,14 @@ module JsDuck # Extracts content inside /** ... */ def purify(input) result = [] # Remove the beginning /** and end */ input = input.sub(/\A\/\*\* ?/, "").sub(/ ?\*\/\Z/, "") # Now we are left with only two types of lines: # - those beginning with * # - and those without it input.each_line do |line| line.chomp! if line =~ /\A\/\*\*/ || line =~ /\*\/\Z/ then # ignore first and last line elsif line =~ /\A\s*\*\s?(.*)\Z/ then if line =~ /\A\s*\*\s?(.*)\Z/ then result << $1 else result << line Loading test/tc_doc_parser.rb +6 −0 Original line number Diff line number Diff line Loading @@ -36,5 +36,11 @@ class TestDocParser < Test::Unit::TestCase assert_equal("Boolean|String", doc[0][:type]) end def test_single_line_doc_comment doc = parse_single("/** @event blah */") assert_equal(:event, doc[0][:tagname]) assert_equal("blah", doc[0][:name]) end end Loading
lib/jsduck/doc_parser.rb +6 −3 Original line number Diff line number Diff line Loading @@ -23,11 +23,14 @@ module JsDuck # Extracts content inside /** ... */ def purify(input) result = [] # Remove the beginning /** and end */ input = input.sub(/\A\/\*\* ?/, "").sub(/ ?\*\/\Z/, "") # Now we are left with only two types of lines: # - those beginning with * # - and those without it input.each_line do |line| line.chomp! if line =~ /\A\/\*\*/ || line =~ /\*\/\Z/ then # ignore first and last line elsif line =~ /\A\s*\*\s?(.*)\Z/ then if line =~ /\A\s*\*\s?(.*)\Z/ then result << $1 else result << line Loading
test/tc_doc_parser.rb +6 −0 Original line number Diff line number Diff line Loading @@ -36,5 +36,11 @@ class TestDocParser < Test::Unit::TestCase assert_equal("Boolean|String", doc[0][:type]) end def test_single_line_doc_comment doc = parse_single("/** @event blah */") assert_equal(:event, doc[0][:tagname]) assert_equal("blah", doc[0][:name]) end end