rdoc 2.2.1 → 2.3.0

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 (95) hide show
  1. data.tar.gz.sig +2 -0
  2. data/.document +4 -0
  3. data/History.txt +35 -0
  4. data/Manifest.txt +36 -15
  5. data/README.txt +11 -27
  6. data/Rakefile +3 -0
  7. data/lib/rdoc.rb +1 -1
  8. data/lib/rdoc/cache.rb +32 -0
  9. data/lib/rdoc/code_objects.rb +121 -59
  10. data/lib/rdoc/generator.rb +196 -133
  11. data/lib/rdoc/generator/darkfish.rb +471 -0
  12. data/lib/rdoc/generator/html.rb +71 -60
  13. data/lib/rdoc/generator/html/html.rb +115 -115
  14. data/lib/rdoc/generator/html/one_page_html.rb +56 -56
  15. data/lib/rdoc/generator/ri.rb +2 -0
  16. data/lib/rdoc/generator/template/darkfish/.document +0 -0
  17. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +302 -0
  18. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +114 -0
  19. data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  20. data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  21. data/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  22. data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  23. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  24. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  25. data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  26. data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  27. data/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  28. data/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  29. data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  30. data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  31. data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  32. data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  33. data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  34. data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  35. data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  36. data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  37. data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  38. data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  39. data/lib/rdoc/generator/template/darkfish/index.rhtml +57 -0
  40. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +116 -0
  41. data/lib/rdoc/generator/template/darkfish/js/jquery.js +32 -0
  42. data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +114 -0
  43. data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +10 -0
  44. data/lib/rdoc/generator/template/darkfish/rdoc.css +696 -0
  45. data/lib/rdoc/generator/xml.rb +19 -12
  46. data/lib/rdoc/generator/xml/rdf.rb +50 -50
  47. data/lib/rdoc/generator/xml/xml.rb +58 -58
  48. data/lib/rdoc/known_classes.rb +0 -1
  49. data/lib/rdoc/markup/preprocess.rb +4 -3
  50. data/lib/rdoc/markup/to_html.rb +4 -1
  51. data/lib/rdoc/markup/to_html_crossref.rb +28 -31
  52. data/lib/rdoc/options.rb +25 -20
  53. data/lib/rdoc/parser.rb +10 -2
  54. data/lib/rdoc/parser/c.rb +38 -29
  55. data/lib/rdoc/parser/f95.rb +32 -32
  56. data/lib/rdoc/parser/ruby.rb +5 -2
  57. data/lib/rdoc/parser/simple.rb +1 -0
  58. data/lib/rdoc/rdoc.rb +99 -47
  59. data/lib/rdoc/ri/cache.rb +6 -6
  60. data/lib/rdoc/ri/display.rb +22 -75
  61. data/lib/rdoc/ri/driver.rb +237 -78
  62. data/lib/rdoc/stats.rb +91 -28
  63. data/lib/rdoc/template.rb +6 -2
  64. data/test/test.ja.rdoc +8 -0
  65. data/test/test.ja.txt +8 -0
  66. data/test/test_attribute_manager.rb +9 -6
  67. data/test/test_rdoc_markup.rb +4 -2
  68. data/test/test_rdoc_markup_attribute_manager.rb +13 -3
  69. data/test/test_rdoc_markup_to_html.rb +18 -2
  70. data/test/test_rdoc_markup_to_html_crossref.rb +186 -249
  71. data/test/test_rdoc_parser.rb +17 -1
  72. data/test/test_rdoc_parser_c.rb +65 -10
  73. data/test/test_rdoc_parser_perl.rb +4 -2
  74. data/test/test_rdoc_parser_ruby.rb +6 -4
  75. data/test/test_rdoc_ri_attribute_formatter.rb +4 -2
  76. data/test/test_rdoc_ri_default_display.rb +8 -4
  77. data/test/test_rdoc_ri_driver.rb +4 -2
  78. data/test/test_rdoc_ri_formatter.rb +6 -4
  79. data/test/test_rdoc_ri_overstrike_formatter.rb +4 -2
  80. metadata +84 -33
  81. metadata.gz.sig +0 -0
  82. data/lib/rdoc/generator/chm.rb +0 -113
  83. data/lib/rdoc/generator/chm/chm.rb +0 -100
  84. data/lib/rdoc/generator/html/frameless.rb +0 -92
  85. data/lib/rdoc/generator/html/hefss.rb +0 -150
  86. data/lib/rdoc/generator/html/kilmer.rb +0 -151
  87. data/lib/rdoc/generator/html/kilmerfactory.rb +0 -427
  88. data/lib/rdoc/generator/texinfo.rb +0 -81
  89. data/lib/rdoc/generator/texinfo/class.texinfo.erb +0 -44
  90. data/lib/rdoc/generator/texinfo/file.texinfo.erb +0 -6
  91. data/lib/rdoc/generator/texinfo/method.texinfo.erb +0 -6
  92. data/lib/rdoc/generator/texinfo/texinfo.erb +0 -28
  93. data/test/rdoc_markup_to_html_crossref_reference.rb +0 -31
  94. data/test/test_rdoc_info_formatting.rb +0 -175
  95. data/test/test_rdoc_info_sections.rb +0 -136
@@ -1683,7 +1683,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
1683
1683
  if TkSYMBEG === tk then
1684
1684
  set_token_position(tk.line_no, tk.char_no)
1685
1685
  tk1 = get_tk
1686
- if TkId === tk1 or TkOp === tk1 or TkSTRING === tk1 then
1686
+ if TkId === tk1 or TkOp === tk1 or TkSTRING === tk1 or TkDSTRING === tk1 then
1687
1687
  if tk1.respond_to?(:name)
1688
1688
  tk = Token(TkSYMBOL).set_text(":" + tk1.name)
1689
1689
  else
@@ -2045,8 +2045,11 @@ class RDoc::Parser::Ruby < RDoc::Parser
2045
2045
  name = name_t.text[1..-1]
2046
2046
  when TkSTRING then
2047
2047
  name = name_t.text[1..-2]
2048
+ when TkASSIGN then # ignore
2049
+ remove_token_listener self
2050
+ return
2048
2051
  else
2049
- warn "#{container.top_level.file_relative_name}:#{name_t.line_no} unknown name token #{name_t.inspect} for meta-method"
2052
+ warn "#{container.toplevel.file_relative_name}:#{name_t.line_no} unknown name token #{name_t.inspect} for meta-method '#{tk.name}'"
2050
2053
  name = 'unknown'
2051
2054
  end
2052
2055
  end
@@ -27,6 +27,7 @@ class RDoc::Parser::Simple < RDoc::Parser
27
27
 
28
28
  def scan
29
29
  @top_level.comment = remove_private_comments(@content)
30
+ @top_level.parser = self.class
30
31
  @top_level
31
32
  end
32
33
 
@@ -17,6 +17,7 @@ require 'rdoc/diagram'
17
17
  require 'find'
18
18
  require 'fileutils'
19
19
  require 'time'
20
+ require 'thread'
20
21
 
21
22
  module RDoc
22
23
 
@@ -32,32 +33,22 @@ module RDoc
32
33
 
33
34
  class RDoc
34
35
 
35
- Generator = Struct.new(:file_name, :class_name, :key)
36
-
37
36
  ##
38
37
  # Accessor for statistics. Available after each call to parse_files
39
38
 
40
39
  attr_reader :stats
41
40
 
42
41
  ##
43
- # This is the list of output generator that we support
42
+ # This is the list of supported output generators
44
43
 
45
44
  GENERATORS = {}
46
45
 
47
- $LOAD_PATH.collect do |d|
48
- File.expand_path d
49
- end.find_all do |d|
50
- File.directory? "#{d}/rdoc/generator"
51
- end.each do |dir|
52
- Dir.entries("#{dir}/rdoc/generator").each do |gen|
53
- next unless /(\w+)\.rb$/ =~ gen
54
- type = $1
55
- unless GENERATORS.has_key? type
56
- GENERATORS[type] = Generator.new("rdoc/generator/#{gen}",
57
- "#{type.upcase}".intern,
58
- type)
59
- end
60
- end
46
+ ##
47
+ # Add +klass+ that can generate output after parsing
48
+
49
+ def self.add_generator(klass)
50
+ name = klass.name.sub(/^RDoc::Generator::/, '').downcase
51
+ GENERATORS[name] = klass
61
52
  end
62
53
 
63
54
  def initialize
@@ -149,7 +140,8 @@ module RDoc
149
140
 
150
141
  relative_files.each do |rel_file_name|
151
142
  next if exclude_pattern && exclude_pattern =~ rel_file_name
152
- stat = File.stat(rel_file_name)
143
+ stat = File.stat rel_file_name rescue next
144
+
153
145
  case type = stat.ftype
154
146
  when "file"
155
147
  next if @last_created and stat.mtime < @last_created
@@ -189,8 +181,6 @@ module RDoc
189
181
  # Parse each file on the command line, recursively entering directories.
190
182
 
191
183
  def parse_files(options)
192
- @stats = Stats.new options.verbosity
193
-
194
184
  files = options.files
195
185
  files = ["."] if files.empty?
196
186
 
@@ -198,33 +188,50 @@ module RDoc
198
188
 
199
189
  return [] if file_list.empty?
200
190
 
191
+ jobs = SizedQueue.new(number_of_threads * 3)
192
+ workers = []
201
193
  file_info = []
202
-
203
- file_list.each do |filename|
204
- @stats.add_file filename
205
-
206
- content = if RUBY_VERSION >= '1.9' then
207
- File.open(filename, "r:ascii-8bit") { |f| f.read }
208
- else
209
- File.read filename
210
- end
211
-
212
- if defined? Encoding then
213
- if /coding:\s*(\S+)/ =~ content[/\A(?:.*\n){0,2}/]
214
- if enc = ::Encoding.find($1)
215
- content.force_encoding(enc)
194
+ file_info_lock = Mutex.new
195
+
196
+ Thread.abort_on_exception = true
197
+ @stats = Stats.new(file_list.size, options.verbosity)
198
+ @stats.begin_adding(number_of_threads)
199
+
200
+ # Create worker threads.
201
+ number_of_threads.times do
202
+ thread = Thread.new do
203
+ while (filename = jobs.pop)
204
+ @stats.add_file(filename)
205
+ content = read_file_contents(filename)
206
+ top_level = ::RDoc::TopLevel.new filename
207
+
208
+ parser = ::RDoc::Parser.for(top_level, filename, content, options,
209
+ @stats)
210
+ result = parser.scan
211
+
212
+ file_info_lock.synchronize do
213
+ file_info << result
216
214
  end
217
215
  end
218
216
  end
217
+ workers << thread
218
+ end
219
219
 
220
- top_level = ::RDoc::TopLevel.new filename
221
-
222
- parser = ::RDoc::Parser.for top_level, filename, content, options,
223
- @stats
220
+ # Feed filenames to the parser worker threads...
221
+ file_list.each do |filename|
222
+ jobs << filename
223
+ end
224
+ workers.size.times do
225
+ jobs << nil
226
+ end
224
227
 
225
- file_info << parser.scan
228
+ # ...and wait until they're done.
229
+ workers.each do |thread|
230
+ thread.join
226
231
  end
227
232
 
233
+ @stats.done_adding
234
+
228
235
  file_info
229
236
  end
230
237
 
@@ -243,7 +250,7 @@ module RDoc
243
250
  def document(argv)
244
251
  TopLevel::reset
245
252
 
246
- @options = Options.new GENERATORS
253
+ @options = Options.new
247
254
  @options.parse argv
248
255
 
249
256
  @last_created = nil
@@ -261,14 +268,12 @@ module RDoc
261
268
  if file_info.empty?
262
269
  $stderr.puts "\nNo newer files." unless @options.quiet
263
270
  else
264
- @gen = @options.generator
271
+ generator = @options.generator
265
272
 
266
- $stderr.puts "\nGenerating #{@gen.key.upcase}..." unless @options.quiet
273
+ $stderr.puts "\nGenerating #{generator.name.sub(/^.*::/, '')}..." unless
274
+ @options.quiet
267
275
 
268
- require @gen.file_name
269
-
270
- gen_class = ::RDoc::Generator.const_get @gen.class_name
271
- @gen = gen_class.for @options
276
+ @gen = generator.for @options
272
277
 
273
278
  pwd = Dir.pwd
274
279
 
@@ -283,11 +288,58 @@ module RDoc
283
288
  end
284
289
  end
285
290
 
286
- unless @options.quiet
291
+ unless @options.quiet or not @stats then
287
292
  puts
288
293
  @stats.print
289
294
  end
290
295
  end
296
+
297
+ private
298
+
299
+ def number_of_threads
300
+ @@number_of_threads ||=
301
+ if RUBY_PLATFORM == "java"
302
+ Java::java::lang::Runtime.getRuntime.availableProcessors * 2
303
+ else
304
+ 2
305
+ end
306
+ end
307
+
308
+ def read_file_contents(filename)
309
+ content = if RUBY_VERSION >= '1.9' then
310
+ File.open(filename, "r:ascii-8bit") { |f| f.read }
311
+ else
312
+ File.read filename
313
+ end
314
+
315
+ if defined? Encoding then
316
+ if /coding:\s*(\S+)/ =~ content[/\A(?:.*\n){0,2}/]
317
+ if enc = ::Encoding.find($1)
318
+ content.force_encoding(enc)
319
+ end
320
+ end
321
+ end
322
+
323
+ content
324
+ end
325
+ end
326
+ end
327
+
328
+ if Gem.respond_to? :find_files then
329
+ rdoc_extensions = Gem.find_files 'rdoc/discover'
330
+
331
+ rdoc_extensions.each do |extension|
332
+ begin
333
+ load extension
334
+ rescue => e
335
+ warn "error loading #{extension.inspect}: #{e.message} (#{e.class})"
336
+ end
291
337
  end
292
338
  end
293
339
 
340
+ # require built-in generators after discovery in case they've been replaced
341
+ require 'rdoc/generator/darkfish'
342
+ require 'rdoc/generator/html'
343
+ require 'rdoc/generator/ri'
344
+ require 'rdoc/generator/xml'
345
+
@@ -20,14 +20,14 @@ class RDoc::RI::ClassEntry
20
20
  @path_names << path
21
21
  end
22
22
 
23
- # read in our methods and any classes
24
- # and modules in our namespace. Methods are
25
- # stored in files called name-c|i.yaml,
26
- # where the 'name' portion is the external
27
- # form of the method name and the c|i is a class|instance
28
- # flag
23
+ ##
24
+ # read in our methods and any classes and modules in our namespace. Methods
25
+ # are stored in files called name-c|i.yaml, where the 'name' portion is the
26
+ # external form of the method name and the c|i is a class|instance flag
29
27
 
30
28
  def load_from(dir)
29
+ return unless File.exist? dir
30
+
31
31
  Dir.foreach(dir) do |name|
32
32
  next if name =~ /^\./
33
33
 
@@ -1,15 +1,5 @@
1
1
  require 'rdoc/ri'
2
2
 
3
- # readline support might not be present, so be careful
4
- # when requiring it.
5
- begin
6
- require('readline')
7
- require('abbrev')
8
- CAN_USE_READLINE = true
9
- rescue
10
- CAN_USE_READLINE = false
11
- end
12
-
13
3
  ##
14
4
  # This is a kind of 'flag' module. If you want to write your own 'ri' display
15
5
  # module (perhaps because you're writing an IDE), you write a class which
@@ -42,6 +32,8 @@ class RDoc::RI::DefaultDisplay
42
32
 
43
33
  include RDoc::RI::Display
44
34
 
35
+ attr_reader :formatter
36
+
45
37
  def initialize(formatter, width, use_stdout, output = $stdout)
46
38
  @use_stdout = use_stdout
47
39
  @formatter = formatter.new output, width, " "
@@ -53,7 +45,7 @@ class RDoc::RI::DefaultDisplay
53
45
 
54
46
  def display_class_info(klass)
55
47
  page do
56
- superclass = klass.superclass_string
48
+ superclass = klass.superclass
57
49
 
58
50
  if superclass
59
51
  superclass = " < " + superclass
@@ -119,64 +111,18 @@ class RDoc::RI::DefaultDisplay
119
111
  return display_class_method_list(klass)
120
112
  end
121
113
  end
122
-
114
+
123
115
  ##
124
116
  # Given a Hash mapping a class' methods to method types (returned by
125
- # display_class_method_list), this method allows the user to
126
- # choose one of the methods.
127
-
128
- def get_class_method_choice(method_map)
129
- if CAN_USE_READLINE
130
- # prepare abbreviations for tab completion
131
- abbreviations = method_map.keys.abbrev
132
- Readline.completion_proc = proc do |string|
133
- abbreviations.values.uniq.grep(/^#{string}/)
134
- end
135
- end
136
-
137
- @formatter.raw_print_line "\nEnter the method name you want.\n"
138
- @formatter.raw_print_line "Class methods can be preceeded by '::' and instance methods by '#'.\n"
139
-
140
- if CAN_USE_READLINE
141
- @formatter.raw_print_line "You can use tab to autocomplete.\n"
142
- @formatter.raw_print_line "Enter a blank line to exit.\n"
143
-
144
- choice_string = Readline.readline(">> ").strip
145
- else
146
- @formatter.raw_print_line "Enter a blank line to exit.\n"
147
- @formatter.raw_print_line ">> "
148
- choice_string = $stdin.gets.strip
149
- end
150
-
151
- if choice_string == ''
152
- return nil
153
- else
154
- class_or_instance = method_map[choice_string]
155
-
156
- if class_or_instance
157
- # If the user's choice is not preceeded by a '::' or a '#', figure
158
- # out whether they want a class or an instance method and decorate
159
- # the choice appropriately.
160
- if(choice_string =~ /^[a-zA-Z]/)
161
- if(class_or_instance == :class)
162
- choice_string = "::#{choice_string}"
163
- else
164
- choice_string = "##{choice_string}"
165
- end
166
- end
117
+ # display_class_method_list), this method allows the user to choose one of
118
+ # the methods.
167
119
 
168
- return choice_string
169
- else
170
- @formatter.raw_print_line "No method matched '#{choice_string}'.\n"
171
- return nil
172
- end
173
- end
120
+ def get_class_method_choice(method_map)
174
121
  end
175
-
176
122
 
177
123
  ##
178
- # Display methods on +klass+
179
- # Returns a hash mapping method name to method contents (HACK?)
124
+ # Display methods on +klass+. Returns a hash mapping method name to method
125
+ # contents
180
126
 
181
127
  def display_class_method_list(klass)
182
128
  method_map = {}
@@ -187,16 +133,16 @@ class RDoc::RI::DefaultDisplay
187
133
  :instance_methods,
188
134
  :instance_method_extensions,
189
135
  ]
190
-
136
+
191
137
  class_data.each do |data_type|
192
138
  data = klass.send data_type
193
-
139
+
194
140
  unless data.nil? or data.empty? then
195
141
  @formatter.blankline
196
-
142
+
197
143
  heading = data_type.to_s.split('_').join(' ').capitalize << ':'
198
144
  @formatter.display_heading heading, 2, ''
199
-
145
+
200
146
  method_names = []
201
147
  data.each do |item|
202
148
  method_names << item.name
@@ -217,7 +163,7 @@ class RDoc::RI::DefaultDisplay
217
163
  end
218
164
  method_names.sort!
219
165
 
220
- @formatter.wrap method_names.join(',')
166
+ @formatter.wrap method_names.join(', ')
221
167
  end
222
168
  end
223
169
 
@@ -268,7 +214,7 @@ class RDoc::RI::DefaultDisplay
268
214
  end
269
215
  end
270
216
  end
271
-
217
+
272
218
  ##
273
219
  # Display a list of +methods+ and allow the user to select one of them.
274
220
 
@@ -280,9 +226,9 @@ class RDoc::RI::DefaultDisplay
280
226
  methods.each_with_index do |method, index|
281
227
  @formatter.raw_print_line "%3d %s [%s]\n" % [index + 1, method.full_name, method.source_path]
282
228
  end
283
-
229
+
284
230
  @formatter.raw_print_line ">> "
285
-
231
+
286
232
  choice = $stdin.gets.strip!
287
233
 
288
234
  if(choice == '')
@@ -294,7 +240,7 @@ class RDoc::RI::DefaultDisplay
294
240
  if ((choice == 0) || (choice > methods.size)) then
295
241
  @formatter.raw_print_line "Invalid choice!\n"
296
242
  else
297
- method = methods[choice - 1]
243
+ method = methods[choice - 1]
298
244
  display_method_info(method)
299
245
  end
300
246
  end
@@ -327,14 +273,16 @@ class RDoc::RI::DefaultDisplay
327
273
  # List the classes in +classes+.
328
274
 
329
275
  def list_known_classes(classes)
330
- if classes.empty?
276
+ if classes.empty? then
331
277
  warn_no_database
332
278
  else
333
279
  page do
334
280
  @formatter.draw_line "Known classes and modules"
335
281
  @formatter.blankline
336
282
 
337
- @formatter.wrap classes.sort.join(', ')
283
+ classes.sort.each do |klass|
284
+ @formatter.wrap klass
285
+ end
338
286
  end
339
287
  end
340
288
  end
@@ -390,4 +338,3 @@ class RDoc::RI::DefaultDisplay
390
338
  end
391
339
 
392
340
  end
393
-