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

Allow links to private members.

Remove an old restriction left over from the days when JSDuck didn't
show private members at all.
parent eeb476fe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ module JsDuck
      end

      def get_matching_member(cls, query)
        ms = find_members(cls, query).find_all {|m| !m[:private] }
        ms = find_members(cls, query)
        if ms.length > 1
          instance_ms = ms.find_all {|m| !m[:meta][:static] }
          instance_ms.length > 0 ? instance_ms[0] : ms.find_all {|m| m[:meta][:static] }[0]
+13 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ describe JsDuck::DocFormatter do
          {:tagname => :cfg, :name => "bar", :id => "cfg-bar"},
          {:tagname => :method, :name => "id", :id => "static-method-id",
            :meta => {:static => true}},
          {:tagname => :method, :name => "privMeth", :id => "method-privMeth", :private => true},
        ],
        :alternateClassNames => ["FooBar"]
      }),
@@ -51,6 +52,11 @@ describe JsDuck::DocFormatter do
        'Look at <a href="Foo#static-method-id">Foo.id</a>'
    end

    it "replaces {@link Foo#privMeth} with link to private class member" do
      @formatter.replace("Look at {@link Foo#privMeth}").should ==
        'Look at <a href="Foo#method-privMeth">Foo.privMeth</a>'
    end

    it "uses context to replace {@link #bar} with link to class member" do
      @formatter.replace("Look at {@link #bar}").should ==
        'Look at <a href="Context#method-bar">bar</a>'
@@ -151,7 +157,8 @@ describe JsDuck::DocFormatter do
          JsDuck::Class.new({
            :name => "Context",
            :members => [
              {:tagname => :method, :name => "bar", :id => "method-bar"}
              {:tagname => :method, :name => "bar", :id => "method-bar"},
              {:tagname => :method, :name => "privMeth", :id => "method-privMeth", :private => true},
            ]
          }),
        ])
@@ -234,6 +241,11 @@ describe JsDuck::DocFormatter do
          'Look at <a href="Context#method-bar">bar</a> method'
      end

      it "converts #privMeth to link to private method" do
        @formatter.replace("Look at #privMeth method").should ==
          'Look at <a href="Context#method-privMeth">privMeth</a> method'
      end

      it "Doesn't convert #unknown to link" do
        @formatter.replace("Ahh, an #unknown method").should ==
          'Ahh, an #unknown method'