Loading lib/jsduck/format/subproperties.rb +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ module JsDuck # Skip the formatting entirely when type-parsing is turned off. return Util::HTML.escape(type) unless @format_types tp = TypeParser.new(@formatter.relations, @formatter) tp = TypeParser.new(@formatter) if tp.parse(type) tp.out else Loading lib/jsduck/type_parser.rb +3 −3 Original line number Diff line number Diff line Loading @@ -50,9 +50,9 @@ module JsDuck # input type-definition with types themselves replaced with links. attr_reader :out # Initializes the parser with hash of valid type names and doc_formatter. def initialize(relations={}, formatter={}) @relations = relations # Initializes the parser with a Format::Doc instance. def initialize(formatter) @relations = formatter.relations @formatter = formatter @primitives = { "boolean" => "Boolean", Loading spec/type_parser_spec.rb +6 −3 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ require "jsduck/relations" require "jsduck/type_parser" require "jsduck/format/doc" require "jsduck/class" require "ostruct" describe JsDuck::TypeParser do Loading @@ -15,7 +16,8 @@ describe JsDuck::TypeParser do "Ext.Element", "Ext.fx2.Anim", ]) JsDuck::TypeParser.new(relations).parse(str) formatter = OpenStruct.new(:relations => relations) JsDuck::TypeParser.new(formatter).parse(str) end it "matches single-quoted string literal" do Loading Loading @@ -326,14 +328,15 @@ describe JsDuck::TypeParser do it "links primitive types to classes" do relations = JsDuck::Relations.new([JsDuck::Class.new({:name => "String"})]) doc_formatter = JsDuck::Format::Doc.new(relations) p = JsDuck::TypeParser.new(relations, doc_formatter) p = JsDuck::TypeParser.new(doc_formatter) p.parse("string") p.out.should == '<a href="String">string</a>' end def parse_to_output(input) relations = JsDuck::Relations.new([]) p = JsDuck::TypeParser.new(relations) formatter = OpenStruct.new(:relations => relations) p = JsDuck::TypeParser.new(formatter) p.parse(input) return p.out end Loading Loading
lib/jsduck/format/subproperties.rb +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ module JsDuck # Skip the formatting entirely when type-parsing is turned off. return Util::HTML.escape(type) unless @format_types tp = TypeParser.new(@formatter.relations, @formatter) tp = TypeParser.new(@formatter) if tp.parse(type) tp.out else Loading
lib/jsduck/type_parser.rb +3 −3 Original line number Diff line number Diff line Loading @@ -50,9 +50,9 @@ module JsDuck # input type-definition with types themselves replaced with links. attr_reader :out # Initializes the parser with hash of valid type names and doc_formatter. def initialize(relations={}, formatter={}) @relations = relations # Initializes the parser with a Format::Doc instance. def initialize(formatter) @relations = formatter.relations @formatter = formatter @primitives = { "boolean" => "Boolean", Loading
spec/type_parser_spec.rb +6 −3 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ require "jsduck/relations" require "jsduck/type_parser" require "jsduck/format/doc" require "jsduck/class" require "ostruct" describe JsDuck::TypeParser do Loading @@ -15,7 +16,8 @@ describe JsDuck::TypeParser do "Ext.Element", "Ext.fx2.Anim", ]) JsDuck::TypeParser.new(relations).parse(str) formatter = OpenStruct.new(:relations => relations) JsDuck::TypeParser.new(formatter).parse(str) end it "matches single-quoted string literal" do Loading Loading @@ -326,14 +328,15 @@ describe JsDuck::TypeParser do it "links primitive types to classes" do relations = JsDuck::Relations.new([JsDuck::Class.new({:name => "String"})]) doc_formatter = JsDuck::Format::Doc.new(relations) p = JsDuck::TypeParser.new(relations, doc_formatter) p = JsDuck::TypeParser.new(doc_formatter) p.parse("string") p.out.should == '<a href="String">string</a>' end def parse_to_output(input) relations = JsDuck::Relations.new([]) p = JsDuck::TypeParser.new(relations) formatter = OpenStruct.new(:relations => relations) p = JsDuck::TypeParser.new(formatter) p.parse(input) return p.out end Loading