From 4ff7a9c9232daec25512bdbb70844221c13ca62f Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 25 Feb 2024 15:49:31 +0800 Subject: [PATCH 1/2] Add help message to the show_source command --- lib/irb/command/show_source.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/irb/command/show_source.rb b/lib/irb/command/show_source.rb index cc783e753..32bdf74d3 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) From 9457335daa6deef653ef236f448ec1d997ef082e Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 25 Feb 2024 15:58:28 +0800 Subject: [PATCH 2/2] Add help message to the show_doc command --- lib/irb/command/show_doc.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/irb/command/show_doc.rb b/lib/irb/command/show_doc.rb index dca10ec4b..4dde28bee 100644 --- a/lib/irb/command/show_doc.rb +++ b/lib/irb/command/show_doc.rb @@ -15,7 +15,21 @@ def transform_args(args) 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'