Commit 98167cd5 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Simplify how Ast class lists auto-detected members.

Just add all kinds of members to :members array.  This simplifies and
future-proofs the ClassDocGrouper which expands all these members into
separate docsets.
parent 15bb57f3
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -195,8 +195,7 @@ module JsDuck
          cls[:singleton] = make_singleton(cfg["singleton"])
          cls[:aliases] = make_string_list(cfg["alias"])
          cls[:aliases] += make_string_list(cfg["xtype"]).map {|xtype| "widget."+xtype }
          cls[:members] = {}
          cls[:members][:cfg] = make_configs(cfg["config"])
          cls[:members] = make_configs(cfg["config"])
        end
      end

@@ -233,7 +232,7 @@ module JsDuck
    end

    def make_configs(ast)
      return [] unless ast && ast["type"] == "ObjectExpression"
      return nil unless ast && ast["type"] == "ObjectExpression"

      configs = []

+8 −10
Original line number Diff line number Diff line
@@ -77,8 +77,7 @@ module JsDuck

      # Turn all auto-detected members into separate docsets
      if docset[:code] && docset[:code][:members]
        docset[:code][:members].each_pair do |type, members|
          members.each do |m|
        docset[:code][:members].each do |m|
          results << {
            :tagname => m[:tagname],
            :type => :no_comment,
@@ -88,7 +87,6 @@ module JsDuck
          }
        end
      end
      end

      results
    end
+7 −13
Original line number Diff line number Diff line
@@ -20,27 +20,21 @@ describe "JsDuck::Ast detecting" do
      EOS
    end

    it "adds :members as hash" do
      members.should be_kind_of(Hash)
    it "adds :members as array" do
      members.should be_kind_of(Array)
    end

    let(:cfg) { members[:cfg] }

    it "finds :cfg as array" do
      cfg.should be_kind_of(Array)
    end

    it "finds two cfgs with :cfg tagname" do
      cfg[0][:tagname].should == :cfg
      cfg[1][:tagname].should == :cfg
    it "finds two cfgs" do
      members[0][:tagname].should == :cfg
      members[1][:tagname].should == :cfg
    end

    it "finds cfg foo" do
      cfg[0][:name].should == "foo"
      members[0][:name].should == "foo"
    end

    it "finds cfg bar" do
      cfg[1][:name].should == "bar"
      members[1][:name].should == "bar"
    end
  end