Sha256: 5a60465afe0ec0e2b7819c447e54a4947b4090ee9ad3a3e39b23cdb3a4f8d222

Contents?: true

Size: 771 Bytes

Versions: 2

Compression:

Stored size: 771 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
    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
    else
      klass = params.first.source
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

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