Loading lib/jsduck/doc_ast.rb +2 −1 Original line number Diff line number Diff line Loading @@ -257,9 +257,10 @@ module JsDuck end def detect_return(doc_map) has_return_tag = !!extract(doc_map, :return) ret = extract(doc_map, :return) || {} return { :type => ret[:type] || "undefined", :type => ret[:type] || (has_return_tag ? "Object" : "undefined"), :name => ret[:name] || "return", :doc => ret[:doc] || "", :properties => doc_map[:return] ? detect_subproperties(:return, doc_map[:return]) : [] Loading lib/jsduck/return_values.rb +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ module JsDuck end def add_return_new(m) if m[:return][:type] == "undefined" if m[:return][:type] == "undefined" || m[:return][:type] == "Object" # Create a whole new :return hash. # If we were to just change the :type field it would modify # the type of all the inherited constructor docs. Loading spec/aggregator_return_spec.rb +18 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,24 @@ describe JsDuck::Aggregator do end end describe "method with @return that has no type" do before do @doc = parse(<<-EOS)[0] /** * Some function * @return Some value. */ function foo() {} EOS end it "defaults return type to Object" do @doc[:return][:type].should == "Object" end it "recognizes documentation of return value" do @doc[:return][:doc].should == "Some value." end end shared_examples_for "has return" do it "detects return type" do @doc[:return][:type].should == "String" Loading Loading
lib/jsduck/doc_ast.rb +2 −1 Original line number Diff line number Diff line Loading @@ -257,9 +257,10 @@ module JsDuck end def detect_return(doc_map) has_return_tag = !!extract(doc_map, :return) ret = extract(doc_map, :return) || {} return { :type => ret[:type] || "undefined", :type => ret[:type] || (has_return_tag ? "Object" : "undefined"), :name => ret[:name] || "return", :doc => ret[:doc] || "", :properties => doc_map[:return] ? detect_subproperties(:return, doc_map[:return]) : [] Loading
lib/jsduck/return_values.rb +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ module JsDuck end def add_return_new(m) if m[:return][:type] == "undefined" if m[:return][:type] == "undefined" || m[:return][:type] == "Object" # Create a whole new :return hash. # If we were to just change the :type field it would modify # the type of all the inherited constructor docs. Loading
spec/aggregator_return_spec.rb +18 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,24 @@ describe JsDuck::Aggregator do end end describe "method with @return that has no type" do before do @doc = parse(<<-EOS)[0] /** * Some function * @return Some value. */ function foo() {} EOS end it "defaults return type to Object" do @doc[:return][:type].should == "Object" end it "recognizes documentation of return value" do @doc[:return][:doc].should == "Some value." end end shared_examples_for "has return" do it "detects return type" do @doc[:return][:type].should == "String" Loading