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