Commit 4c2cdec7 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Optional method parameters rendered in brackets.

parent 60771499
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -47,10 +47,22 @@ module JsDuck

    # Creates parameter list used in method and event signature.
    def short_param_list(item)
      if item[:params].length == 0
        return "()"
      end

      params = item[:params].collect do |p|
        (p[:type] || "Object") + " " + (p[:name] || "")
        type = p[:type] || "Object"
        name = p[:name] || ""
        str = "<code>#{type} #{name}</code>"
        if p[:doc] =~ /\(optional\)/
          "<span title='Optional' class='optional'>[" + str + "]</span>"
        else
          str
        end
      return params.length > 0 ? ("( " + params.join(", ") + " )") : "()"
      end

      return "( " + params.join(", ") + " )"
    end

    # 116 chars is also where ext-doc makes its cut, but unlike