Sha256: a71cf142b2f84f0da5612b2532de31b446fa15de7f7f3f5f73d8e1426c28d140

Contents?: true

Size: 827 Bytes

Versions: 46

Compression:

Stored size: 827 Bytes

Contents

# Handles 'raise' calls inside methods
class YARD::Handlers::Ruby::ExceptionHandler < YARD::Handlers::Ruby::Base
  handles method_call(:raise)

  process do
    return unless owner.is_a?(MethodObject) # Only methods yield
    return if [:command_call, :call].include? statement.type
    return if owner.has_tag?(:raise)

    klass = nil
    if statement.call?
      params = statement.parameters(false)
      if params.size == 1
        if params.first.ref? && params.first.first.type != :ident
          klass = params.first.source
        elsif params.first.call? && params.first.method_name(true) == :new
          klass = params.first.namespace.source
        end
      elsif params.size > 1
        klass = params.first.source
      end
    end

    owner.add_tag YARD::Tags::Tag.new(:raise, '', klass) if klass
  end
end

Version data entries

46 entries across 39 versions & 7 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/yard-0.9.2/lib/yard/handlers/ruby/exception_handler.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.1/lib/yard/handlers/ruby/exception_handler.rb
yard-0.9.5 lib/yard/handlers/ruby/exception_handler.rb
yard-0.9.4 lib/yard/handlers/ruby/exception_handler.rb
yard-0.9.3 lib/yard/handlers/ruby/exception_handler.rb
yard-0.9.2 lib/yard/handlers/ruby/exception_handler.rb
yard-0.9.1 lib/yard/handlers/ruby/exception_handler.rb
yard-0.9.0 lib/yard/handlers/ruby/exception_handler.rb
yard-0.8.7.6 lib/yard/handlers/ruby/exception_handler.rb
yard-0.8.7.5 lib/yard/handlers/ruby/exception_handler.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/exception_handler.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/exception_handler.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/exception_handler.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/exception_handler.rb
yard-0.8.7.4 lib/yard/handlers/ruby/exception_handler.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/exception_handler.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/exception_handler.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/exception_handler.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/exception_handler.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/exception_handler.rb