rdoc 2.1.0 → 2.2.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 (57) hide show
  1. data/History.txt +82 -1
  2. data/Manifest.txt +8 -0
  3. data/README.txt +33 -9
  4. data/RI.txt +58 -0
  5. data/Rakefile +2 -0
  6. data/bin/ri +1 -2
  7. data/lib/rdoc.rb +154 -36
  8. data/lib/rdoc/code_objects.rb +38 -2
  9. data/lib/rdoc/diagram.rb +17 -15
  10. data/lib/rdoc/generator.rb +21 -15
  11. data/lib/rdoc/generator/chm/chm.rb +2 -0
  12. data/lib/rdoc/generator/html.rb +137 -89
  13. data/lib/rdoc/generator/html/common.rb +24 -0
  14. data/lib/rdoc/generator/html/frameless.rb +28 -731
  15. data/lib/rdoc/generator/html/hefss.rb +47 -311
  16. data/lib/rdoc/generator/html/html.rb +226 -156
  17. data/lib/rdoc/generator/html/kilmer.rb +31 -298
  18. data/lib/rdoc/generator/html/kilmerfactory.rb +427 -0
  19. data/lib/rdoc/generator/html/one_page_html.rb +6 -5
  20. data/lib/rdoc/generator/texinfo.rb +3 -6
  21. data/lib/rdoc/generator/xml.rb +4 -7
  22. data/lib/rdoc/generator/xml/xml.rb +21 -9
  23. data/lib/rdoc/markup.rb +0 -95
  24. data/lib/rdoc/markup/inline.rb +1 -1
  25. data/lib/rdoc/markup/to_html.rb +9 -6
  26. data/lib/rdoc/markup/to_html_crossref.rb +67 -21
  27. data/lib/rdoc/markup/to_texinfo.rb +1 -1
  28. data/lib/rdoc/parser.rb +22 -1
  29. data/lib/rdoc/parser/c.rb +14 -16
  30. data/lib/rdoc/parser/ruby.rb +3 -3
  31. data/lib/rdoc/parser/simple.rb +1 -1
  32. data/lib/rdoc/rdoc.rb +0 -1
  33. data/lib/rdoc/ri/cache.rb +5 -6
  34. data/lib/rdoc/ri/descriptions.rb +3 -0
  35. data/lib/rdoc/ri/display.rb +157 -37
  36. data/lib/rdoc/ri/driver.rb +314 -198
  37. data/lib/rdoc/ri/formatter.rb +1 -1
  38. data/lib/rdoc/ri/paths.rb +2 -11
  39. data/lib/rdoc/ri/reader.rb +3 -3
  40. data/lib/rdoc/ri/util.rb +0 -2
  41. data/test/binary.dat +0 -0
  42. data/test/rdoc_markup_to_html_crossref_reference.rb +31 -0
  43. data/test/test_attribute_manager.rb +73 -0
  44. data/test/test_rdoc_info_formatting.rb +6 -6
  45. data/test/test_rdoc_info_sections.rb +2 -2
  46. data/test/test_rdoc_markup_attribute_manager.rb +14 -14
  47. data/test/test_rdoc_markup_to_html.rb +15 -3
  48. data/test/test_rdoc_markup_to_html_crossref.rb +276 -7
  49. data/test/test_rdoc_parser.rb +13 -0
  50. data/test/test_rdoc_parser_c.rb +1 -1
  51. data/test/test_rdoc_parser_ruby.rb +72 -1
  52. data/test/test_rdoc_ri_default_display.rb +23 -22
  53. data/test/test_rdoc_ri_driver.rb +1 -1
  54. data/test/test_rdoc_ri_formatter.rb +1 -1
  55. metadata +27 -35
  56. data.tar.gz.sig +0 -1
  57. metadata.gz.sig +0 -0
@@ -11,29 +11,33 @@ require 'rdoc/markup/to_flow'
11
11
 
12
12
  class RDoc::RI::Driver
13
13
 
14
- class Hash < ::Hash
15
- def self.convert(hash)
16
- hash = new.update hash
17
-
18
- hash.each do |key, value|
19
- hash[key] = case value
20
- when ::Hash then
21
- convert value
22
- when Array then
23
- value = value.map do |v|
24
- ::Hash === v ? convert(v) : v
25
- end
26
- value
27
- else
28
- value
29
- end
30
- end
31
-
32
- hash
33
- end
14
+ #
15
+ # This class offers both Hash and OpenStruct functionality.
16
+ # We convert from the Core Hash to this before calling any of
17
+ # the display methods, in order to give the display methods
18
+ # a cleaner API for accessing the data.
19
+ #
20
+ class OpenStructHash < Hash
21
+ #
22
+ # This method converts from a Hash to an OpenStructHash.
23
+ #
24
+ def self.convert(object)
25
+ case object
26
+ when Hash then
27
+ new_hash = new # Convert Hash -> OpenStructHash
28
+
29
+ object.each do |key, value|
30
+ new_hash[key] = convert(value)
31
+ end
34
32
 
35
- def method_missing method, *args
36
- self[method.to_s]
33
+ new_hash
34
+ when Array then
35
+ object.map do |element|
36
+ convert(element)
37
+ end
38
+ else
39
+ object
40
+ end
37
41
  end
38
42
 
39
43
  def merge_enums(other)
@@ -57,6 +61,10 @@ class RDoc::RI::Driver
57
61
  end
58
62
  end
59
63
  end
64
+
65
+ def method_missing method, *args
66
+ self[method.to_s]
67
+ end
60
68
  end
61
69
 
62
70
  class Error < RDoc::RI::Error; end
@@ -74,16 +82,17 @@ class RDoc::RI::Driver
74
82
  options[:use_stdout] = !$stdout.tty?
75
83
  options[:width] = 72
76
84
  options[:formatter] = RDoc::RI::Formatter.for 'plain'
85
+ options[:interactive] = false
77
86
  options[:list_classes] = false
78
87
  options[:list_names] = false
88
+ options[:use_cache] = true
79
89
 
80
- # By default all paths are used. If any of these are true, only those
81
- # directories are used.
82
- use_system = false
83
- use_site = false
84
- use_home = false
85
- use_gems = false
86
- doc_dirs = []
90
+ # By default all standard paths are used.
91
+ options[:use_system] = true
92
+ options[:use_site] = true
93
+ options[:use_home] = true
94
+ options[:use_gems] = true
95
+ options[:extra_doc_dirs] = []
87
96
 
88
97
  opts = OptionParser.new do |opt|
89
98
  opt.program_name = File.basename $0
@@ -150,22 +159,6 @@ Options may also be set in the 'RI' environment variable.
150
159
 
151
160
  opt.separator nil
152
161
 
153
- opt.on("--doc-dir=DIRNAME", "-d", Array,
154
- "List of directories to search for",
155
- "documentation. If not specified, we search",
156
- "the standard rdoc/ri directories. May be",
157
- "repeated.") do |value|
158
- value.each do |dir|
159
- unless File.directory? dir then
160
- raise OptionParser::InvalidArgument, "#{dir} is not a directory"
161
- end
162
- end
163
-
164
- doc_dirs.concat value
165
- end
166
-
167
- opt.separator nil
168
-
169
162
  opt.on("--fmt=FORMAT", "--format=FORMAT", "-f",
170
163
  RDoc::RI::Formatter::FORMATTERS.keys,
171
164
  "Format to use when displaying output:",
@@ -179,49 +172,109 @@ Options may also be set in the 'RI' environment variable.
179
172
 
180
173
  opt.separator nil
181
174
 
182
- unless RDoc::RI::Paths::GEMDIRS.empty? then
183
- opt.on("--[no-]gems",
184
- "Include documentation from RubyGems.") do |value|
185
- use_gems = value
175
+ opt.on("--doc-dir=DIRNAME", "-d", Array,
176
+ "List of directories from which to source",
177
+ "documentation in addition to the standard",
178
+ "directories. May be repeated.") do |value|
179
+ value.each do |dir|
180
+ unless File.directory? dir then
181
+ raise OptionParser::InvalidArgument, "#{dir} is not a directory"
182
+ end
183
+
184
+ options[:extra_doc_dirs] << File.expand_path(dir)
186
185
  end
187
186
  end
188
187
 
189
188
  opt.separator nil
190
189
 
191
- opt.on("--[no-]home",
192
- "Include documentation stored in ~/.rdoc.") do |value|
193
- use_home = value
190
+ opt.on("--[no-]use-cache",
191
+ "Whether or not to use ri's cache.",
192
+ "True by default.") do |value|
193
+ options[:use_cache] = value
194
194
  end
195
195
 
196
196
  opt.separator nil
197
197
 
198
- opt.on("--[no-]list-names", "-l",
199
- "List all the names known to RDoc, one per",
200
- "line.") do |value|
201
- options[:list_names] = value
198
+ opt.on("--no-standard-docs",
199
+ "Do not include documentation from",
200
+ "the Ruby standard library, site_lib,",
201
+ "installed gems, or ~/.rdoc.",
202
+ "Equivalent to specifying",
203
+ "the options --no-system, --no-site, --no-gems,",
204
+ "and --no-home") do
205
+ options[:use_system] = false
206
+ options[:use_site] = false
207
+ options[:use_gems] = false
208
+ options[:use_home] = false
202
209
  end
203
210
 
204
211
  opt.separator nil
205
212
 
206
- opt.on("--no-pager", "-T",
207
- "Send output directly to stdout.") do |value|
208
- options[:use_stdout] = !value
213
+ opt.on("--[no-]system",
214
+ "Include documentation from Ruby's standard",
215
+ "library. Defaults to true.") do |value|
216
+ options[:use_system] = value
209
217
  end
210
218
 
211
219
  opt.separator nil
212
220
 
213
221
  opt.on("--[no-]site",
214
222
  "Include documentation from libraries",
215
- "installed in site_lib.") do |value|
216
- use_site = value
223
+ "installed in site_lib.",
224
+ "Defaults to true.") do |value|
225
+ options[:use_site] = value
217
226
  end
218
227
 
219
228
  opt.separator nil
220
229
 
221
- opt.on("--[no-]system",
222
- "Include documentation from Ruby's standard",
223
- "library.") do |value|
224
- use_system = value
230
+ opt.on("--[no-]gems",
231
+ "Include documentation from RubyGems.",
232
+ "Defaults to true.") do |value|
233
+ options[:use_gems] = value
234
+ end
235
+
236
+ opt.separator nil
237
+
238
+ opt.on("--[no-]home",
239
+ "Include documentation stored in ~/.rdoc.",
240
+ "Defaults to true.") do |value|
241
+ options[:use_home] = value
242
+ end
243
+
244
+ opt.separator nil
245
+
246
+ opt.on("--list-doc-dirs",
247
+ "List the directories from which ri will",
248
+ "source documentation on stdout and exit.") do
249
+ options[:list_doc_dirs] = true
250
+ end
251
+
252
+ opt.separator nil
253
+
254
+ opt.on("--list-names", "-l",
255
+ "List all the names known to RDoc, one per",
256
+ "line.") do
257
+ options[:list_names] = true
258
+ end
259
+
260
+ opt.separator nil
261
+
262
+ opt.on("--no-pager", "-T",
263
+ "Send output directly to stdout,",
264
+ "rather than to a pager.") do
265
+ options[:use_stdout] = true
266
+ end
267
+
268
+ opt.on("--interactive", "-i",
269
+ "This makes ri go into interactive mode.",
270
+ "When ri is in interactive mode it will",
271
+ "allow the user to disambiguate lists of",
272
+ "methods in case multiple methods match",
273
+ "against a method search string. It also",
274
+ "will allow the user to enter in a method",
275
+ "name (with auto-completion, if readline",
276
+ "is supported) when viewing a class.") do
277
+ options[:interactive] = true
225
278
  end
226
279
 
227
280
  opt.separator nil
@@ -238,10 +291,10 @@ Options may also be set in the 'RI' environment variable.
238
291
 
239
292
  options[:names] = argv
240
293
 
241
- options[:path] = RDoc::RI::Paths.path(use_system, use_site, use_home,
242
- use_gems, *doc_dirs)
243
- options[:raw_path] = RDoc::RI::Paths.raw_path(use_system, use_site,
244
- use_home, use_gems, *doc_dirs)
294
+ options[:formatter] ||= RDoc::RI::Formatter.for('plain')
295
+ options[:use_stdout] ||= !$stdout.tty?
296
+ options[:use_stdout] ||= options[:interactive]
297
+ options[:width] ||= 72
245
298
 
246
299
  options
247
300
 
@@ -259,21 +312,28 @@ Options may also be set in the 'RI' environment variable.
259
312
  end
260
313
 
261
314
  def initialize(options={})
262
- options[:formatter] ||= RDoc::RI::Formatter.for('plain')
263
- options[:use_stdout] ||= !$stdout.tty?
264
- options[:width] ||= 72
265
315
  @names = options[:names]
266
316
 
267
317
  @class_cache_name = 'classes'
268
- @all_dirs = RDoc::RI::Paths.path(true, true, true, true)
318
+
319
+ @doc_dirs = RDoc::RI::Paths.path(options[:use_system],
320
+ options[:use_site],
321
+ options[:use_home],
322
+ options[:use_gems],
323
+ options[:extra_doc_dirs])
324
+
269
325
  @homepath = RDoc::RI::Paths.raw_path(false, false, true, false).first
270
326
  @homepath = @homepath.sub(/\.rdoc/, '.ri')
271
- @sys_dirs = RDoc::RI::Paths.raw_path(true, false, false, false)
327
+ @sys_dir = RDoc::RI::Paths.raw_path(true, false, false, false).first
328
+ @list_doc_dirs = options[:list_doc_dirs]
272
329
 
273
330
  FileUtils.mkdir_p cache_file_path unless File.directory? cache_file_path
331
+ @cache_doc_dirs_path = File.join cache_file_path, ".doc_dirs"
274
332
 
333
+ @use_cache = options[:use_cache]
275
334
  @class_cache = nil
276
335
 
336
+ @interactive = options[:interactive]
277
337
  @display = RDoc::RI::DefaultDisplay.new(options[:formatter],
278
338
  options[:width],
279
339
  options[:use_stdout])
@@ -282,30 +342,92 @@ Options may also be set in the 'RI' environment variable.
282
342
  def class_cache
283
343
  return @class_cache if @class_cache
284
344
 
285
- newest = map_dirs('created.rid', :all) do |f|
345
+ # Get the documentation directories used to make the cache in order to see
346
+ # whether the cache is valid for the current ri instantiation.
347
+ if(File.readable?(@cache_doc_dirs_path))
348
+ cache_doc_dirs = IO.read(@cache_doc_dirs_path).split("\n")
349
+ else
350
+ cache_doc_dirs = []
351
+ end
352
+
353
+ newest = map_dirs('created.rid') do |f|
286
354
  File.mtime f if test ?f, f
287
355
  end.max
288
356
 
357
+ # An up to date cache file must have been created more recently than
358
+ # the last modification of any of the documentation directories. It also
359
+ # must have been created with the same documentation directories
360
+ # as those from which ri currently is sourcing documentation.
289
361
  up_to_date = (File.exist?(class_cache_file_path) and
290
- newest and newest < File.mtime(class_cache_file_path))
362
+ newest and newest < File.mtime(class_cache_file_path) and
363
+ (cache_doc_dirs == @doc_dirs))
364
+
365
+ if up_to_date and @use_cache then
366
+ open class_cache_file_path, 'rb' do |fp|
367
+ begin
368
+ @class_cache = Marshal.load fp.read
369
+ rescue
370
+ #
371
+ # This shouldn't be necessary, since the up_to_date logic above
372
+ # should force the cache to be recreated when a new version of
373
+ # rdoc is installed. This seems like a worthwhile enhancement
374
+ # to ri's robustness, however.
375
+ #
376
+ $stderr.puts "Error reading the class cache; recreating the class cache!"
377
+ @class_cache = create_class_cache
378
+ end
379
+ end
380
+ else
381
+ @class_cache = create_class_cache
382
+ end
383
+
384
+ @class_cache
385
+ end
386
+
387
+ def create_class_cache
388
+ class_cache = OpenStructHash.new
291
389
 
292
- @class_cache = if up_to_date then
293
- load_cache_for @class_cache_name
294
- else
295
- class_cache = RDoc::RI::Driver::Hash.new
390
+ if(@use_cache)
391
+ # Dump the documentation directories to a file in the cache, so that
392
+ # we only will use the cache for future instantiations with identical
393
+ # documentation directories.
394
+ File.open @cache_doc_dirs_path, "wb" do |fp|
395
+ fp << @doc_dirs.join("\n")
396
+ end
397
+ end
296
398
 
297
- classes = map_dirs('**/cdesc*.yaml', :sys) { |f| Dir[f] }
298
- populate_class_cache class_cache, classes
399
+ classes = map_dirs('**/cdesc*.yaml') { |f| Dir[f] }
400
+ warn "Updating class cache with #{classes.size} classes..."
401
+ populate_class_cache class_cache, classes
299
402
 
300
- classes = map_dirs('**/cdesc*.yaml') { |f| Dir[f] }
301
- warn "Updating class cache with #{classes.size} classes..."
403
+ write_cache class_cache, class_cache_file_path
302
404
 
303
- populate_class_cache class_cache, classes, true
304
- write_cache class_cache, class_cache_file_path
305
- end
405
+ class_cache
406
+ end
306
407
 
307
- @class_cache = RDoc::RI::Driver::Hash.convert @class_cache
308
- @class_cache
408
+ def populate_class_cache(class_cache, classes, extension = false)
409
+ classes.each do |cdesc|
410
+ desc = read_yaml cdesc
411
+ klassname = desc["full_name"]
412
+
413
+ unless class_cache.has_key? klassname then
414
+ desc["display_name"] = "Class"
415
+ desc["sources"] = [cdesc]
416
+ desc["instance_method_extensions"] = []
417
+ desc["class_method_extensions"] = []
418
+ class_cache[klassname] = desc
419
+ else
420
+ klass = class_cache[klassname]
421
+
422
+ if extension then
423
+ desc["instance_method_extensions"] = desc.delete "instance_methods"
424
+ desc["class_method_extensions"] = desc.delete "class_methods"
425
+ end
426
+
427
+ klass.merge_enums desc
428
+ klass["sources"] << cdesc
429
+ end
430
+ end
309
431
  end
310
432
 
311
433
  def class_cache_file_path
@@ -322,8 +444,11 @@ Options may also be set in the 'RI' environment variable.
322
444
 
323
445
  def display_class(name)
324
446
  klass = class_cache[name]
325
- klass = RDoc::RI::Driver::Hash.convert klass
326
- @display.display_class_info klass, class_cache
447
+ @display.display_class_info klass
448
+ end
449
+
450
+ def display_method(method)
451
+ @display.display_method_info method
327
452
  end
328
453
 
329
454
  def get_info_for(arg)
@@ -337,42 +462,59 @@ Options may also be set in the 'RI' environment variable.
337
462
  cache = nil
338
463
 
339
464
  if File.exist? path and
340
- File.mtime(path) >= File.mtime(class_cache_file_path) then
465
+ File.mtime(path) >= File.mtime(class_cache_file_path) and
466
+ @use_cache then
341
467
  open path, 'rb' do |fp|
342
- cache = Marshal.load fp.read
468
+ begin
469
+ cache = Marshal.load fp.read
470
+ rescue
471
+ #
472
+ # The cache somehow is bad. Recreate the cache.
473
+ #
474
+ $stderr.puts "Error reading the cache for #{klassname}; recreating the cache!"
475
+ cache = create_cache_for klassname, path
476
+ end
343
477
  end
344
478
  else
345
- class_cache = nil
479
+ cache = create_cache_for klassname, path
480
+ end
346
481
 
347
- open class_cache_file_path, 'rb' do |fp|
348
- class_cache = Marshal.load fp.read
349
- end
482
+ cache
483
+ end
484
+
485
+ def create_cache_for(klassname, path)
486
+ klass = class_cache[klassname]
487
+ return nil unless klass
488
+
489
+ method_files = klass["sources"]
490
+ cache = OpenStructHash.new
350
491
 
351
- klass = class_cache[klassname]
352
- return nil unless klass
353
-
354
- method_files = klass["sources"]
355
- cache = RDoc::RI::Driver::Hash.new
356
-
357
- sys_dir = @sys_dirs.first
358
- method_files.each do |f|
359
- system_file = f.index(sys_dir) == 0
360
- Dir[File.join(File.dirname(f), "*")].each do |yaml|
361
- next unless yaml =~ /yaml$/
362
- next if yaml =~ /cdesc-[^\/]+yaml$/
363
- method = read_yaml yaml
364
- name = method["full_name"]
365
- ext_path = f
366
- ext_path = "gem #{$1}" if f =~ %r%gems/[\d.]+/doc/([^/]+)%
367
- method["source_path"] = ext_path unless system_file
368
- cache[name] = RDoc::RI::Driver::Hash.convert method
492
+ method_files.each do |f|
493
+ system_file = f.index(@sys_dir) == 0
494
+ Dir[File.join(File.dirname(f), "*")].each do |yaml|
495
+ next unless yaml =~ /yaml$/
496
+ next if yaml =~ /cdesc-[^\/]+yaml$/
497
+
498
+ method = read_yaml yaml
499
+
500
+ if system_file then
501
+ method["source_path"] = "Ruby #{RDoc::RI::Paths::VERSION}"
502
+ else
503
+ if(f =~ %r%gems/[\d.]+/doc/([^/]+)%) then
504
+ ext_path = "gem #{$1}"
505
+ else
506
+ ext_path = f
507
+ end
508
+
509
+ method["source_path"] = ext_path
369
510
  end
370
- end
371
511
 
372
- write_cache cache, path
512
+ name = method["full_name"]
513
+ cache[name] = method
514
+ end
373
515
  end
374
-
375
- RDoc::RI::Driver::Hash.convert cache
516
+
517
+ write_cache cache, path
376
518
  end
377
519
 
378
520
  ##
@@ -406,20 +548,10 @@ Options may also be set in the 'RI' environment variable.
406
548
  method
407
549
  end
408
550
 
409
- def map_dirs(file_name, system=false)
410
- dirs = if system == :all then
411
- @all_dirs
412
- else
413
- if system then
414
- @sys_dirs
415
- else
416
- @all_dirs - @sys_dirs
417
- end
418
- end
419
-
420
- dirs.map { |dir| yield File.join(dir, file_name) }.flatten.compact
551
+ def map_dirs(file_name)
552
+ @doc_dirs.map { |dir| yield File.join(dir, file_name) }.flatten.compact
421
553
  end
422
-
554
+
423
555
  ##
424
556
  # Extract the class and method name parts from +name+ like Foo::Bar#baz
425
557
 
@@ -436,83 +568,66 @@ Options may also be set in the 'RI' environment variable.
436
568
  [klass, meth]
437
569
  end
438
570
 
439
- def populate_class_cache(class_cache, classes, extension = false)
440
- classes.each do |cdesc|
441
- desc = read_yaml cdesc
442
- klassname = desc["full_name"]
443
-
444
- unless class_cache.has_key? klassname then
445
- desc["display_name"] = "Class"
446
- desc["sources"] = [cdesc]
447
- desc["instance_method_extensions"] = []
448
- desc["class_method_extensions"] = []
449
- class_cache[klassname] = desc
450
- else
451
- klass = class_cache[klassname]
452
-
453
- if extension then
454
- desc["instance_method_extensions"] = desc.delete "instance_methods"
455
- desc["class_method_extensions"] = desc.delete "class_methods"
456
- end
457
-
458
- klass = RDoc::RI::Driver::Hash.convert klass
459
-
460
- klass.merge_enums desc
461
- klass["sources"] << cdesc
462
- end
463
- end
464
- end
465
-
466
571
  def read_yaml(path)
467
572
  data = File.read path
573
+
574
+ # Necessary to be backward-compatible with documentation generated
575
+ # by earliar RDoc versions.
468
576
  data = data.gsub(/ \!ruby\/(object|struct):(RDoc::RI|RI).*/, '')
469
577
  data = data.gsub(/ \!ruby\/(object|struct):SM::(\S+)/,
470
578
  ' !ruby/\1:RDoc::Markup::\2')
471
- YAML.load data
579
+ OpenStructHash.convert(YAML.load(data))
472
580
  end
473
581
 
474
582
  def run
475
- if @names.empty? then
583
+ if(@list_doc_dirs)
584
+ puts @doc_dirs.join("\n")
585
+ elsif @names.empty? then
476
586
  @display.list_known_classes class_cache.keys.sort
477
587
  else
478
588
  @names.each do |name|
479
- case name
480
- when /::|\#|\./ then
481
- if class_cache.key? name then
482
- display_class name
483
- else
484
- klass, = parse_name name
485
-
486
- orig_klass = klass
487
- orig_name = name
488
-
489
- until klass == 'Kernel' do
490
- method = lookup_method name, klass
491
-
492
- break method if method
493
-
494
- ancestor = lookup_ancestor klass, orig_klass
495
-
496
- break unless ancestor
497
-
498
- name = name.sub klass, ancestor
499
- klass = ancestor
589
+ if class_cache.key? name then
590
+ method_map = display_class name
591
+ if(@interactive)
592
+ method_name = @display.get_class_method_choice(method_map)
593
+
594
+ if(method_name != nil)
595
+ method = lookup_method "#{name}#{method_name}", name
596
+ display_method method
500
597
  end
501
-
502
- raise NotFoundError, orig_name unless method
503
-
504
- @display.display_method_info method
505
598
  end
599
+ elsif name =~ /::|\#|\./ then
600
+ klass, = parse_name name
601
+
602
+ orig_klass = klass
603
+ orig_name = name
604
+
605
+ loop do
606
+ method = lookup_method name, klass
607
+
608
+ break method if method
609
+
610
+ ancestor = lookup_ancestor klass, orig_klass
611
+
612
+ break unless ancestor
613
+
614
+ name = name.sub klass, ancestor
615
+ klass = ancestor
616
+ end
617
+
618
+ raise NotFoundError, orig_name unless method
619
+
620
+ display_method method
506
621
  else
507
- if class_cache.key? name then
508
- display_class name
622
+ methods = select_methods(/#{name}/)
623
+
624
+ if methods.size == 0
625
+ raise NotFoundError, name
626
+ elsif methods.size == 1
627
+ display_method methods[0]
509
628
  else
510
- methods = select_methods(/^#{name}/)
511
-
512
- if methods.size == 0
513
- raise NotFoundError, name
514
- elsif methods.size == 1
515
- @display.display_method_info methods.first
629
+ if(@interactive)
630
+ @display.display_method_list_choice methods
516
631
  else
517
632
  @display.display_method_list methods
518
633
  end
@@ -540,12 +655,13 @@ Options may also be set in the 'RI' environment variable.
540
655
  end
541
656
 
542
657
  def write_cache(cache, path)
543
- File.open path, "wb" do |cache_file|
544
- Marshal.dump cache, cache_file
658
+ if(@use_cache)
659
+ File.open path, "wb" do |cache_file|
660
+ Marshal.dump cache, cache_file
661
+ end
545
662
  end
546
-
663
+
547
664
  cache
548
665
  end
549
666
 
550
667
  end
551
-