Commit d58b74ec authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Support multiple xtypes.

Class config now has "xtypes" property which is always array.
parent 612e748d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ module JsDuck
      [:extends, :xtype, :singleton, :private].each do |tag|
        old[tag] = old[tag] || new[tag]
      end
      [:mixins, :alternateClassNames].each do |tag|
      [:mixins, :alternateClassNames, :xtypes].each do |tag|
        old[tag] = old[tag] + new[tag]
      end
      old[:doc] = old[:doc].length > 0 ? old[:doc] : new[:doc]
+3 −3
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ module JsDuck
        :extends => detect_extends(doc_map, code),
        :mixins => detect_list(:mixins, doc_map, code),
        :alternateClassNames => detect_list(:alternateClassNames, doc_map, code),
        :xtype => detect_xtype(doc_map),
        :xtypes => detect_xtypes(doc_map),
        :author => detect_author(doc_map),
        :docauthor => detect_docauthor(doc_map),
        :singleton => !!doc_map[:singleton],
@@ -273,8 +273,8 @@ module JsDuck
      end
    end

    def detect_xtype(doc_map)
      doc_map[:xtype] ? doc_map[:xtype].first[:name] : nil
    def detect_xtypes(doc_map)
      doc_map[:xtype] ? doc_map[:xtype].map {|tag| tag[:name] } : []
    end

    def detect_author(doc_map)
+24 −6
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ describe JsDuck::Aggregator do
      @doc[:singleton].should == true
    end
    it "detects xtype" do
      @doc[:xtype].should == "nicely"
      @doc[:xtypes].should == ["nicely"]
    end
  end

@@ -115,6 +115,24 @@ describe JsDuck::Aggregator do
    end
  end

  describe "class with multiple @xtypes" do
    before do
      @doc = parse(<<-EOS)[0]
        /**
         * @class MyClass
         * @xtype foo
         * @xtype bar
         * Some documentation.
         */
      EOS
    end

    it_should_behave_like "class"
    it "collects all xtypes together" do
      @doc[:xtypes].should == ["foo", "bar"]
    end
  end

  describe "function after doc-comment" do
    before do
      @doc = parse("/** */ function MyClass() {}")[0]
@@ -283,7 +301,7 @@ describe JsDuck::Aggregator do

    it_should_behave_like "class"
    it "detects xtype" do
      @doc[:xtype].should == "nicely"
      @doc[:xtypes].should == ["nicely"]
    end
  end

@@ -464,10 +482,6 @@ describe JsDuck::Aggregator do
      @classes[0][:extends].should == "Bar"
    end

    it "takes @xtype from first doc-block that has one" do
      @classes[0][:xtype].should == "xfoo"
    end

    it "is singleton when one doc-block is singleton" do
      @classes[0][:singleton].should == true
    end
@@ -476,6 +490,10 @@ describe JsDuck::Aggregator do
      @classes[0][:private].should == true
    end

    it "combines all @xtypes" do
      @classes[0][:xtypes].length.should == 2
    end

    it "combines all configs" do
      @classes[0][:cfg].length.should == 3
    end
+2 −2
Original line number Diff line number Diff line
@@ -9,8 +9,8 @@ Ext.define('Docs.view.cls.Header', {
    tpl: Ext.create('Ext.XTemplate',
        '<h1 class="{[this.getClass(values)]}">',
            '<a href="source/{href}" target="_blank">{name}</a>',
            '<tpl if="xtype">',
                '<span>xtype: {xtype}</span>',
            '<tpl if="xtypes.length &gt; 0">',
                '<span>xtype: {[values.xtypes.join(", ")]}</span>',
            '</tpl>',
        '</h1>',
        {