Sha256: 4f6d497eb3f92b809c3f4e77b3a2e7e8486bfc5946135d3cbe0b6f03666e6afb

Contents?: true

Size: 801 Bytes

Versions: 2

Compression:

Stored size: 801 Bytes

Contents

# (see Ruby::MixinHandler)
class YARD::Handlers::Ruby::Legacy::MixinHandler < YARD::Handlers::Ruby::Legacy::Base
  handles /\Ainclude(\s|\()/
  
  process do
    statement.tokens[1..-1].to_s.split(/\s*,\s*/).each do |mixin|
      process_mixin(mixin.strip)
    end
  end

  private

  def process_mixin(mixin)
    unless mixmatch = mixin[/\A(#{NAMESPACEMATCH})/, 1]
      raise YARD::Parser::UndocumentableError, "mixin #{mixin} for class #{namespace.path}"
    end

    obj = Proxy.new(namespace, mixmatch)
    
    case obj
    when Proxy
      obj.type = :module
    when ConstantObject # If a constant is included, use its value as the real object
      obj = Proxy.new(namespace, obj.value)
    end

    namespace.mixins(scope).unshift(obj) unless namespace.mixins(scope).include?(obj)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yard-0.6.1 lib/yard/handlers/ruby/legacy/mixin_handler.rb
yard-0.6.0 lib/yard/handlers/ruby/legacy/mixin_handler.rb