Loading lib/jsduck/ast.rb +4 −4 Original line number Diff line number Diff line Loading @@ -143,7 +143,7 @@ module JsDuck def make_class(name, ast=nil) cls = { :type => :class, :tagname => :class, :name => name, } Loading Loading @@ -192,7 +192,7 @@ module JsDuck def make_method(name, ast=nil) return { :type => :method, :tagname => :method, :name => name, :params => make_params(ast) } Loading @@ -208,9 +208,9 @@ module JsDuck def make_property(name=nil, ast=nil) return { :type => :property, :tagname => :property, :name => name, :value_type => make_value_type(ast) :type => make_value_type(ast) } end Loading lib/jsduck/doc_type.rb +2 −2 Original line number Diff line number Diff line Loading @@ -25,13 +25,13 @@ module JsDuck elsif doc_map[:cfg] && doc_map[:cfg].length == 1 # When just one @cfg, avoid treating it as @class :cfg elsif code[:type] == :class elsif code[:tagname] == :class :class elsif code[:type] == :css_mixin :css_mixin elsif doc_map[:cfg] :cfg elsif code[:type] == :method elsif code[:tagname] == :method :method else :property Loading spec/ast_property_spec.rb +9 −9 Original line number Diff line number Diff line Loading @@ -51,39 +51,39 @@ describe "JsDuck::Ast detects property with" do end end describe "value type in var initialized with" do describe "type in var initialized with" do it "int" do detect("/** */ var foo = 5;")[:value_type].should == "Number" detect("/** */ var foo = 5;")[:type].should == "Number" end it "float" do detect("/** */ var foo = 0.5;")[:value_type].should == "Number" detect("/** */ var foo = 0.5;")[:type].should == "Number" end it "string" do detect("/** */ var foo = 'haa';")[:value_type].should == "String" detect("/** */ var foo = 'haa';")[:type].should == "String" end it "true" do detect("/** */ var foo = true;")[:value_type].should == "Boolean" detect("/** */ var foo = true;")[:type].should == "Boolean" end it "false" do detect("/** */ var foo = false;")[:value_type].should == "Boolean" detect("/** */ var foo = false;")[:type].should == "Boolean" end it "array" do detect("/** */ var foo = [];")[:value_type].should == "Array" detect("/** */ var foo = [];")[:type].should == "Array" end it "object" do detect("/** */ var foo = {};")[:value_type].should == "Object" detect("/** */ var foo = {};")[:type].should == "Object" end end describe "no value type in" do it "uninitialized var declaration" do detect("/** */ var foo;")[:value_type].should == nil detect("/** */ var foo;")[:type].should == nil end end Loading spec/ast_spec.rb +1 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ require "jsduck/esprima_parser" describe JsDuck::Ast do def detect(string) node = JsDuck::EsprimaParser.new(string).parse[0] return JsDuck::Ast.new.detect(node[:code])[:type] return JsDuck::Ast.new.detect(node[:code])[:tagname] end describe "detects as class" do Loading Loading
lib/jsduck/ast.rb +4 −4 Original line number Diff line number Diff line Loading @@ -143,7 +143,7 @@ module JsDuck def make_class(name, ast=nil) cls = { :type => :class, :tagname => :class, :name => name, } Loading Loading @@ -192,7 +192,7 @@ module JsDuck def make_method(name, ast=nil) return { :type => :method, :tagname => :method, :name => name, :params => make_params(ast) } Loading @@ -208,9 +208,9 @@ module JsDuck def make_property(name=nil, ast=nil) return { :type => :property, :tagname => :property, :name => name, :value_type => make_value_type(ast) :type => make_value_type(ast) } end Loading
lib/jsduck/doc_type.rb +2 −2 Original line number Diff line number Diff line Loading @@ -25,13 +25,13 @@ module JsDuck elsif doc_map[:cfg] && doc_map[:cfg].length == 1 # When just one @cfg, avoid treating it as @class :cfg elsif code[:type] == :class elsif code[:tagname] == :class :class elsif code[:type] == :css_mixin :css_mixin elsif doc_map[:cfg] :cfg elsif code[:type] == :method elsif code[:tagname] == :method :method else :property Loading
spec/ast_property_spec.rb +9 −9 Original line number Diff line number Diff line Loading @@ -51,39 +51,39 @@ describe "JsDuck::Ast detects property with" do end end describe "value type in var initialized with" do describe "type in var initialized with" do it "int" do detect("/** */ var foo = 5;")[:value_type].should == "Number" detect("/** */ var foo = 5;")[:type].should == "Number" end it "float" do detect("/** */ var foo = 0.5;")[:value_type].should == "Number" detect("/** */ var foo = 0.5;")[:type].should == "Number" end it "string" do detect("/** */ var foo = 'haa';")[:value_type].should == "String" detect("/** */ var foo = 'haa';")[:type].should == "String" end it "true" do detect("/** */ var foo = true;")[:value_type].should == "Boolean" detect("/** */ var foo = true;")[:type].should == "Boolean" end it "false" do detect("/** */ var foo = false;")[:value_type].should == "Boolean" detect("/** */ var foo = false;")[:type].should == "Boolean" end it "array" do detect("/** */ var foo = [];")[:value_type].should == "Array" detect("/** */ var foo = [];")[:type].should == "Array" end it "object" do detect("/** */ var foo = {};")[:value_type].should == "Object" detect("/** */ var foo = {};")[:type].should == "Object" end end describe "no value type in" do it "uninitialized var declaration" do detect("/** */ var foo;")[:value_type].should == nil detect("/** */ var foo;")[:type].should == nil end end Loading
spec/ast_spec.rb +1 −1 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ require "jsduck/esprima_parser" describe JsDuck::Ast do def detect(string) node = JsDuck::EsprimaParser.new(string).parse[0] return JsDuck::Ast.new.detect(node[:code])[:type] return JsDuck::Ast.new.detect(node[:code])[:tagname] end describe "detects as class" do Loading