Skip to content

Commit

Permalink
[ruby/irb] Add --extra-doc-dir option to show doc dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta authored and matzbot committed Oct 11, 2021
1 parent dcaaf79 commit 866a09d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/irb/context.rb
Expand Up @@ -125,6 +125,8 @@ def initialize(irb, workspace = nil, input_method = nil)
end
self.save_history = IRB.conf[:SAVE_HISTORY] if IRB.conf[:SAVE_HISTORY]

@extra_doc_dirs = IRB.conf[:EXTRA_DOC_DIRS]

@echo = IRB.conf[:ECHO]
if @echo.nil?
@echo = true
Expand Down Expand Up @@ -241,6 +243,9 @@ def main
#
# If set to +false+, <code>^D</code> will quit irb.
attr_accessor :ignore_eof
# Specify the installation locations of the ri file to be displayed in the
# document dialog.
attr_accessor :extra_doc_dirs
# Whether to echo the return value to output or not.
#
# Uses <code>IRB.conf[:ECHO]</code> if available, or defaults to +true+.
Expand Down
4 changes: 4 additions & 0 deletions lib/irb/init.rb
Expand Up @@ -51,6 +51,7 @@ def IRB.init_config(ap_path)
@CONF[:USE_LOADER] = false
@CONF[:IGNORE_SIGINT] = true
@CONF[:IGNORE_EOF] = false
@CONF[:EXTRA_DOC_DIRS] = []
@CONF[:ECHO] = nil
@CONF[:ECHO_ON_ASSIGNMENT] = nil
@CONF[:VERBOSE] = nil
Expand Down Expand Up @@ -257,6 +258,9 @@ def IRB.parse_opts(argv: ::ARGV)
@CONF[:USE_MULTILINE] = true
when "--nomultiline", "--noreidline"
@CONF[:USE_MULTILINE] = false
when /^--extra-doc-dir(?:=(.+))?/
opt = $1 || argv.shift
@CONF[:EXTRA_DOC_DIRS] << opt
when "--echo"
@CONF[:ECHO] = true
when "--noecho"
Expand Down
4 changes: 3 additions & 1 deletion lib/irb/input-method.rb
Expand Up @@ -329,7 +329,9 @@ def auto_indent(&block)
name = result[pointer]
name = IRB::InputCompletor.retrieve_completion_data(name, doc_namespace: true)

driver = RDoc::RI::Driver.new
options = {}
options[:extra_doc_dirs] = IRB.conf[:EXTRA_DOC_DIRS] unless IRB.conf[:EXTRA_DOC_DIRS].empty?
driver = RDoc::RI::Driver.new(options)

if key.match?(dialog.name)
begin
Expand Down

0 comments on commit 866a09d

Please sign in to comment.