Commit 8a25ee65 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Add "static-" to ID-s of static members.

So normal and static members with same name will have different ID-s.

This fixes several problems with handling of static members.
Most noticably hide-inherited hides all inherited members and
filtering also hides the static member if they don't match.
parent 32764d98
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -202,7 +202,10 @@ module JsDuck
      # Use the canonical class name for link (not some alternateClassName)
      cls = @relations[cls].full_name
      # prepend type name to member name
      member = member && (get_member(cls, member, type)[:tagname].to_s + "-" + member)
      if member
        m_tag = get_member(cls, member, type)
        member = (m_tag[:static] ? "static-" : "") + m_tag[:tagname].to_s + "-" + member
      end

      @link_tpl.gsub(/(%[\w#-])/) do
        case $1
+2 −2
Original line number Diff line number Diff line
@@ -168,7 +168,7 @@ module JsDuck
      inherited = owner == @cls[:name] ? "not-inherited" : "inherited"

      return [
        "<div id='#{m[:tagname]}-#{m[:name]}' class='member #{first_child} #{inherited}'>",
        "<div id='#{m[:static] ? 'static-' : ''}#{m[:tagname]}-#{m[:name]}' class='member #{first_child} #{inherited}'>",
          # leftmost column: expand button
          "<a href='#' class='side #{expandable}'>",
            "<span>&nbsp;</span>",
@@ -232,7 +232,7 @@ module JsDuck
        after += "<strong class='template-signature'>template</strong>"
      end

      uri = "#!/api/#{m[:owner]}-#{m[:tagname]}-#{m[:name]}"
      uri = "#!/api/#{m[:owner]}#{m[:static]?'-static':''}-#{m[:tagname]}-#{m[:name]}"

      return [
        before,
+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ module JsDuck
      else
        # when creation of global class is skipped,
        # this owner property can be nil.
        (doc[:owner] || "global").gsub(/\./, '-') + "-" + doc[:tagname].to_s + "-" + doc[:name]
        (doc[:owner] || "global").gsub(/\./, '-') + (doc[:static] ? "-static" : "") + "-" + doc[:tagname].to_s + "-" + doc[:name]
      end
    end

+4 −4
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ describe JsDuck::DocFormatter do
          :method => [{:name => "bar", :tagname => :method}]
        },
        :statics => {
          :method => [{:name => "id", :tagname => :method}],
          :method => [{:name => "id", :tagname => :method, :static => true}],
        },
      }),
      JsDuck::Class.new({
@@ -25,7 +25,7 @@ describe JsDuck::DocFormatter do
          :cfg => [{:name => "bar", :tagname => :cfg}],
        },
        :statics => {
          :method => [{:name => "id", :tagname => :method}],
          :method => [{:name => "id", :tagname => :method, :static => true}],
        },
        :alternateClassNames => ["FooBar"]
      }),
@@ -48,7 +48,7 @@ describe JsDuck::DocFormatter do

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

    it "uses context to replace {@link #bar} with link to class member" do
@@ -58,7 +58,7 @@ describe JsDuck::DocFormatter do

    it "uses context to replace {@link #id} with link to static class member" do
      @formatter.replace("Look at {@link #id}").should ==
        'Look at <a href="Context#method-id">id</a>'
        'Look at <a href="Context#static-method-id">id</a>'
    end

    it "allows use of custom link text" do
+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ Ext.define('Docs.view.cls.Overview', {
        // and hide inherited members if hideInherited=true
        var re = new RegExp(Ext.String.escapeRegex(search), "i");
        this.eachMember(function(m) {
            var el = Ext.get(m.tagname + "-" + m.name);
            var el = Ext.get((m['static'] ? "static-" : "") + m.tagname + "-" + m.name);
            var byInheritance = !hideInherited || (m.owner === this.docClass.name);
            var byFilter = !isSearch || re.test(m.name);
            if (byInheritance && byFilter) {
Loading