Loading lib/jsduck/type_parser.rb +3 −0 Original line number Diff line number Diff line Loading @@ -207,6 +207,7 @@ module JsDuck key = @input.scan(/[a-zA-Z0-9_]+/) return false unless key @out << key skip_whitespace if @input.scan(/:/) Loading Loading @@ -321,8 +322,10 @@ module JsDuck # All type names besides * can be followed by .<arguments> if name != "*" && @input.scan(/\.</) @out << ".<" return false unless type_arguments return false unless @input.scan(/>/) @out << ">" end true Loading spec/type_parser_spec.rb +21 −3 Original line number Diff line number Diff line Loading @@ -303,11 +303,29 @@ describe JsDuck::TypeParser do p.out.should == '<a href="String">string</a>' end it "preserves whitespace in output" do def parse_to_output(input) relations = JsDuck::Relations.new([]) p = JsDuck::TypeParser.new(relations) p.parse("( string | number )") p.out.should == '( string | number )' p.parse(input) return p.out end it "preserves whitespace in output" do parse_to_output("( string | number )").should == "( string | number )" end it "converts < and > to HTML entities in output" do parse_to_output("number.<string, *>").should == "number.<string, *>" end it "preserves function notation in output" do input = 'function(this:string, ?number=, !number, ...[number]): boolean' parse_to_output(input).should == input end it "preserves object literal notation in output" do input = '{myNum: number, myObject}' parse_to_output(input).should == input end end Loading Loading
lib/jsduck/type_parser.rb +3 −0 Original line number Diff line number Diff line Loading @@ -207,6 +207,7 @@ module JsDuck key = @input.scan(/[a-zA-Z0-9_]+/) return false unless key @out << key skip_whitespace if @input.scan(/:/) Loading Loading @@ -321,8 +322,10 @@ module JsDuck # All type names besides * can be followed by .<arguments> if name != "*" && @input.scan(/\.</) @out << ".<" return false unless type_arguments return false unless @input.scan(/>/) @out << ">" end true Loading
spec/type_parser_spec.rb +21 −3 Original line number Diff line number Diff line Loading @@ -303,11 +303,29 @@ describe JsDuck::TypeParser do p.out.should == '<a href="String">string</a>' end it "preserves whitespace in output" do def parse_to_output(input) relations = JsDuck::Relations.new([]) p = JsDuck::TypeParser.new(relations) p.parse("( string | number )") p.out.should == '( string | number )' p.parse(input) return p.out end it "preserves whitespace in output" do parse_to_output("( string | number )").should == "( string | number )" end it "converts < and > to HTML entities in output" do parse_to_output("number.<string, *>").should == "number.<string, *>" end it "preserves function notation in output" do input = 'function(this:string, ?number=, !number, ...[number]): boolean' parse_to_output(input).should == input end it "preserves object literal notation in output" do input = '{myNum: number, myObject}' parse_to_output(input).should == input end end Loading