1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Don't reinvent comment_describing in Pry::Method

This commit is contained in:
Conrad Irwin 2013-05-10 00:22:49 -07:00
parent ed52bfdb74
commit 54cb0f369b

View file

@ -295,10 +295,8 @@ class Pry
when :ruby when :ruby
if rbx? && !pry_method? if rbx? && !pry_method?
get_comment_content(core_doc) get_comment_content(core_doc)
elsif pry_method?
get_comment_content(doc_for_pry_method)
else else
get_comment_content(@method.comment) get_comment_content(comment)
end end
end end
end end
@ -476,6 +474,10 @@ class Pry
@method.send(method_name, *args, &block) @method.send(method_name, *args, &block)
end end
def comment
Pry::Code.from_file(source_file).comment_describing(source_line)
end
private private
# @return [YARD::CodeObjects::MethodObject] # @return [YARD::CodeObjects::MethodObject]
@ -492,24 +494,6 @@ class Pry
end end
end end
# FIXME: a very similar method to this exists on WrappedModule: extract_doc_for_candidate
def doc_for_pry_method
_, line_num = source_location
buffer = ""
Pry.line_buffer[0..(line_num - 1)].each do |line|
# Add any line that is a valid ruby comment,
# but clear as soon as we hit a non comment line.
if (line =~ /^\s*#/) || (line =~ /^\s*$/)
buffer << line.lstrip
else
buffer.replace("")
end
end
buffer
end
# @param [Class, Module] ancestors The ancestors to investigate # @param [Class, Module] ancestors The ancestors to investigate
# @return [Method] The unwrapped super-method # @return [Method] The unwrapped super-method
def super_using_ancestors(ancestors, times=1) def super_using_ancestors(ancestors, times=1)