Skip to content

Commit 06f43aa

Browse files
authored
Add help messages to show_source and show_doc commands (#887)
* Add help message to the show_source command * Add help message to the show_doc command
1 parent 7b323ee commit 06f43aa

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

lib/irb/command/show_doc.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,21 @@ def transform_args(args)
1515
end
1616

1717
category "Context"
18-
description "Enter the mode to look up RI documents."
18+
description "Look up documentation with RI."
19+
20+
help_message <<~HELP_MESSAGE
21+
Usage: show_doc [name]
22+
23+
When name is provided, IRB will look up the documentation for the given name.
24+
When no name is provided, a RI session will be started.
25+
26+
Examples:
27+
28+
show_doc
29+
show_doc Array
30+
show_doc Array#each
31+
32+
HELP_MESSAGE
1933

2034
def execute(*names)
2135
require 'rdoc/ri/driver'

lib/irb/command/show_source.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,21 @@ module IRB
88
module Command
99
class ShowSource < Base
1010
category "Context"
11-
description "Show the source code of a given method or constant."
11+
description "Show the source code of a given method, class/module, or constant."
12+
13+
help_message <<~HELP_MESSAGE
14+
Usage: show_source [target] [-s]
15+
16+
-s Show the super method. You can stack it like `-ss` to show the super of the super, etc.
17+
18+
Examples:
19+
20+
show_source Foo
21+
show_source Foo#bar
22+
show_source Foo#bar -s
23+
show_source Foo.baz
24+
show_source Foo::BAR
25+
HELP_MESSAGE
1226

1327
class << self
1428
def transform_args(args)

0 commit comments

Comments
 (0)