2008-01-13 03:13:37 +00:00
|
|
|
require 'rdoc/generator'
|
2010-04-01 07:45:16 +00:00
|
|
|
require 'rdoc/ri'
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
##
|
|
|
|
# Generates ri data files
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2008-01-13 03:13:37 +00:00
|
|
|
class RDoc::Generator::RI
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
RDoc::RDoc.add_generator self
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
def self.for options
|
|
|
|
new options
|
2008-01-07 01:36:33 +00:00
|
|
|
end
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2008-01-07 01:36:33 +00:00
|
|
|
##
|
2008-07-21 18:35:14 +00:00
|
|
|
# Set up a new ri generator
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
def initialize options #:not-new:
|
|
|
|
@options = options
|
|
|
|
@store = RDoc::RI::Store.new '.'
|
|
|
|
@old_siginfo = nil
|
|
|
|
@current = nil
|
2008-01-07 01:36:33 +00:00
|
|
|
end
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2008-01-07 01:36:33 +00:00
|
|
|
##
|
2010-04-01 07:45:16 +00:00
|
|
|
# Build the initial indices and output objects based on an array of TopLevel
|
|
|
|
# objects containing the extracted information.
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
def generate top_levels
|
|
|
|
install_siginfo_handler
|
2008-01-14 03:34:05 +00:00
|
|
|
|
2010-05-12 06:46:53 +00:00
|
|
|
@store.load_cache
|
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
RDoc::TopLevel.all_classes_and_modules.each do |klass|
|
|
|
|
@current = "#{klass.class}: #{klass.full_name}"
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
@store.save_class klass
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
klass.each_method do |method|
|
|
|
|
@current = "#{method.class}: #{method.full_name}"
|
|
|
|
@store.save_method klass, method
|
|
|
|
end
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
klass.each_attribute do |attribute|
|
|
|
|
@store.save_method klass, attribute
|
|
|
|
end
|
2008-01-07 01:36:33 +00:00
|
|
|
end
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
@current = 'saving cache'
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
@store.save_cache
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
ensure
|
|
|
|
@current = nil
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
remove_siginfo_handler
|
2008-01-07 01:36:33 +00:00
|
|
|
end
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2008-01-07 01:36:33 +00:00
|
|
|
##
|
2010-04-01 07:45:16 +00:00
|
|
|
# Installs a siginfo handler that prints the current filename.
|
2008-01-07 00:42:03 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
def install_siginfo_handler
|
|
|
|
return unless Signal.list.key? 'INFO'
|
2008-01-07 01:36:33 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
@old_siginfo = trap 'INFO' do
|
|
|
|
puts @current if @current
|
2003-12-16 05:44:25 +00:00
|
|
|
end
|
2008-01-07 01:36:33 +00:00
|
|
|
end
|
2003-12-16 05:44:25 +00:00
|
|
|
|
2008-01-07 01:36:33 +00:00
|
|
|
##
|
2010-04-01 07:45:16 +00:00
|
|
|
# Removes a siginfo handler and replaces the previous
|
2008-01-07 02:52:15 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
def remove_siginfo_handler
|
|
|
|
return unless Signal.list.key? 'INFO'
|
2008-01-07 02:52:15 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
handler = @old_siginfo || 'DEFAULT'
|
2008-01-07 02:52:15 +00:00
|
|
|
|
2010-04-01 07:45:16 +00:00
|
|
|
trap 'INFO', handler
|
2003-12-16 05:44:25 +00:00
|
|
|
end
|
2008-01-07 00:42:03 +00:00
|
|
|
|
2003-12-16 05:44:25 +00:00
|
|
|
end
|
2008-01-07 00:42:03 +00:00
|
|
|
|