[前][次][番号順一覧][スレッド一覧]

ruby-changes:68388

From: aycabta <ko1@a...>
Date: Mon, 11 Oct 2021 21:13:14 +0900 (JST)
Subject: [ruby-changes:68388] 866a09dd9e (master): [ruby/irb] Add --extra-doc-dir option to show doc dialog

https://git.ruby-lang.org/ruby.git/commit/?id=866a09dd9e

From 866a09dd9ea2775a3231c0e9833f3bca48947f30 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Mon, 11 Oct 2021 20:35:27 +0900
Subject: [ruby/irb] Add --extra-doc-dir option to show doc dialog

https://github.com/ruby/irb/commit/3f79cb506f
---
 lib/irb/context.rb      | 5 +++++
 lib/irb/init.rb         | 4 ++++
 lib/irb/input-method.rb | 4 +++-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/irb/context.rb b/lib/irb/context.rb
index 31d4126e5c..0a46c1b1d4 100644
--- a/lib/irb/context.rb
+++ b/lib/irb/context.rb
@@ -125,6 +125,8 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/context.rb#L125
       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
@@ -241,6 +243,9 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/context.rb#L243
     #
     # 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+.
diff --git a/lib/irb/init.rb b/lib/irb/init.rb
index 3c27b4ffff..d2baee2017 100644
--- a/lib/irb/init.rb
+++ b/lib/irb/init.rb
@@ -51,6 +51,7 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/init.rb#L51
     @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
@@ -257,6 +258,9 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/init.rb#L258
         @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"
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index 5efd5d8e21..dc95065f97 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -329,7 +329,9 @@ module IRB https://github.com/ruby/ruby/blob/trunk/lib/irb/input-method.rb#L329
       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
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]