Skip to content

Commit 3f79cb5

Browse files
committed
Add --extra-doc-dir option to show doc dialog
1 parent 6330601 commit 3f79cb5

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

lib/irb/context.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ def initialize(irb, workspace = nil, input_method = nil)
125125
end
126126
self.save_history = IRB.conf[:SAVE_HISTORY] if IRB.conf[:SAVE_HISTORY]
127127

128+
@extra_doc_dirs = IRB.conf[:EXTRA_DOC_DIRS]
129+
128130
@echo = IRB.conf[:ECHO]
129131
if @echo.nil?
130132
@echo = true
@@ -241,6 +243,9 @@ def main
241243
#
242244
# If set to +false+, <code>^D</code> will quit irb.
243245
attr_accessor :ignore_eof
246+
# Specify the installation locations of the ri file to be displayed in the
247+
# document dialog.
248+
attr_accessor :extra_doc_dirs
244249
# Whether to echo the return value to output or not.
245250
#
246251
# Uses <code>IRB.conf[:ECHO]</code> if available, or defaults to +true+.

lib/irb/init.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def IRB.init_config(ap_path)
5151
@CONF[:USE_LOADER] = false
5252
@CONF[:IGNORE_SIGINT] = true
5353
@CONF[:IGNORE_EOF] = false
54+
@CONF[:EXTRA_DOC_DIRS] = []
5455
@CONF[:ECHO] = nil
5556
@CONF[:ECHO_ON_ASSIGNMENT] = nil
5657
@CONF[:VERBOSE] = nil
@@ -257,6 +258,9 @@ def IRB.parse_opts(argv: ::ARGV)
257258
@CONF[:USE_MULTILINE] = true
258259
when "--nomultiline", "--noreidline"
259260
@CONF[:USE_MULTILINE] = false
261+
when /^--extra-doc-dir(?:=(.+))?/
262+
opt = $1 || argv.shift
263+
@CONF[:EXTRA_DOC_DIRS] << opt
260264
when "--echo"
261265
@CONF[:ECHO] = true
262266
when "--noecho"

lib/irb/input-method.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,9 @@ def auto_indent(&block)
329329
name = result[pointer]
330330
name = IRB::InputCompletor.retrieve_completion_data(name, doc_namespace: true)
331331

332-
driver = RDoc::RI::Driver.new
332+
options = {}
333+
options[:extra_doc_dirs] = IRB.conf[:EXTRA_DOC_DIRS] unless IRB.conf[:EXTRA_DOC_DIRS].empty?
334+
driver = RDoc::RI::Driver.new(options)
333335

334336
if key.match?(dialog.name)
335337
begin

0 commit comments

Comments
 (0)