mirror of
https://github.com/ruby/ruby.git
synced 2025-08-16 05:59:00 +02:00
irb: defer requiring rdoc to improve the start up time
This commit is contained in:
parent
973fd18f11
commit
976c689ad4
2 changed files with 10 additions and 7 deletions
|
@ -9,17 +9,18 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
require 'rdoc/ri/driver'
|
|
||||||
|
|
||||||
require_relative "nop"
|
require_relative "nop"
|
||||||
|
|
||||||
# :stopdoc:
|
# :stopdoc:
|
||||||
module IRB
|
module IRB
|
||||||
module ExtendCommand
|
module ExtendCommand
|
||||||
class Help < Nop
|
class Help < Nop
|
||||||
begin
|
def execute(*names)
|
||||||
Ri = RDoc::RI::Driver.new
|
require 'rdoc/ri/driver'
|
||||||
rescue SystemExit
|
IRB::ExtendCommand::Help.const_set(:Ri, RDoc::RI::Driver.new)
|
||||||
|
rescue LoadError, SystemExit
|
||||||
|
IRB::ExtendCommand::Help.remove_method(:execute)
|
||||||
|
# raise NoMethodError in ensure
|
||||||
else
|
else
|
||||||
def execute(*names)
|
def execute(*names)
|
||||||
if names.empty?
|
if names.empty?
|
||||||
|
@ -35,6 +36,8 @@ module IRB
|
||||||
end
|
end
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
|
execute(*names)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
require "readline"
|
require "readline"
|
||||||
require "rdoc"
|
autoload :RDoc, "rdoc"
|
||||||
|
|
||||||
module IRB
|
module IRB
|
||||||
module InputCompletor # :nodoc:
|
module InputCompletor # :nodoc:
|
||||||
|
@ -267,8 +267,8 @@ module IRB
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RDocRIDriver = RDoc::RI::Driver.new
|
|
||||||
PerfectMatchedProc = ->(matched) {
|
PerfectMatchedProc = ->(matched) {
|
||||||
|
RDocRIDriver ||= RDoc::RI::Driver.new
|
||||||
if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
|
if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
|
||||||
File.open(File.join(__dir__, 'ruby_logo.aa')) do |f|
|
File.open(File.join(__dir__, 'ruby_logo.aa')) do |f|
|
||||||
RDocRIDriver.page do |io|
|
RDocRIDriver.page do |io|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue