blob: 819eb52d40000a19dea8e84af97f5731a7f58441 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
require 'rdoc/generator'
require 'rdoc/ri'
##
# Generates ri data files
class RDoc::Generator::RI
RDoc::RDoc.add_generator self
def self.for options
new options
end
##
# Set up a new ri generator
def initialize options #:not-new:
@options = options
@store = RDoc::RI::Store.new '.'
@old_siginfo = nil
@current = nil
end
##
# Build the initial indices and output objects based on an array of TopLevel
# objects containing the extracted information.
def generate top_levels
install_siginfo_handler
@store.load_cache
RDoc::TopLevel.all_classes_and_modules.each do |klass|
@current = "#{klass.class}: #{klass.full_name}"
@store.save_class klass
klass.each_method do |method|
@current = "#{method.class}: #{method.full_name}"
@store.save_method klass, method
end
klass.each_attribute do |attribute|
@store.save_method klass, attribute
end
end
@current = 'saving cache'
@store.save_cache
ensure
@current = nil
remove_siginfo_handler
end
##
# Installs a siginfo handler that prints the current filename.
def install_siginfo_handler
return unless Signal.list.key? 'INFO'
@old_siginfo = trap 'INFO' do
puts @current if @current
end
end
##
# Removes a siginfo handler and replaces the previous
def remove_siginfo_handler
return unless Signal.list.key? 'INFO'
handler = @old_siginfo || 'DEFAULT'
trap 'INFO', handler
end
end
|