summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStan Lo <[email protected]>2024-02-25 23:22:30 +0800
committergit <[email protected]>2024-02-25 15:22:33 +0000
commitc976cb52a2594e9eb147df126617d430766c9d18 (patch)
treee6f50c11f30117720e95b0b7d7cde2ca0a9fcd20 /lib
parent898f30f8bd064c9803625c98a3e46bd3434ff1bb (diff)
[ruby/irb] Add help messages to `show_source` and `show_doc`
commands (https://github.com/ruby/irb/pull/887) * Add help message to the show_source command * Add help message to the show_doc command https://github.com/ruby/irb/commit/06f43aadb3
Diffstat (limited to 'lib')
-rw-r--r--lib/irb/command/show_doc.rb16
-rw-r--r--lib/irb/command/show_source.rb16
2 files changed, 30 insertions, 2 deletions
diff --git a/lib/irb/command/show_doc.rb b/lib/irb/command/show_doc.rb
index dca10ec4be..4dde28bee9 100644
--- a/lib/irb/command/show_doc.rb
+++ b/lib/irb/command/show_doc.rb
@@ -15,7 +15,21 @@ module IRB
end
category "Context"
- description "Enter the mode to look up RI documents."
+ description "Look up documentation with RI."
+
+ help_message <<~HELP_MESSAGE
+ Usage: show_doc [name]
+
+ When name is provided, IRB will look up the documentation for the given name.
+ When no name is provided, a RI session will be started.
+
+ Examples:
+
+ show_doc
+ show_doc Array
+ show_doc Array#each
+
+ HELP_MESSAGE
def execute(*names)
require 'rdoc/ri/driver'
diff --git a/lib/irb/command/show_source.rb b/lib/irb/command/show_source.rb
index cc783e7532..32bdf74d31 100644
--- a/lib/irb/command/show_source.rb
+++ b/lib/irb/command/show_source.rb
@@ -8,7 +8,21 @@ module IRB
module Command
class ShowSource < Base
category "Context"
- description "Show the source code of a given method or constant."
+ description "Show the source code of a given method, class/module, or constant."
+
+ help_message <<~HELP_MESSAGE
+ Usage: show_source [target] [-s]
+
+ -s Show the super method. You can stack it like `-ss` to show the super of the super, etc.
+
+ Examples:
+
+ show_source Foo
+ show_source Foo#bar
+ show_source Foo#bar -s
+ show_source Foo.baz
+ show_source Foo::BAR
+ HELP_MESSAGE
class << self
def transform_args(args)