class Docks::Languages::JavaScript

Public Class Methods

extensions() click to toggle source
# File lib/docks/languages/javascript_language.rb, line 10
def self.extensions; %w(js) end
symbol_sources() click to toggle source
# File lib/docks/languages/javascript_language.rb, line 11
def self.symbol_sources; [SymbolSources::JQuery, SymbolSources::MDN] end
type() click to toggle source
# File lib/docks/languages/javascript_language.rb, line 9
def self.type; Docks::Types::Languages::SCRIPT end

Public Instance Methods

parser() click to toggle source
# File lib/docks/languages/javascript_language.rb, line 13
def parser; Docks::Parsers::JavaScript.instance end
signature_for(symbol) click to toggle source
# File lib/docks/languages/javascript_language.rb, line 15
def signature_for(symbol)
  return unless [Types::Symbol::MIXIN, Types::Symbol::FUNCTION, Types::Symbol::FACTORY, Types::Symbol::CLASS].include?(symbol.symbol_type)
  params = symbol.fetch(:params, []).map do |param|
    text = ""
    text << "[" if param.optional
    text << param.name
    text << " = #{param.default}" if param.default
    text << "]" if param.optional
    text
  end

  presentation = if symbol.respond_to?(:method?) && symbol.method?
    if symbol.static?
      "#{symbol.for}.#{symbol.name} = function"
    elsif symbol.belongs_to.instance_of?(Containers::Klass)
      "#{symbol.for}.prototype.#{symbol.name} = function"
    else
      "#{symbol.name}: function"
    end
  else
    "function #{symbol.name}"
  end

  "#{presentation}(#{params.join(", ")}) { /* ... */ }"
end