Sha256: b730195d224ad1aa6c78853666c4afeed07d691a3e4d6f64195410f35baf5728

Contents?: true

Size: 732 Bytes

Versions: 5

Compression:

Stored size: 732 Bytes

Contents

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

5 entries across 5 versions & 1 rubygems

Version Path
yard-0.5.8 lib/yard/handlers/ruby/exception_handler.rb
yard-0.5.7 lib/yard/handlers/ruby/exception_handler.rb
yard-0.5.6 lib/yard/handlers/ruby/exception_handler.rb
yard-0.5.5 lib/yard/handlers/ruby/exception_handler.rb
yard-0.5.4 lib/yard/handlers/ruby/exception_handler.rb