Class: Docks::Languages::CoffeeScript

Inherits:
Base
  • Object
show all
Defined in:
lib/docks/languages/coffeescript_language.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#load_stub, #renderer, symbol_sources

Class Method Details

.extensionsObject



8
# File 'lib/docks/languages/coffeescript_language.rb', line 8

def self.extensions; %w(coffee coffeescript) end

.typeObject



7
# File 'lib/docks/languages/coffeescript_language.rb', line 7

def self.type; Docks::Types::Languages::SCRIPT end

Instance Method Details

#parserObject



10
# File 'lib/docks/languages/coffeescript_language.rb', line 10

def parser; Docks::Parsers::CoffeeScript.instance end

#signature_for(symbol) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/docks/languages/coffeescript_language.rb', line 12

def signature_for(symbol)
  is_class = symbol.symbol_type == Types::Symbol::CLASS
  return unless is_class || [Types::Symbol::MIXIN, Types::Symbol::FUNCTION, Types::Symbol::FACTORY].include?(symbol.symbol_type)
  params = symbol.fetch(:params, [])

  presentation = if is_class
    "class #{symbol.name}\n  constructor: "
  elsif symbol.respond_to?(:method?) && symbol.method?
    symbol.static? ? "#{symbol.for}.#{symbol.name} = " : "#{symbol.name}: "
  else
    "#{symbol.name} = "
  end

  presentation << "(#{params.map { |param| "#{param.name}#{" = #{param.default}" if param.default}" }.join(", ")}) " unless params.empty?
  "#{presentation}-> # ..."
end