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

Don't rename constructor method when exporting.

Handle the renaming in UI.  This way we can more easily check for
which method is the constructor as we can just check if name equals
"constructor".

This also fixes the bug of inherited constructors not having "new"
in front of them.
parent b975984b
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -68,8 +68,7 @@ module JsDuck
    # Returns array of all public members of particular type in a class,
    # sorted by name.
    #
    # For methods the the constructor is listed as first method having
    # the same name as class itself.
    # For methods the the constructor is listed first.
    #
    # See members_hash for details.
    def members(type)
@@ -83,11 +82,7 @@ module JsDuck
      constr = ms.find {|m| m[:name] == "constructor" }
      if constr
        ms.delete(constr)
        # Clone it.  Otherwise the search for "constructor" from this
        # class will return nothing as we have renamed it.
        constr2 = constr.clone
        constr2[:name] = short_name
        ms.unshift(constr2)
        ms.unshift(constr)
      end
      ms
    end
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ describe JsDuck::Class do

    it "returns constructor as first method" do
      ms = @child.members(:method)
      ms.first[:name].should == "ChildClass"
      ms.first[:name].should == "constructor"
    end
  end

+2 −1
Original line number Diff line number Diff line
@@ -220,8 +220,9 @@ Ext.define('Docs.view.cls.Overview', {
        var cfg = Ext.apply({}, member);
        cfg.expandable = member.shortDoc ? "expandable" : "not-expandable";

        if (member.tagname === "method" && member.name === member.owner.replace(/^.*\./, "")) {
        if (member.tagname === "method" && member.name === "constructor") {
            cfg.before = "<strong class='constructor-signature'>new</strong>";
            cfg.name = this.docClass.name;
        }

        if (member.tagname === "cfg" || member.tagname === "property") {
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ Ext.define('Docs.view.cls.Toolbar', {
        return {
            cls: cls,
            url: member ? cls+"-"+member.tagname+"-"+member.name : cls,
            label: member ? member.name : cls,
            label: member ? ((member.name === "constructor") ? cls : member.name) : cls,
            inherited: member ? member.owner !== cls : false
        };
    },