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

Correctly handle autodetected private accessors.

Now generating accessors also propagates the :autodetected field,
which in turn is taken account by InheritDoc class.
parent 24d8b407
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ module JsDuck
        :owner => cfg[:owner],
        :files => cfg[:files],
        :private => cfg[:private],
        :autodetected => cfg[:autodetected],
        :meta => clone_meta(cfg),
      })
    end
+1 −0
Original line number Diff line number Diff line
@@ -245,6 +245,7 @@ module JsDuck
          docset[:code] = cfg
        else
          cfg[:inheritdoc] = {}
          cfg[:accessor] = true
          cfg[:autodetected] = true
          configs << cfg
        end
+4 −4
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ module JsDuck
      @relations.each do |cls|
        resolve_class(cls) if cls[:inheritdoc]
        cls.all_local_members.each do |member|
          if member[:inheritdoc]
          if member[:inheritdoc] || member[:autodetected]
            resolve(member)
          end
        end
@@ -27,7 +27,7 @@ module JsDuck
    def resolve(m)
      parent = find_parent(m)

      if parent
      if m[:inheritdoc] && parent
        m[:doc] = (m[:doc] + "\n\n" + parent[:doc]).strip
        m[:params] = parent[:params] if parent[:params]
        m[:return] = parent[:return] if parent[:return]
@@ -51,7 +51,7 @@ module JsDuck
    #
    # If the parent also has @inheritdoc, continues recursively.
    def find_parent(m)
      inherit = m[:inheritdoc]
      inherit = m[:inheritdoc] || {}
      if inherit[:cls]
        # @inheritdoc MyClass#member
        parent_cls = @relations[m[:inheritdoc][:cls]]
@@ -100,7 +100,7 @@ module JsDuck
    end

    def lookup_member(cls, m)
      inherit = m[:inheritdoc]
      inherit = m[:inheritdoc] || {}
      cls.get_members(inherit[:member] || m[:name], inherit[:type] || m[:tagname], inherit[:static] || m[:meta][:static])[0]
    end

+4 −0
Original line number Diff line number Diff line
@@ -36,6 +36,10 @@ describe JsDuck::Aggregator do
      cfg[0][:inheritdoc].should == {}
    end

    it "sets :accessor flag on config" do
      cfg[0][:accessor].should == true
    end

    it "sets :autodetected flag on config" do
      cfg[0][:autodetected].should == true
    end