rdoc 2.5 → 2.5.1

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 (56) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +1 -1
  3. data/History.txt +41 -8
  4. data/Manifest.txt +1 -0
  5. data/lib/rdoc.rb +7 -7
  6. data/lib/rdoc/any_method.rb +24 -8
  7. data/lib/rdoc/attr.rb +13 -0
  8. data/lib/rdoc/class_module.rb +5 -3
  9. data/lib/rdoc/code_object.rb +0 -19
  10. data/lib/rdoc/generator/darkfish.rb +44 -42
  11. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +5 -5
  12. data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +7 -7
  13. data/lib/rdoc/generator/template/darkfish/rdoc.css +2 -2
  14. data/lib/rdoc/markup.rb +7 -7
  15. data/lib/rdoc/markup/parser.rb +1 -1
  16. data/lib/rdoc/markup/preprocess.rb +1 -1
  17. data/lib/rdoc/markup/to_html.rb +1 -1
  18. data/lib/rdoc/options.rb +1 -1
  19. data/lib/rdoc/parser.rb +5 -5
  20. data/lib/rdoc/parser/c.rb +54 -17
  21. data/lib/rdoc/parser/perl.rb +8 -8
  22. data/lib/rdoc/parser/ruby.rb +24 -29
  23. data/lib/rdoc/rdoc.rb +30 -18
  24. data/lib/rdoc/ri/driver.rb +7 -15
  25. data/lib/rdoc/ri/paths.rb +1 -2
  26. data/lib/rdoc/ruby_lex.rb +12 -12
  27. data/lib/rdoc/ruby_token.rb +4 -4
  28. data/lib/rdoc/stats.rb +2 -2
  29. data/lib/rdoc/task.rb +9 -5
  30. data/test/test.txt +1 -0
  31. data/test/test_rdoc_any_method.rb +50 -8
  32. data/test/test_rdoc_attr.rb +8 -0
  33. data/test/test_rdoc_class_module.rb +1 -1
  34. data/test/test_rdoc_code_object.rb +2 -2
  35. data/test/test_rdoc_constant.rb +1 -1
  36. data/test/test_rdoc_context.rb +2 -2
  37. data/test/test_rdoc_include.rb +1 -1
  38. data/test/test_rdoc_markup_parser.rb +18 -0
  39. data/test/test_rdoc_markup_to_ansi.rb +1 -1
  40. data/test/test_rdoc_markup_to_html_crossref.rb +1 -1
  41. data/test/test_rdoc_markup_to_rdoc.rb +1 -1
  42. data/test/test_rdoc_normal_class.rb +1 -1
  43. data/test/test_rdoc_normal_module.rb +1 -1
  44. data/test/test_rdoc_parser.rb +2 -6
  45. data/test/test_rdoc_parser_c.rb +20 -0
  46. data/test/test_rdoc_parser_ruby.rb +1 -1
  47. data/test/test_rdoc_rdoc.rb +2 -2
  48. data/test/test_rdoc_require.rb +1 -1
  49. data/test/test_rdoc_ri_driver.rb +27 -6
  50. data/test/test_rdoc_ri_paths.rb +10 -6
  51. data/test/test_rdoc_task.rb +9 -9
  52. data/test/test_rdoc_top_level.rb +1 -1
  53. data/test/xref_data.rb +1 -1
  54. data/test/xref_test_case.rb +1 -1
  55. metadata +4 -2
  56. metadata.gz.sig +0 -0
@@ -1,9 +1,9 @@
1
1
  /*
2
2
  * "Darkfish" Rdoc CSS
3
3
  * $Id: rdoc.css 54 2009-01-27 01:09:48Z deveiant $
4
- *
4
+ *
5
5
  * Author: Michael Granger <ged@FaerieMUD.org>
6
- *
6
+ *
7
7
  */
8
8
 
9
9
  /* Base Green is: #6C8C22 */
@@ -27,9 +27,9 @@ require 'rdoc'
27
27
  # convert multiple input strings.
28
28
  #
29
29
  # require 'rdoc/markup/to_html'
30
- #
30
+ #
31
31
  # h = RDoc::Markup::ToHtml.new
32
- #
32
+ #
33
33
  # puts h.convert(input_string)
34
34
  #
35
35
  # You can extend the RDoc::Markup parser to recognise new markup
@@ -41,22 +41,22 @@ require 'rdoc'
41
41
  #
42
42
  # require 'rdoc/markup'
43
43
  # require 'rdoc/markup/to_html'
44
- #
44
+ #
45
45
  # class WikiHtml < RDoc::Markup::ToHtml
46
46
  # def handle_special_WIKIWORD(special)
47
47
  # "<font color=red>" + special.text + "</font>"
48
48
  # end
49
49
  # end
50
- #
50
+ #
51
51
  # m = RDoc::Markup.new
52
52
  # m.add_word_pair("{", "}", :STRIKE)
53
53
  # m.add_html("no", :STRIKE)
54
- #
54
+ #
55
55
  # m.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
56
- #
56
+ #
57
57
  # wh = WikiHtml.new
58
58
  # wh.add_tag(:STRIKE, "<strike>", "</strike>")
59
- #
59
+ #
60
60
  # puts "<body>#{wh.convert ARGF.read}</body>"
61
61
  #
62
62
  #--
@@ -463,7 +463,7 @@ class RDoc::Markup::Parser
463
463
  token
464
464
  when s.scan(/ +/) then
465
465
  [:INDENT, s.matched_size, *token_pos(pos)]
466
- when s.scan(/(=+)\s+/) then
466
+ when s.scan(/(=+)\s*/) then
467
467
  level = s[1].length
468
468
  level = 6 if level > 6
469
469
  @tokens << [:HEADER, level, *token_pos(pos)]
@@ -67,7 +67,7 @@ class RDoc::Markup::PreProcess
67
67
  # and then in each of the directories specified in the RDOC_INCLUDE path
68
68
 
69
69
  def find_include_file(name)
70
- to_search = [ File.dirname(@input_file_name) ].concat @include_path
70
+ to_search = [File.dirname(@input_file_name)].concat @include_path
71
71
  to_search.each do |dir|
72
72
  full_name = File.join(dir, name)
73
73
  stat = File.stat(full_name) rescue next
@@ -290,7 +290,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
290
290
  # Determins the HTML list element for +list_type+ and +open_tag+
291
291
 
292
292
  def html_list_name(list_type, open_tag)
293
- tags = LIST_TYPE_TO_HTML[list_type]
293
+ tags = LIST_TYPE_TO_HTML[list_type]
294
294
  raise RDoc::Error, "Invalid list type: #{list_type.inspect}" unless tags
295
295
  annotate tags[open_tag ? 0 : 1]
296
296
  end
@@ -193,7 +193,7 @@ Usage: #{opt.program_name} [options] [names...]
193
193
 
194
194
  opt.separator nil
195
195
 
196
- opt.on("--force-update", "-U",
196
+ opt.on("--[no-]force-update", "-U",
197
197
  "Forces rdoc to scan all sources even if",
198
198
  "newer than the flag file.") do |value|
199
199
  @force_update = value
@@ -22,14 +22,14 @@ require 'rdoc/stats'
22
22
  # following incantation
23
23
  #
24
24
  # require "rdoc/parser"
25
- #
25
+ #
26
26
  # class RDoc::Parser::Xyz < RDoc::Parser
27
27
  # parse_files_matching /\.xyz$/ # <<<<
28
- #
28
+ #
29
29
  # def initialize(file_name, body, options)
30
30
  # ...
31
31
  # end
32
- #
32
+ #
33
33
  # def scan
34
34
  # ...
35
35
  # end
@@ -67,7 +67,7 @@ class RDoc::Parser
67
67
  # content that an RDoc parser shouldn't try to consume.
68
68
 
69
69
  def self.binary?(file)
70
- s = File.read(file, File.stat(file).blksize) || ""
70
+ s = File.read(file, 1024) or return false
71
71
 
72
72
  if s[0, 2] == Marshal.dump('')[0, 2] then
73
73
  true
@@ -89,7 +89,7 @@ class RDoc::Parser
89
89
 
90
90
  def self.zip? file
91
91
  zip_signature = File.read file, 4
92
-
92
+
93
93
  zip_signature == "PK\x03\x04" or
94
94
  zip_signature == "PK\x05\x06" or
95
95
  zip_signature == "PK\x07\x08"
@@ -65,7 +65,7 @@ require 'rdoc/known_classes'
65
65
  # Ruby function is in the same source file as the rb_define_method call.
66
66
  # If this isn't the case, add the comment:
67
67
  #
68
- # rb_define_method(....); // in: filename
68
+ # rb_define_method(....); // in filename
69
69
  #
70
70
  # As an example, we might have an extension that defines multiple classes
71
71
  # in its Init_xxx method. We could document them using
@@ -76,7 +76,7 @@ require 'rdoc/known_classes'
76
76
  # * Encapsulate the writing and reading of the configuration
77
77
  # * file. ...
78
78
  # */
79
- #
79
+ #
80
80
  # /*
81
81
  # * Document-method: read_value
82
82
  # *
@@ -227,8 +227,8 @@ class RDoc::Parser::C < RDoc::Parser
227
227
  next if var_name == "argf" # it'd be nice to handle this one
228
228
 
229
229
  var_name = "rb_cObject" if var_name == "rb_mKernel"
230
- handle_method(type, var_name, meth_name,
231
- meth_body, param_count, source_file)
230
+ handle_method(type, var_name, meth_name, meth_body, param_count,
231
+ source_file)
232
232
  end
233
233
 
234
234
  @content.scan(%r{rb_define_attr\(
@@ -304,7 +304,7 @@ class RDoc::Parser::C < RDoc::Parser
304
304
 
305
305
  find_modifiers comment, meth_obj if comment
306
306
 
307
- # meth_obj.params = params
307
+ #meth_obj.params = params
308
308
  meth_obj.start_collecting_tokens
309
309
  tk = RDoc::RubyToken::Token.new nil, 1, 1
310
310
  tk.set_text body_text
@@ -390,14 +390,20 @@ class RDoc::Parser::C < RDoc::Parser
390
390
  void\s+
391
391
  Init_#{class_name}\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)}xmi then # )
392
392
  comment = $1
393
- elsif @content =~ %r{Document-(?:class|module):\s+#{class_name}\s*?(?:<\s+[:,\w]+)?\n((?>.*?\*/))}m then
393
+ elsif @content =~ %r{Document-(?:class|module):\s+#{class_name}\s*?(?:<\s+[:,\w]+)?\n((?>.*?\*/))}m then # "
394
394
  comment = $1
395
395
  elsif @content =~ %r{((?>/\*.*?\*/\s+))
396
396
  ([\w\.\s]+\s* = \s+)?rb_define_(class|module).*?"(#{class_name})"}xm then
397
397
  comment = $1
398
398
  end
399
399
 
400
- class_mod.comment = strip_stars comment if comment
400
+ return unless comment
401
+
402
+ comment = strip_stars comment
403
+
404
+ comment = look_for_directives_in class_mod, comment
405
+
406
+ class_mod.comment = comment
401
407
  end
402
408
 
403
409
  ##
@@ -479,7 +485,7 @@ class RDoc::Parser::C < RDoc::Parser
479
485
  end
480
486
 
481
487
  unless enclosure then
482
- warn("Enclosing class/module '#{in_module}' for #{type} #{class_name} not known")
488
+ warn "Enclosing class/module '#{in_module}' for #{type} #{class_name} not known"
483
489
  return
484
490
  end
485
491
  else
@@ -601,9 +607,9 @@ class RDoc::Parser::C < RDoc::Parser
601
607
  meth_obj = RDoc::AnyMethod.new '', meth_name
602
608
  meth_obj.singleton = %w[singleton_method module_function].include? type
603
609
 
604
- p_count = (Integer(param_count) rescue -1)
610
+ p_count = Integer(param_count) rescue -1
605
611
 
606
- if p_count < 0
612
+ if p_count < 0 then
607
613
  meth_obj.params = "(...)"
608
614
  elsif p_count == 0
609
615
  meth_obj.params = "()"
@@ -611,11 +617,14 @@ class RDoc::Parser::C < RDoc::Parser
611
617
  meth_obj.params = "(" + (1..p_count).map{|i| "p#{i}"}.join(", ") + ")"
612
618
  end
613
619
 
614
- if source_file and File.exist? source_file then
615
- file_name = File.join(@file_dir, source_file)
616
- body = (@@known_bodies[source_file] ||= File.read(file_name))
617
- elsif source_file then
618
- warn "unknown source file #{source_file}"
620
+ if source_file then
621
+ file_name = File.join @file_dir, source_file
622
+
623
+ if File.exist? file_name then
624
+ body = (@@known_bodies[file_name] ||= File.read(file_name))
625
+ else
626
+ warn "unknown source #{source_file} for #{meth_name} in #{@file_name}"
627
+ end
619
628
  else
620
629
  body = @content
621
630
  end
@@ -640,6 +649,34 @@ class RDoc::Parser::C < RDoc::Parser
640
649
  end
641
650
  end
642
651
 
652
+ ##
653
+ # Look for directives in a normal comment block:
654
+ #
655
+ # /*
656
+ # * :title: My Awesome Project
657
+ # */
658
+ #
659
+ # This routine modifies it's parameter
660
+
661
+ def look_for_directives_in(context, comment)
662
+ preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include
663
+
664
+ preprocess.handle comment do |directive, param|
665
+ case directive
666
+ when 'main' then
667
+ @options.main_page = param
668
+ ''
669
+ when 'title' then
670
+ @options.title = param
671
+ ''
672
+ else
673
+ warn "Unrecognized directive :#{directive}:"
674
+ false
675
+ end
676
+ end
677
+
678
+ comment
679
+ end
643
680
  ##
644
681
  # Removes lines that are commented out that might otherwise get picked up
645
682
  # when scanning for classes and methods
@@ -649,8 +686,8 @@ class RDoc::Parser::C < RDoc::Parser
649
686
  end
650
687
 
651
688
  def remove_private_comments(comment)
652
- comment.gsub!(/\/?\*--\n(.*?)\/?\*\+\+/m, '')
653
- comment.sub!(/\/?\*--\n.*/m, '')
689
+ comment.gsub!(/\/?\*--\n(.*?)\/?\*\+\+/m, '')
690
+ comment.sub!(/\/?\*--\n.*/m, '')
654
691
  end
655
692
 
656
693
  ##
@@ -15,7 +15,7 @@ require 'rdoc/parser'
15
15
  #
16
16
  # We would like to support all the markup the POD provides
17
17
  # so that it will convert happily to HTML. At the moment
18
- # I don't think I can do that: time constraints.
18
+ # I don't think I can do that: time constraints.
19
19
  #
20
20
 
21
21
  class RDoc::Parser::PerlPOD < RDoc::Parser
@@ -45,39 +45,39 @@ class RDoc::Parser::PerlPOD < RDoc::Parser
45
45
  # but I think it would obscure the intent, scatter the
46
46
  # code all over tha place. This machine is necessary
47
47
  # because POD requires that directives be preceded by
48
- # blank lines, so reading line by line is necessary,
48
+ # blank lines, so reading line by line is necessary,
49
49
  # and preserving state about what is seen is necesary.
50
50
 
51
51
  def scan
52
52
 
53
53
  @top_level.comment ||= ""
54
- state=:code_blank
54
+ state=:code_blank
55
55
  line_number = 0
56
56
  line = nil
57
57
 
58
58
  # This started out as a really long nested case statement,
59
59
  # which also led to repetitive code. I'd like to avoid that
60
60
  # so I'm using a "table" instead.
61
-
61
+
62
62
  # Firstly we need some procs to do the transition and processing
63
63
  # work. Because these are procs they are closures, and they can
64
64
  # use variables in the local scope.
65
65
  #
66
66
  # First, the "nothing to see here" stuff.
67
- code_noop = lambda do
67
+ code_noop = lambda do
68
68
  if line =~ /^\s+$/
69
69
  state = :code_blank
70
70
  end
71
71
  end
72
72
 
73
- pod_noop = lambda do
73
+ pod_noop = lambda do
74
74
  if line =~ /^\s+$/
75
75
  state = :pod_blank
76
76
  end
77
77
  @top_level.comment += filter(line)
78
78
  end
79
79
 
80
- begin_noop = lambda do
80
+ begin_noop = lambda do
81
81
  if line =~ /^\s+$/
82
82
  state = :begin_blank
83
83
  end
@@ -151,7 +151,7 @@ class RDoc::Parser::PerlPOD < RDoc::Parser
151
151
  def filter(comment)
152
152
  return '' if comment =~ /^=pod\s*$/
153
153
  comment.gsub!(/^=pod/, '==')
154
- comment.gsub!(/^=head(\d+)/) do
154
+ comment.gsub!(/^=head(\d+)/) do
155
155
  "=" * $1.to_i
156
156
  end
157
157
  comment.gsub!(/=item/, '');
@@ -50,7 +50,7 @@ $TOKEN_DEBUG ||= nil
50
50
  #
51
51
  # ##
52
52
  # # This method tries over and over until it is tired
53
- #
53
+ #
54
54
  # def go_go_go(thing_to_try, tries = 10) # :args: thing_to_try
55
55
  # puts thing_to_try
56
56
  # go_go_go thing_to_try, tries - 1
@@ -70,7 +70,7 @@ $TOKEN_DEBUG ||= nil
70
70
  # # :call-seq:
71
71
  # # my_method(Range)
72
72
  # # my_method(offset, length)
73
- #
73
+ #
74
74
  # def my_method(*args)
75
75
  # end
76
76
  #
@@ -81,7 +81,7 @@ $TOKEN_DEBUG ||= nil
81
81
  #
82
82
  # ##
83
83
  # # My method is awesome
84
- #
84
+ #
85
85
  # def my_method(&block) # :yields: happy, times
86
86
  # block.call 1, 2
87
87
  # end
@@ -93,7 +93,7 @@ $TOKEN_DEBUG ||= nil
93
93
  #
94
94
  # ##
95
95
  # # This is a meta-programmed method!
96
- #
96
+ #
97
97
  # add_my_method :meta_method, :arg1, :arg2
98
98
  #
99
99
  # The parser looks at the token after the identifier to determine the name, in
@@ -131,14 +131,14 @@ $TOKEN_DEBUG ||= nil
131
131
  # ##
132
132
  # # :attr_writer: ghost_writer
133
133
  # # There is an attribute here, but you can't see it!
134
- #
134
+ #
135
135
  # ##
136
136
  # # :method: ghost_method
137
137
  # # There is a method here, but you can't see it!
138
- #
138
+ #
139
139
  # ##
140
140
  # # this is a comment for a regular method
141
- #
141
+ #
142
142
  # def regular_method() end
143
143
  #
144
144
  # Note that by default, the :method: directive will be ignored if there is a
@@ -212,7 +212,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
212
212
  def error(msg)
213
213
  msg = make_message msg
214
214
  $stderr.puts msg
215
- exit(1)
215
+ exit false
216
216
  end
217
217
 
218
218
  ##
@@ -377,10 +377,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
377
377
  # This routine modifies it's parameter
378
378
 
379
379
  def look_for_directives_in(context, comment)
380
- preprocess = RDoc::Markup::PreProcess.new(@file_name,
381
- @options.rdoc_include)
380
+ preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include
382
381
 
383
- preprocess.handle(comment) do |directive, param|
382
+ preprocess.handle comment do |directive, param|
384
383
  case directive
385
384
  when 'enddoc' then
386
385
  throw :enddoc
@@ -391,7 +390,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
391
390
  'attr', 'attr_accessor', 'attr_reader', 'attr_writer' then
392
391
  false # handled elsewhere
393
392
  when 'section' then
394
- context.set_current_section(param, comment)
393
+ context.set_current_section param, comment
395
394
  comment.replace ''
396
395
  break
397
396
  when 'startdoc' then
@@ -405,7 +404,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
405
404
  @options.title = param
406
405
  ''
407
406
  else
408
- warn "Unrecognized directive '#{directive}'"
407
+ warn "Unrecognized directive :#{directive}:"
409
408
  false
410
409
  end
411
410
  end
@@ -417,7 +416,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
417
416
  # Adds useful info about the parser to +message+
418
417
 
419
418
  def make_message message
420
- prefix = "\n#{@file_name}:"
419
+ prefix = "#{@file_name}:"
421
420
 
422
421
  prefix << "#{@scanner.line_no}:#{@scanner.char_no}:" if @scanner
423
422
 
@@ -737,27 +736,27 @@ class RDoc::Parser::Ruby < RDoc::Parser
737
736
  # To create foo and bar attributes on class C with comment "My attributes":
738
737
  #
739
738
  # class C
740
- #
739
+ #
741
740
  # ##
742
741
  # # :attr:
743
742
  # #
744
743
  # # My attributes
745
- #
744
+ #
746
745
  # my_attr :foo, :bar
747
- #
746
+ #
748
747
  # end
749
748
  #
750
749
  # To create a foo attribute on class C with comment "My attribute":
751
750
  #
752
751
  # class C
753
- #
752
+ #
754
753
  # ##
755
754
  # # :attr: foo
756
755
  # #
757
756
  # # My attribute
758
- #
757
+ #
759
758
  # my_attr :foo, :bar
760
- #
759
+ #
761
760
  # end
762
761
 
763
762
  def parse_meta_attr(context, single, tk, comment)
@@ -1405,16 +1404,12 @@ class RDoc::Parser::Ruby < RDoc::Parser
1405
1404
  end
1406
1405
  end
1407
1406
 
1408
- def parse_yield_parameters
1409
- parse_method_or_yield_parameters
1410
- end
1411
-
1412
1407
  def parse_yield(context, single, tk, method)
1413
- if method.block_params.nil?
1414
- get_tkread
1415
- @scanner.instance_eval{@continue = false}
1416
- method.block_params = parse_yield_parameters
1417
- end
1408
+ return if method.block_params
1409
+
1410
+ get_tkread
1411
+ @scanner.instance_eval { @continue = false }
1412
+ method.block_params = parse_method_or_yield_parameters
1418
1413
  end
1419
1414
 
1420
1415
  ##