rdoc 2.4.3 → 2.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (139) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +3 -1
  3. data/History.txt +68 -0
  4. data/LICENSE.txt +57 -0
  5. data/Manifest.txt +37 -19
  6. data/README.txt +2 -12
  7. data/Rakefile +12 -12
  8. data/bin/rdoc +4 -4
  9. data/lib/rdoc.rb +32 -9
  10. data/lib/rdoc/alias.rb +2 -2
  11. data/lib/rdoc/any_method.rb +108 -16
  12. data/lib/rdoc/attr.rb +87 -1
  13. data/lib/rdoc/class_module.rb +131 -5
  14. data/lib/rdoc/code_object.rb +28 -5
  15. data/lib/rdoc/constant.rb +22 -0
  16. data/lib/rdoc/context.rb +80 -37
  17. data/lib/rdoc/gauntlet.rb +48 -0
  18. data/lib/rdoc/generator/darkfish.rb +25 -23
  19. data/lib/rdoc/generator/markup.rb +6 -29
  20. data/lib/rdoc/generator/ri.rb +39 -189
  21. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +17 -1
  22. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +10 -0
  23. data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  24. data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  25. data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  26. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  27. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  28. data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  29. data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  30. data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  31. data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  32. data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  33. data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  34. data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  35. data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  36. data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  37. data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  38. data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  39. data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  40. data/lib/rdoc/generator/template/darkfish/index.rhtml +2 -2
  41. data/lib/rdoc/generator/template/darkfish/rdoc.css +38 -33
  42. data/lib/rdoc/include.rb +22 -0
  43. data/lib/rdoc/markup.rb +10 -262
  44. data/lib/rdoc/markup/attribute_manager.rb +57 -50
  45. data/lib/rdoc/markup/blank_line.rb +19 -0
  46. data/lib/rdoc/markup/document.rb +72 -0
  47. data/lib/rdoc/markup/formatter.rb +118 -0
  48. data/lib/rdoc/markup/formatter_test_case.rb +341 -0
  49. data/lib/rdoc/markup/heading.rb +17 -0
  50. data/lib/rdoc/markup/inline.rb +6 -5
  51. data/lib/rdoc/markup/list.rb +78 -0
  52. data/lib/rdoc/markup/list_item.rb +83 -0
  53. data/lib/rdoc/markup/paragraph.rb +66 -0
  54. data/lib/rdoc/markup/parser.rb +528 -0
  55. data/lib/rdoc/markup/rule.rb +17 -0
  56. data/lib/rdoc/markup/to_ansi.rb +72 -0
  57. data/lib/rdoc/markup/to_bs.rb +74 -0
  58. data/lib/rdoc/markup/to_html.rb +106 -172
  59. data/lib/rdoc/markup/to_html_crossref.rb +10 -4
  60. data/lib/rdoc/markup/to_rdoc.rb +243 -0
  61. data/lib/rdoc/markup/to_test.rb +27 -16
  62. data/lib/rdoc/markup/verbatim.rb +42 -0
  63. data/lib/rdoc/normal_class.rb +38 -1
  64. data/lib/rdoc/normal_module.rb +38 -8
  65. data/lib/rdoc/options.rb +39 -151
  66. data/lib/rdoc/parser.rb +36 -18
  67. data/lib/rdoc/parser/c.rb +102 -109
  68. data/lib/rdoc/parser/ruby.rb +359 -1662
  69. data/lib/rdoc/parser/ruby_tools.rb +157 -0
  70. data/lib/rdoc/parser/simple.rb +0 -2
  71. data/lib/rdoc/rdoc.rb +142 -82
  72. data/lib/rdoc/ri.rb +10 -0
  73. data/lib/rdoc/ri/driver.rb +674 -444
  74. data/lib/rdoc/ri/formatter.rb +2 -651
  75. data/lib/rdoc/ri/paths.rb +70 -45
  76. data/lib/rdoc/ri/store.rb +248 -0
  77. data/lib/rdoc/ruby_lex.rb +1284 -0
  78. data/lib/rdoc/ruby_token.rb +416 -0
  79. data/lib/rdoc/single_class.rb +5 -0
  80. data/lib/rdoc/stats.rb +152 -83
  81. data/lib/rdoc/task.rb +27 -49
  82. data/lib/rdoc/text.rb +130 -0
  83. data/lib/rdoc/tokenstream.rb +28 -9
  84. data/lib/rdoc/top_level.rb +49 -43
  85. data/test/hidden.zip.txt +1 -0
  86. data/test/test_attribute_manager.rb +9 -16
  87. data/test/test_rdoc_any_method.rb +23 -0
  88. data/test/test_rdoc_attr.rb +40 -0
  89. data/test/test_rdoc_class_module.rb +100 -0
  90. data/test/test_rdoc_code_object.rb +18 -2
  91. data/test/test_rdoc_context.rb +41 -0
  92. data/test/test_rdoc_generator_ri.rb +56 -0
  93. data/test/test_rdoc_markup.rb +21 -610
  94. data/test/test_rdoc_markup_attribute_manager.rb +14 -17
  95. data/test/test_rdoc_markup_document.rb +51 -0
  96. data/test/test_rdoc_markup_paragraph.rb +27 -0
  97. data/test/test_rdoc_markup_parser.rb +1327 -0
  98. data/test/test_rdoc_markup_to_ansi.rb +426 -0
  99. data/test/test_rdoc_markup_to_bs.rb +443 -0
  100. data/test/test_rdoc_markup_to_html.rb +183 -18
  101. data/test/test_rdoc_markup_to_html_crossref.rb +1 -3
  102. data/test/test_rdoc_markup_to_rdoc.rb +426 -0
  103. data/test/test_rdoc_normal_class.rb +17 -0
  104. data/test/test_rdoc_normal_module.rb +6 -6
  105. data/test/test_rdoc_options.rb +41 -0
  106. data/test/test_rdoc_parser.rb +66 -13
  107. data/test/test_rdoc_parser_c.rb +93 -38
  108. data/test/test_rdoc_parser_perl.rb +2 -3
  109. data/test/test_rdoc_parser_ruby.rb +291 -28
  110. data/test/test_rdoc_parser_simple.rb +48 -0
  111. data/test/test_rdoc_rdoc.rb +66 -0
  112. data/test/test_rdoc_ri_driver.rb +752 -38
  113. data/test/test_rdoc_ri_paths.rb +39 -0
  114. data/test/test_rdoc_ri_store.rb +309 -0
  115. data/test/test_rdoc_text.rb +157 -0
  116. data/test/test_rdoc_top_level.rb +35 -9
  117. data/test/xref_data.rb +9 -1
  118. data/test/xref_test_case.rb +8 -3
  119. metadata +110 -38
  120. metadata.gz.sig +0 -0
  121. data/lib/rdoc/cache.rb +0 -41
  122. data/lib/rdoc/diagram.rb +0 -340
  123. data/lib/rdoc/dot.rb +0 -249
  124. data/lib/rdoc/markup/fragments.rb +0 -377
  125. data/lib/rdoc/markup/lines.rb +0 -156
  126. data/lib/rdoc/markup/to_flow.rb +0 -211
  127. data/lib/rdoc/markup/to_latex.rb +0 -328
  128. data/lib/rdoc/markup/to_texinfo.rb +0 -73
  129. data/lib/rdoc/ri/cache.rb +0 -187
  130. data/lib/rdoc/ri/descriptions.rb +0 -156
  131. data/lib/rdoc/ri/display.rb +0 -340
  132. data/lib/rdoc/ri/reader.rb +0 -106
  133. data/lib/rdoc/ri/util.rb +0 -79
  134. data/lib/rdoc/ri/writer.rb +0 -68
  135. data/test/test_rdoc_ri_attribute_formatter.rb +0 -44
  136. data/test/test_rdoc_ri_default_display.rb +0 -302
  137. data/test/test_rdoc_ri_formatter.rb +0 -320
  138. data/test/test_rdoc_ri_html_formatter.rb +0 -141
  139. data/test/test_rdoc_ri_overstrike_formatter.rb +0 -71
@@ -0,0 +1,157 @@
1
+ ##
2
+ # Collection of methods for writing parsers against RDoc::RubyLex and
3
+ # RDoc::RubyToken
4
+
5
+ module RDoc::Parser::RubyTools
6
+
7
+ include RDoc::RubyToken
8
+
9
+ ##
10
+ # Adds a token listener +obj+, but you should probably use token_listener
11
+
12
+ def add_token_listener(obj)
13
+ @token_listeners ||= []
14
+ @token_listeners << obj
15
+ end
16
+
17
+ ##
18
+ # Fetches the next token from the scanner
19
+
20
+ def get_tk
21
+ tk = nil
22
+
23
+ if @tokens.empty? then
24
+ tk = @scanner.token
25
+ @read.push @scanner.get_readed
26
+ puts "get_tk1 => #{tk.inspect}" if $TOKEN_DEBUG
27
+ else
28
+ @read.push @unget_read.shift
29
+ tk = @tokens.shift
30
+ puts "get_tk2 => #{tk.inspect}" if $TOKEN_DEBUG
31
+ end
32
+
33
+ tk = nil if TkEND_OF_SCRIPT === tk
34
+
35
+ if TkSYMBEG === tk then
36
+ set_token_position tk.line_no, tk.char_no
37
+
38
+ case tk1 = get_tk
39
+ when TkId, TkOp, TkSTRING, TkDSTRING, TkSTAR, TkAMPER then
40
+ if tk1.respond_to?(:name) then
41
+ tk = Token(TkSYMBOL).set_text(":" + tk1.name)
42
+ else
43
+ tk = Token(TkSYMBOL).set_text(":" + tk1.text)
44
+ end
45
+
46
+ # remove the identifier we just read (we're about to replace it with a
47
+ # symbol)
48
+ @token_listeners.each do |obj|
49
+ obj.pop_token
50
+ end if @token_listeners
51
+ else
52
+ warn("':' not followed by identifier or operator")
53
+ tk = tk1
54
+ end
55
+ end
56
+
57
+ # inform any listeners of our shiny new token
58
+ @token_listeners.each do |obj|
59
+ obj.add_token(tk)
60
+ end if @token_listeners
61
+
62
+ tk
63
+ end
64
+
65
+ def get_tk_until(*tokens)
66
+ read = []
67
+
68
+ loop do
69
+ tk = get_tk
70
+ case tk when *tokens then unget_tk tk; break end
71
+ read << tk
72
+ end
73
+
74
+ read
75
+ end
76
+
77
+ ##
78
+ # Retrieves a String representation of the read tokens
79
+
80
+ def get_tkread
81
+ read = @read.join("")
82
+ @read = []
83
+ read
84
+ end
85
+
86
+ ##
87
+ # Peek equivalent for get_tkread
88
+
89
+ def peek_read
90
+ @read.join('')
91
+ end
92
+
93
+ ##
94
+ # Peek at the next token, but don't remove it from the stream
95
+
96
+ def peek_tk
97
+ unget_tk(tk = get_tk)
98
+ tk
99
+ end
100
+
101
+ ##
102
+ # Removes the token listener +obj+
103
+
104
+ def remove_token_listener(obj)
105
+ @token_listeners.delete(obj)
106
+ end
107
+
108
+ ##
109
+ # Resets the tools
110
+
111
+ def reset
112
+ @read = []
113
+ @tokens = []
114
+ @unget_read = []
115
+ @nest = 0
116
+ end
117
+
118
+ ##
119
+ # Skips whitespace tokens including newlines if +skip_nl+ is true
120
+
121
+ def skip_tkspace(skip_nl = true) # HACK dup
122
+ tokens = []
123
+
124
+ while TkSPACE === (tk = get_tk) or (skip_nl and TkNL === tk) do
125
+ tokens.push tk
126
+ end
127
+
128
+ unget_tk tk
129
+ tokens
130
+ end
131
+
132
+ ##
133
+ # Has +obj+ listen to tokens
134
+
135
+ def token_listener(obj)
136
+ add_token_listener obj
137
+ yield
138
+ ensure
139
+ remove_token_listener obj
140
+ end
141
+
142
+ ##
143
+ # Returns +tk+ to the scanner
144
+
145
+ def unget_tk(tk)
146
+ @tokens.unshift tk
147
+ @unget_read.unshift @read.pop
148
+
149
+ # Remove this token from any listeners
150
+ @token_listeners.each do |obj|
151
+ obj.pop_token
152
+ end if @token_listeners
153
+ end
154
+
155
+ end
156
+
157
+
@@ -1,5 +1,3 @@
1
- require 'rdoc/parser'
2
-
3
1
  ##
4
2
  # Parse a non-source file. We basically take the whole thing as one big
5
3
  # comment. If the first character in the file is '#', we strip leading pound
@@ -11,12 +11,9 @@ require 'rdoc/parser/perl'
11
11
  require 'rdoc/stats'
12
12
  require 'rdoc/options'
13
13
 
14
- require 'rdoc/diagram'
15
-
16
14
  require 'find'
17
15
  require 'fileutils'
18
16
  require 'time'
19
- require 'thread'
20
17
 
21
18
  ##
22
19
  # Encapsulate the production of rdoc documentation. Basically you can use this
@@ -30,6 +27,11 @@ require 'thread'
30
27
 
31
28
  class RDoc::RDoc
32
29
 
30
+ ##
31
+ # File pattern to exclude
32
+
33
+ attr_accessor :exclude
34
+
33
35
  ##
34
36
  # Generator instance used for creating output
35
37
 
@@ -38,7 +40,7 @@ class RDoc::RDoc
38
40
  ##
39
41
  # RDoc options
40
42
 
41
- attr_reader :options
43
+ attr_accessor :options
42
44
 
43
45
  ##
44
46
  # Accessor for statistics. Available after each call to parse_files
@@ -73,9 +75,13 @@ class RDoc::RDoc
73
75
  end
74
76
 
75
77
  def initialize
76
- @generator = nil
77
- @options = nil
78
- @stats = nil
78
+ @current = nil
79
+ @exclude = nil
80
+ @generator = nil
81
+ @last_created = nil
82
+ @old_siginfo = nil
83
+ @options = nil
84
+ @stats = nil
79
85
  end
80
86
 
81
87
  ##
@@ -85,6 +91,20 @@ class RDoc::RDoc
85
91
  raise RDoc::Error, msg
86
92
  end
87
93
 
94
+ ##
95
+ # Gathers a set of parseable files from the files and directories listed in
96
+ # +files+.
97
+
98
+ def gather_files files
99
+ files = ["."] if files.empty?
100
+
101
+ file_list = normalized_file_list files, true, @exclude
102
+
103
+ file_list = file_list.uniq
104
+
105
+ file_list = remove_unparseable file_list
106
+ end
107
+
88
108
  ##
89
109
  # Turns RDoc from stdin into HTML
90
110
 
@@ -96,6 +116,17 @@ class RDoc::RDoc
96
116
  $stdout.write out
97
117
  end
98
118
 
119
+ ##
120
+ # Installs a siginfo handler that prints the current filename.
121
+
122
+ def install_siginfo_handler
123
+ return unless Signal.list.include? 'INFO'
124
+
125
+ @old_siginfo = trap 'INFO' do
126
+ puts @current if @current
127
+ end
128
+ end
129
+
99
130
  ##
100
131
  # Create an output dir if it doesn't exist. If it does exist, but doesn't
101
132
  # contain the flag file <tt>created.rid</tt> then we refuse to use it, as
@@ -122,6 +153,7 @@ class RDoc::RDoc
122
153
  else
123
154
  FileUtils.mkdir_p(op_dir)
124
155
  end
156
+
125
157
  last
126
158
  end
127
159
 
@@ -144,7 +176,7 @@ class RDoc::RDoc
144
176
  # representing candidates for documentation. It may also contain comments
145
177
  # (starting with '#')
146
178
 
147
- def parse_dot_doc_file(in_dir, filename, options)
179
+ def parse_dot_doc_file in_dir, filename
148
180
  # read and strip comments
149
181
  patterns = File.read(filename).gsub(/#.*/, '')
150
182
 
@@ -152,7 +184,7 @@ class RDoc::RDoc
152
184
 
153
185
  patterns.split.each do |patt|
154
186
  candidates = Dir.glob(File.join(in_dir, patt))
155
- result.concat(normalized_file_list(options, candidates))
187
+ result.concat normalized_file_list(candidates)
156
188
  end
157
189
 
158
190
  result
@@ -170,7 +202,7 @@ class RDoc::RDoc
170
202
  # The effect of this is that if you want a file with a non-standard
171
203
  # extension parsed, you must name it explicitly.
172
204
 
173
- def normalized_file_list(options, relative_files, force_doc = false,
205
+ def normalized_file_list(relative_files, force_doc = false,
174
206
  exclude_pattern = nil)
175
207
  file_list = []
176
208
 
@@ -187,18 +219,20 @@ class RDoc::RDoc
187
219
  end
188
220
  when "directory"
189
221
  next if rel_file_name == "CVS" || rel_file_name == ".svn"
190
- dot_doc = File.join(rel_file_name, RDoc::DOT_DOC_FILENAME)
191
- if File.file?(dot_doc)
192
- file_list.concat(parse_dot_doc_file(rel_file_name, dot_doc, options))
222
+
223
+ dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME
224
+
225
+ if File.file?(dot_doc) then
226
+ file_list << parse_dot_doc_file(rel_file_name, dot_doc)
193
227
  else
194
- file_list.concat(list_files_in_directory(rel_file_name, options))
228
+ file_list << list_files_in_directory(rel_file_name)
195
229
  end
196
230
  else
197
231
  raise RDoc::Error, "I can't deal with a #{type} #{rel_file_name}"
198
232
  end
199
233
  end
200
234
 
201
- file_list
235
+ file_list.flatten
202
236
  end
203
237
 
204
238
  ##
@@ -207,74 +241,82 @@ class RDoc::RDoc
207
241
  # files. However we may well contain subdirectories which must be tested
208
242
  # for .document files.
209
243
 
210
- def list_files_in_directory(dir, options)
244
+ def list_files_in_directory dir
211
245
  files = Dir.glob File.join(dir, "*")
212
246
 
213
- normalized_file_list options, files, false, options.exclude
247
+ normalized_file_list files, false, @options.exclude
214
248
  end
215
249
 
216
250
  ##
217
- # Parse each file on the command line, recursively entering directories.
251
+ # Parses +filename+ and returns an RDoc::TopLevel
218
252
 
219
- def parse_files(options)
220
- files = options.files
221
- files = ["."] if files.empty?
253
+ def parse_file filename
254
+ @stats.add_file filename
255
+ content = read_file_contents filename
256
+
257
+ return unless content
258
+
259
+ top_level = RDoc::TopLevel.new filename
260
+
261
+ parser = RDoc::Parser.for top_level, filename, content, @options, @stats
262
+
263
+ return unless parser
264
+
265
+ parser.scan
266
+ rescue => e
267
+ $stderr.puts <<-EOF
268
+ Before reporting this, could you check that the file you're documenting
269
+ compiles cleanly--RDoc is not a full Ruby parser, and gets confused easily if
270
+ fed invalid programs.
271
+
272
+ The internal error was:
273
+
274
+ \t(#{e.class}) #{e.message}
275
+
276
+ EOF
222
277
 
223
- file_list = normalized_file_list(options, files, true, options.exclude)
278
+ $stderr.puts e.backtrace.join("\n\t") if $RDOC_DEBUG
279
+
280
+ raise e
281
+ nil
282
+ end
283
+
284
+ ##
285
+ # Parse each file on the command line, recursively entering directories.
286
+
287
+ def parse_files files
288
+ file_list = gather_files files
224
289
 
225
290
  return [] if file_list.empty?
226
291
 
227
- jobs = SizedQueue.new(@options.threads * 3)
228
- workers = []
229
292
  file_info = []
230
- file_info_lock = Mutex.new
231
-
232
- Thread.abort_on_exception = true
233
- @stats = RDoc::Stats.new(file_list.size, options.verbosity)
234
- @stats.begin_adding @options.threads
235
-
236
- # Create worker threads.
237
- @options.threads.times do
238
- thread = Thread.new do
239
- while (filename = jobs.pop)
240
- @stats.add_file(filename)
241
- content = read_file_contents(filename)
242
- top_level = RDoc::TopLevel.new filename
243
-
244
- parser = RDoc::Parser.for(top_level, filename, content, options,
245
- @stats)
246
- result = parser.scan
247
-
248
- file_info_lock.synchronize do
249
- file_info << result
250
- end
251
- end
252
- end
253
- workers << thread
254
- end
255
293
 
256
- # Feed filenames to the parser worker threads...
257
- file_list.each do |filename|
258
- jobs << filename
259
- end
260
- workers.size.times do
261
- jobs << nil
262
- end
294
+ @stats = RDoc::Stats.new file_list.size, @options.verbosity
295
+ @stats.begin_adding
263
296
 
264
- # ...and wait until they're done.
265
- workers.each do |thread|
266
- thread.join
267
- end
297
+ file_info = file_list.map do |filename|
298
+ @current = filename
299
+ parse_file filename
300
+ end.compact
268
301
 
269
302
  @stats.done_adding
270
303
 
271
304
  file_info
272
305
  end
273
306
 
307
+ ##
308
+ # Removes file extensions known to be unparseable from +files+
309
+
310
+ def remove_unparseable files
311
+ files.reject do |file|
312
+ file =~ /\.(?:class|eps|erb|scpt\.txt|ttf|yml)$/i
313
+ end
314
+ end
315
+
274
316
  ##
275
317
  # Format up one or more files according to the given arguments.
276
318
  #
277
- # For simplicity, _argv_ is an array of strings, equivalent to the strings
319
+ # For simplicity, +argv+ is an array of strings, equivalent to the strings
278
320
  # that would be passed on the command line. (This isn't a coincidence, as
279
321
  # we _do_ pass in ARGV when running interactively). For a list of options,
280
322
  # see rdoc/rdoc.rb. By default, output will be stored in a directory
@@ -285,6 +327,8 @@ class RDoc::RDoc
285
327
 
286
328
  def document(argv)
287
329
  RDoc::TopLevel.reset
330
+ RDoc::Parser::C.reset
331
+ RDoc::AnyMethod.reset
288
332
 
289
333
  @options = RDoc::Options.new
290
334
  @options.parse argv
@@ -294,11 +338,13 @@ class RDoc::RDoc
294
338
  exit
295
339
  end
296
340
 
341
+ @exclude = @options.exclude
342
+
297
343
  @last_created = setup_output_dir @options.op_dir, @options.force_update
298
344
 
299
345
  start_time = Time.now
300
346
 
301
- file_info = parse_files @options
347
+ file_info = parse_files @options.files
302
348
 
303
349
  @options.title = "RDoc Documentation"
304
350
 
@@ -315,17 +361,15 @@ class RDoc::RDoc
315
361
 
316
362
  pwd = Dir.pwd
317
363
 
318
- Dir.chdir @options.op_dir
364
+ Dir.chdir @options.op_dir do
365
+ begin
366
+ self.class.current = self
319
367
 
320
- begin
321
- self.class.current = self
322
-
323
- RDoc::Diagram.new(file_info, @options).draw if @options.diagram
324
- @generator.generate file_info
325
- update_output_dir ".", start_time
326
- ensure
327
- self.class.current = nil
328
- Dir.chdir pwd
368
+ @generator.generate file_info
369
+ update_output_dir ".", start_time
370
+ ensure
371
+ self.class.current = nil
372
+ end
329
373
  end
330
374
  end
331
375
 
@@ -335,8 +379,6 @@ class RDoc::RDoc
335
379
  end
336
380
  end
337
381
 
338
- private
339
-
340
382
  def read_file_contents(filename)
341
383
  content = if RUBY_VERSION >= '1.9' then
342
384
  File.open(filename, "r:ascii-8bit") { |f| f.read }
@@ -345,7 +387,7 @@ class RDoc::RDoc
345
387
  end
346
388
 
347
389
  if defined? Encoding then
348
- if /coding:\s*(\S+)/ =~ content[/\A(?:.*\n){0,2}/]
390
+ if /coding:\s*([\w-]+)/i =~ content[/\A(?:.*\n){0,2}/]
349
391
  if enc = ::Encoding.find($1)
350
392
  content.force_encoding(enc)
351
393
  end
@@ -353,20 +395,38 @@ class RDoc::RDoc
353
395
  end
354
396
 
355
397
  content
398
+ rescue Errno::EISDIR, Errno::ENOENT
399
+ nil
400
+ end
401
+
402
+ ##
403
+ # Removes a siginfo handler and replaces the previous
404
+
405
+ def remove_siginfo_handler
406
+ return unless Signal.list.key? 'INFO'
407
+
408
+ handler = @old_siginfo || 'DEFAULT'
409
+
410
+ trap 'INFO', handler
356
411
  end
357
412
 
358
413
  end
359
414
 
360
- if Gem.respond_to? :find_files then
361
- rdoc_extensions = Gem.find_files 'rdoc/discover'
415
+ begin
416
+ require 'rubygems'
362
417
 
363
- rdoc_extensions.each do |extension|
364
- begin
365
- load extension
366
- rescue => e
367
- warn "error loading #{extension.inspect}: #{e.message} (#{e.class})"
418
+ if Gem.respond_to? :find_files then
419
+ rdoc_extensions = Gem.find_files 'rdoc/discover'
420
+
421
+ rdoc_extensions.each do |extension|
422
+ begin
423
+ load extension
424
+ rescue => e
425
+ warn "error loading #{extension.inspect}: #{e.message} (#{e.class})"
426
+ end
368
427
  end
369
428
  end
429
+ rescue LoadError
370
430
  end
371
431
 
372
432
  # require built-in generators after discovery in case they've been replaced