Sha256: acb81c3e6ea5c3bd78c890828eeba19750b6b57f7035a69ec188bfe6586e0120

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'jsduck/table'
require 'jsduck/short_params'
require 'jsduck/long_params'

module JsDuck

  class MethodTable < Table
    def initialize(cls, cache={})
      super(cls, cache)
      @type = :method
      @id = @cls.full_name + "-methods"
      @title = "Public Methods"
      @column_title = "Method"
      @row_class = "method-row"
      @short_params = ShortParams.new
      @long_params = LongParams.new(@cls)
    end

    def signature_suffix(item)
      @short_params.render(item[:params]) + " : " + item[:return][:type]
    end

    def extra_doc(item)
      [
        "<div class='mdetail-params'>",
        "<strong>Parameters:</strong>",
        @long_params.render(item[:params]),
        "<strong>Returns:</strong>",
        render_return(item),
        "</div>"
      ].join("\n")
    end

    def render_return(item)
      type = item[:return][:type]
      doc = item[:return][:doc]
      if type == "void" && doc.length == 0
        "<ul><li>void</li></ul>"
      else
        "<ul><li><code>#{type}</code><div class='sub-desc'>#{doc}</div></li></ul>"
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jsduck-0.4 lib/jsduck/method_table.rb
jsduck-0.3 lib/jsduck/method_table.rb