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

commands/show_info: fix formatting error for C method header

Fixes #2006 (show-source formatting bug in From)

In order to test this I had to build Pry from master locally and install
it. When I ran `String#initialize` I saw an error that `has_pry_doc` is
undefined on the Config class. This makes sense. This option is defined in the
pry-doc plugin.

As a workaround, I had to change the check to `defined?`. However, in the
future, we should make Pry plugin-agnostic - strictly no plugin checks in the
code.
This commit is contained in:
Kyrylo Silin 2019-05-02 23:36:00 +03:00
parent ed45fb3087
commit 61fa19b1f0
2 changed files with 2 additions and 2 deletions

View file

@ -139,7 +139,7 @@ class Pry
def method_header(code_object, line_num)
h = ""
h << (code_object.c_method? ? "(C Method):" : ":#{line_num}:")
h << (code_object.c_method? ? ' (C Method):' : ":#{line_num}:")
h << method_sections(code_object)[:owner]
h << method_sections(code_object)[:visibility]
h << method_sections(code_object)[:signature]

View file

@ -514,7 +514,7 @@ class Pry
# @return [YARD::CodeObjects::MethodObject]
# @raise [CommandError] when the method can't be found or `pry-doc` isn't installed.
def pry_doc_info
if Pry.config.has_pry_doc
if defined?(PryDoc)
Pry::MethodInfo.info_for(@method) ||
raise(
CommandError,