зеркало из https://github.com/github/ruby.git
[ruby/irb] Add show_doc as an alias to the help command
(https://github.com/ruby/irb/pull/475) In the long-term, we want to align with `Pry`, `byebug` and `debug` to use the `help` command to list all commands, which is what `show_cmds` currently does. And `show_doc` will be the command to look up Ruby APIs. By aliasing `show_doc` to the current `help` now, users will have time to get use to it.
This commit is contained in:
Родитель
12b7c129bf
Коммит
c9076d546a
|
@ -162,6 +162,7 @@ module IRB # :nodoc:
|
||||||
|
|
||||||
[
|
[
|
||||||
:irb_help, :Help, "cmd/help",
|
:irb_help, :Help, "cmd/help",
|
||||||
|
[:show_doc, NO_OVERRIDE],
|
||||||
[:help, NO_OVERRIDE],
|
[:help, NO_OVERRIDE],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -376,16 +376,18 @@ module TestIRB
|
||||||
assert_match(/Please specify the file name./, out)
|
assert_match(/Please specify the file name./, out)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_help
|
def test_help_and_show_doc
|
||||||
|
["help", "show_doc"].each do |cmd|
|
||||||
out, _ = execute_lines(
|
out, _ = execute_lines(
|
||||||
"help 'String#gsub'\n",
|
"#{cmd} 'String#gsub'\n",
|
||||||
"\n",
|
"\n",
|
||||||
)
|
)
|
||||||
|
|
||||||
# the former is what we'd get without document content installed, like on CI
|
# the former is what we'd get without document content installed, like on CI
|
||||||
# the latter is what we may get locally
|
# the latter is what we may get locally
|
||||||
possible_rdoc_output = [/Nothing known about String#gsub/, /Returns a copy of self with all occurrences of the given pattern/]
|
possible_rdoc_output = [/Nothing known about String#gsub/, /Returns a copy of self with all occurrences of the given pattern/]
|
||||||
assert(possible_rdoc_output.any? { |output| output.match?(out) }, "Expect the help command to match one of the possible outputs")
|
assert(possible_rdoc_output.any? { |output| output.match?(out) }, "Expect the `#{cmd}` command to match one of the possible outputs")
|
||||||
|
end
|
||||||
ensure
|
ensure
|
||||||
# this is the only way to reset the redefined method without coupling the test with its implementation
|
# this is the only way to reset the redefined method without coupling the test with its implementation
|
||||||
EnvUtil.suppress_warning { load "irb/cmd/help.rb" }
|
EnvUtil.suppress_warning { load "irb/cmd/help.rb" }
|
||||||
|
|
Загрузка…
Ссылка в новой задаче