diff --git a/lib/jsduck/inline/link.rb b/lib/jsduck/inline/link.rb index d125f100c6e472767c0d2fcee50344edd21abd4c..33179fc5434ce3f29f9ab7a29c7cab047c10a6db 100644 --- a/lib/jsduck/inline/link.rb +++ b/lib/jsduck/inline/link.rb @@ -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] diff --git a/spec/doc_formatter_spec.rb b/spec/doc_formatter_spec.rb index af0557dae04aea1b380121e6377659beb20d7609..3feab1ec8a2e2f81a41c5cc3364122a6e5674359 100644 --- a/spec/doc_formatter_spec.rb +++ b/spec/doc_formatter_spec.rb @@ -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 Foo.id' end + it "replaces {@link Foo#privMeth} with link to private class member" do + @formatter.replace("Look at {@link Foo#privMeth}").should == + 'Look at Foo.privMeth' + end + it "uses context to replace {@link #bar} with link to class member" do @formatter.replace("Look at {@link #bar}").should == 'Look at bar' @@ -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 bar method' end + it "converts #privMeth to link to private method" do + @formatter.replace("Look at #privMeth method").should == + 'Look at privMeth method' + end + it "Doesn't convert #unknown to link" do @formatter.replace("Ahh, an #unknown method").should == 'Ahh, an #unknown method'