rdoc 3.2 → 3.3

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.

data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,30 @@
1
+ === 3.3 / ??
2
+
3
+ * Minor enhancements
4
+ * The coverage report can now report undocumented method parameters
5
+ including methods defined in C.
6
+
7
+ <kbd>rdoc -C</kbd> gives a standard report, <kbd>rdoc -C1</kbd> includes
8
+ method parameters. Method parameters are considered documented if they're
9
+ marked-up with <tt>+</tt>, <tt><code></tt> or <code><tt></code>.
10
+ * The C parser now uses <tt>*args</tt> instead of <tt>...</tt> if no
11
+ <tt>call-seq</tt> was provided to give names to the arguments.
12
+ * Bug fixes
13
+ * The C parser now records the file location of aliases, attributes,
14
+ constants and methods allowing -C to work on C files.
15
+ * Darkfish now handles dots in call-seq allowing <tt>ary.insert(index,
16
+ obj...)</tt> to display correctly. Patch #6 by KUBO Takehiro.
17
+ * Improved processing of meta-programmed methods when followed by unparseable
18
+ syntax. RubyForge patch #28653 by Aidan Cully.
19
+ * rdoc now touches the flag file when it create the output directory.
20
+ Prevents the "isn't an RDoc directory" error if rdoc crashes.
21
+ * RDoc now properly converts to the expected output encoding. RubyForge bug
22
+ #28791 by Dzmitry Prakapenka.
23
+ * Restored parsing of block comments. RubyForge bug #28668 by Stefano Crocco.
24
+ * Metaprogrammed methods defined with blocks no longer confuse the ruby
25
+ parser. RubyForge bug #28370 by Erik Hollensbe.
26
+ * ri no longer displays all methods in the inheritance chain.
27
+
1
28
  === 3.2 / 2010-12-29
2
29
 
3
30
  * Minor enhancements
@@ -28,7 +55,7 @@ otherwise noted.
28
55
  RubyForge Bug #26290 by Sylvain Joyeux.
29
56
  * Coverage report no longer crashes for constant aliases. Pull Request #1
30
57
  by Andy Lindeman.
31
- * RDoc no longer looses ghost methods when followed by certain tokens.
58
+ * RDoc no longer loses ghost methods when followed by certain tokens.
32
59
  RubyForge bug #27793 by Aaron Patterson.
33
60
  * RDoc no longer crashes in ri if HOME is not set. Ruby Bug #4202 by
34
61
  Shyouhei Urabe.
@@ -79,6 +79,7 @@ lib/rdoc/markup/to_html.rb
79
79
  lib/rdoc/markup/to_html_crossref.rb
80
80
  lib/rdoc/markup/to_rdoc.rb
81
81
  lib/rdoc/markup/to_test.rb
82
+ lib/rdoc/markup/to_tt_only.rb
82
83
  lib/rdoc/markup/verbatim.rb
83
84
  lib/rdoc/meta_method.rb
84
85
  lib/rdoc/method_attr.rb
@@ -139,6 +140,7 @@ test/test_rdoc_markup_to_bs.rb
139
140
  test/test_rdoc_markup_to_html.rb
140
141
  test/test_rdoc_markup_to_html_crossref.rb
141
142
  test/test_rdoc_markup_to_rdoc.rb
143
+ test/test_rdoc_markup_to_tt_only.rb
142
144
  test/test_rdoc_method_attr.rb
143
145
  test/test_rdoc_normal_class.rb
144
146
  test/test_rdoc_normal_module.rb
@@ -153,6 +155,7 @@ test/test_rdoc_ri_driver.rb
153
155
  test/test_rdoc_ri_paths.rb
154
156
  test/test_rdoc_ri_store.rb
155
157
  test/test_rdoc_ruby_lex.rb
158
+ test/test_rdoc_single_class.rb
156
159
  test/test_rdoc_stats.rb
157
160
  test/test_rdoc_task.rb
158
161
  test/test_rdoc_text.rb
@@ -95,7 +95,7 @@ module RDoc
95
95
  ##
96
96
  # RDoc version you are using
97
97
 
98
- VERSION = '3.2'
98
+ VERSION = '3.3'
99
99
 
100
100
  ##
101
101
  # Method visibilities
@@ -4,6 +4,8 @@ require 'rdoc/class_module'
4
4
  # An anonymous class like:
5
5
  #
6
6
  # c = Class.new do end
7
+ #
8
+ # AnonClass is currently not used.
7
9
 
8
10
  class RDoc::AnonClass < RDoc::ClassModule
9
11
  end
@@ -140,12 +140,41 @@ class RDoc::AnyMethod < RDoc::MethodAttr
140
140
  end
141
141
 
142
142
  ##
143
- # Pretty parameter list for this method
143
+ # A list of this method's method and yield parameters. +call-seq+ params
144
+ # are preferred over parsed method and block params.
145
+
146
+ def param_list
147
+ if @call_seq then
148
+ params = @call_seq.split("\n").last
149
+ params = params.sub(/.*?\((.*)\)/, '\1')
150
+ params = params.sub(/(\{|do)\s*\|([^|]*)\|.*/, ',\2')
151
+ elsif @params then
152
+ params = @params.sub(/\((.*)\)/, '\1')
153
+
154
+ params << ",#{@block_params}" if @block_params
155
+ elsif @block_params then
156
+ params = @block_params
157
+ else
158
+ return []
159
+ end
160
+
161
+ params.gsub(/\s+/, '').split ','
162
+ end
163
+
164
+ ##
165
+ # Pretty parameter list for this method. If the method's parameters were
166
+ # given by +call-seq+ it is preferred over the parsed values.
144
167
 
145
168
  def param_seq
146
- params = @params.gsub(/\s*\#.*/, '')
147
- params = params.tr("\n", " ").squeeze(" ")
148
- params = "(#{params})" unless params[0] == ?(
169
+ if @call_seq then
170
+ params = @call_seq.split("\n").last
171
+ params = params.sub(/[^( ]+/, '')
172
+ params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2')
173
+ else
174
+ params = @params.gsub(/\s*\#.*/, '')
175
+ params = params.tr("\n", " ").squeeze(" ")
176
+ params = "(#{params})" unless params[0] == ?(
177
+ end
149
178
 
150
179
  if @block_params then
151
180
  # If this method has explicit block parameters, remove any explicit
@@ -115,6 +115,12 @@ class RDoc::CodeObject
115
115
  if comment and not comment.empty? then
116
116
  normalize_comment comment
117
117
  else
118
+ # TODO is this sufficient?
119
+ # HACK correct fix is to have #initialize create @comment
120
+ # with the correct encoding
121
+ if Object.const_defined? :Encoding and @comment.empty? then
122
+ @comment.force_encoding comment.encoding
123
+ end
118
124
  @comment
119
125
  end
120
126
  end
@@ -188,7 +188,6 @@ class RDoc::Context < RDoc::CodeObject
188
188
  @in_files = []
189
189
 
190
190
  @name ||= "unknown"
191
- @comment ||= ""
192
191
  @parent = nil
193
192
  @visibility = :public
194
193
 
@@ -78,4 +78,3 @@ module RDoc::Encoding
78
78
 
79
79
  end
80
80
 
81
-
@@ -1,7 +1,11 @@
1
+ # This file is loaded by generators. It allows RDoc's CodeObject tree to
2
+ # avoid loading generator code to increase startup time (for ri).
3
+
1
4
  require 'rdoc/text'
2
5
  require 'rdoc/code_objects'
3
6
  require 'rdoc/generator'
4
7
  require 'rdoc/markup/to_html_crossref'
8
+ require 'rdoc/ruby_token'
5
9
 
6
10
  ##
7
11
  # Handle common RDoc::Markup tasks for various CodeObjects
@@ -228,7 +228,7 @@
228
228
  <% if method.call_seq %>
229
229
  <% method.call_seq.strip.split("\n").each_with_index do |call_seq, i| %>
230
230
  <div class="method-heading">
231
- <span class="method-callseq"><%= call_seq.strip.gsub(/->/, '&rarr;').gsub( /^\w.+\./m, '') %></span>
231
+ <span class="method-callseq"><%= call_seq.strip.gsub(/->/, '&rarr;').gsub( /^\w+\./m, '') %></span>
232
232
  <% if i == 0 %>
233
233
  <span class="method-click-advice">click to toggle source</span>
234
234
  <% end %>
@@ -537,8 +537,8 @@ class RDoc::Markup
537
537
  # structure (paragraphs, lists, and so on). Invoke an event handler as we
538
538
  # identify significant chunks.
539
539
 
540
- def initialize
541
- @attribute_manager = RDoc::Markup::AttributeManager.new
540
+ def initialize attribute_manager = nil
541
+ @attribute_manager = attribute_manager || RDoc::Markup::AttributeManager.new
542
542
  @output = nil
543
543
  end
544
544
 
@@ -74,7 +74,6 @@ class RDoc::Markup::AttributeManager
74
74
  add_html "code", :TT
75
75
  end
76
76
 
77
-
78
77
  ##
79
78
  # Return an attribute object with the given turn_on and turn_off bits set
80
79
 
@@ -0,0 +1,114 @@
1
+ require 'rdoc/markup/formatter'
2
+ require 'rdoc/markup/inline'
3
+
4
+ ##
5
+ # Extracts sections of text enclosed in plus, tt or code. Used to discover
6
+ # undocumented parameters.
7
+
8
+ class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter
9
+
10
+ ##
11
+ # Stack of list types
12
+
13
+ attr_reader :list_type
14
+
15
+ ##
16
+ # Output accumulator
17
+
18
+ attr_reader :res
19
+
20
+ ##
21
+ # Creates a new tt-only formatter.
22
+
23
+ def initialize
24
+ super
25
+
26
+ add_tag :TT, nil, nil
27
+ end
28
+
29
+ ##
30
+ # Pops the list type for +list+ from #list_type
31
+
32
+ def accept_list_end list
33
+ @list_type.pop
34
+ end
35
+
36
+ ##
37
+ # Pushes the list type for +list+ onto #list_type
38
+
39
+ def accept_list_start list
40
+ @list_type << list.type
41
+ end
42
+
43
+ ##
44
+ # Prepares the visitor for consuming +list_item+
45
+
46
+ def accept_list_item_start list_item
47
+ case @list_type.last
48
+ when :NOTE, :LABEL then
49
+ tt_sections(list_item.label)
50
+ end
51
+ end
52
+
53
+ ##
54
+ # Adds +paragraph+ to the output
55
+
56
+ def accept_paragraph paragraph
57
+ tt_sections(paragraph.text)
58
+ end
59
+
60
+ ##
61
+ # Does nothing to +markup_item+ because it doesn't have any user-built
62
+ # content
63
+
64
+ def do_nothing markup_item
65
+ end
66
+
67
+ alias accept_blank_line do_nothing # :nodoc:
68
+ alias accept_heading do_nothing # :nodoc:
69
+ alias accept_list_item_end do_nothing # :nodoc:
70
+ alias accept_raw do_nothing # :nodoc:
71
+ alias accept_rule do_nothing # :nodoc:
72
+ alias accept_verbatim do_nothing # :nodoc:
73
+
74
+ ##
75
+ # Extracts tt sections from +text+
76
+
77
+ def tt_sections text
78
+ flow = @am.flow text.dup
79
+
80
+ flow.each do |item|
81
+ case item
82
+ when String then
83
+ @res << item if in_tt?
84
+ when RDoc::Markup::AttrChanger then
85
+ off_tags res, item
86
+ on_tags res, item
87
+ when RDoc::Markup::Special then
88
+ @res << convert_special(item) if in_tt? # TODO can this happen?
89
+ else
90
+ raise "Unknown flow element: #{item.inspect}"
91
+ end
92
+ end
93
+
94
+ res
95
+ end
96
+
97
+ ##
98
+ # Returns an Array of items that were wrapped in plus, tt or code.
99
+
100
+ def end_accepting
101
+ @res.compact
102
+ end
103
+
104
+ ##
105
+ # Prepares the visitor for gathering tt sections
106
+
107
+ def start_accepting
108
+ @res = []
109
+
110
+ @list_type = []
111
+ end
112
+
113
+ end
114
+
@@ -12,6 +12,13 @@ class RDoc::NormalClass < RDoc::ClassModule
12
12
  superclass ? super + [superclass] : super
13
13
  end
14
14
 
15
+ ##
16
+ # The definition of this class, <tt>class MyClassName</tt>
17
+
18
+ def definition
19
+ "class #{full_name}"
20
+ end
21
+
15
22
  def inspect # :nodoc:
16
23
  superclass = @superclass ? " < #{@superclass}" : nil
17
24
  "<%s:0x%x class %s%s includes: %p attributes: %p methods: %p aliases: %p>" % [
@@ -12,6 +12,13 @@ class RDoc::NormalModule < RDoc::ClassModule
12
12
  ]
13
13
  end
14
14
 
15
+ ##
16
+ # The definition of this module, <tt>module MyModuleName</tt>
17
+
18
+ def definition
19
+ "module #{full_name}"
20
+ end
21
+
15
22
  ##
16
23
  # This is a module, returns true
17
24
 
@@ -455,9 +455,11 @@ Usage: #{opt.program_name} [options] [names...]
455
455
 
456
456
  opt.separator nil
457
457
 
458
- opt.on("--[no-]coverage-report", "--[no-]dcov", "-C",
458
+ opt.on("--[no-]coverage-report=[LEVEL]", "--[no-]dcov", "-C", Integer,
459
459
  "Prints a report on undocumented items.",
460
460
  "Does not generate files.") do |value|
461
+ value = 0 if value.nil? # Integer converts -C to nil
462
+
461
463
  @coverage_report = value
462
464
  @force_update = true if value
463
465
  end
@@ -156,6 +156,7 @@ class RDoc::Parser::C < RDoc::Parser
156
156
  comment = strip_stars comment
157
157
  al.comment = comment
158
158
 
159
+ al.record_location @top_level
159
160
  class_obj.add_alias al
160
161
  @stats.add_alias al
161
162
  end
@@ -618,6 +619,7 @@ class RDoc::Parser::C < RDoc::Parser
618
619
 
619
620
  attr = RDoc::Attr.new '', name, rw, comment
620
621
 
622
+ attr.record_location @top_level
621
623
  class_obj.add_attribute attr
622
624
  @stats.add_attribute attr
623
625
  end
@@ -732,6 +734,7 @@ class RDoc::Parser::C < RDoc::Parser
732
734
  con = RDoc::Constant.new const_name, definition, comment
733
735
  end
734
736
 
737
+ con.record_location @top_level
735
738
  @stats.add_constant con
736
739
  class_obj.add_constant con
737
740
  end
@@ -776,11 +779,12 @@ class RDoc::Parser::C < RDoc::Parser
776
779
  p_count = Integer(param_count) rescue -1
777
780
 
778
781
  if p_count < 0 then
779
- meth_obj.params = "(...)"
782
+ meth_obj.params = "(*args)"
780
783
  elsif p_count == 0
781
784
  meth_obj.params = "()"
782
785
  else
783
- meth_obj.params = "(" + (1..p_count).map{|i| "p#{i}"}.join(", ") + ")"
786
+ params = (1..p_count).map { |i| "p#{i}" }.join(', ')
787
+ meth_obj.params = "(#{params})"
784
788
  end
785
789
 
786
790
  if source_file then
@@ -797,6 +801,7 @@ class RDoc::Parser::C < RDoc::Parser
797
801
 
798
802
  if find_body(class_name, meth_body, meth_obj, body) and
799
803
  meth_obj.document_self then
804
+ meth_obj.record_location @top_level
800
805
  class_obj.add_method meth_obj
801
806
  @stats.add_method meth_obj
802
807
  meth_obj.visibility = :private if 'private_method' == type
@@ -658,7 +658,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
658
658
 
659
659
  unless TkASSIGN === eq_tk then
660
660
  unget_tk eq_tk
661
- return
661
+ return false
662
662
  end
663
663
 
664
664
  nest = 0
@@ -669,7 +669,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
669
669
  if TkGT === tk then
670
670
  unget_tk tk
671
671
  unget_tk eq_tk
672
- return
672
+ return false
673
673
  end
674
674
 
675
675
  rhs_name = ''
@@ -725,6 +725,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
725
725
 
726
726
  @stats.add_constant con
727
727
  container.add_constant con if con.document_self
728
+ true
728
729
  end
729
730
 
730
731
  ##
@@ -764,7 +765,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
764
765
  meth.comment = comment
765
766
 
766
767
  @stats.add_method meth
767
- elsif comment.sub!(/# +:?(attr(_reader|_writer|_accessor)?:) *(\S*).*?\n/i, '') then
768
+ elsif comment.sub!(/# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i, '') then
768
769
  rw = case $1
769
770
  when 'attr_reader' then 'R'
770
771
  when 'attr_writer' then 'W'
@@ -933,6 +934,10 @@ class RDoc::Parser::Ruby < RDoc::Parser
933
934
  break unless last_tk and TkCOMMA === last_tk
934
935
  when TkSPACE then
935
936
  # expression continues
937
+ when TkDO then
938
+ unget_tk tk
939
+ parse_statements container, single, meth
940
+ break
936
941
  else
937
942
  last_tk = tk
938
943
  end
@@ -1223,6 +1228,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
1223
1228
 
1224
1229
  while tk = get_tk do
1225
1230
  keep_comment = false
1231
+ try_parse_comment = false
1226
1232
 
1227
1233
  non_comment_seen = true unless TkCOMMENT === tk
1228
1234
 
@@ -1287,7 +1293,9 @@ class RDoc::Parser::Ruby < RDoc::Parser
1287
1293
 
1288
1294
  when TkCONSTANT then
1289
1295
  if container.document_self then
1290
- parse_constant container, tk, comment
1296
+ if not parse_constant container, tk, comment then
1297
+ try_parse_comment = true
1298
+ end
1291
1299
  end
1292
1300
 
1293
1301
  when TkALIAS then
@@ -1365,10 +1373,14 @@ class RDoc::Parser::Ruby < RDoc::Parser
1365
1373
  return
1366
1374
  end
1367
1375
  else
1376
+ try_parse_comment = nest == 1
1377
+ end
1378
+
1379
+ if try_parse_comment then
1368
1380
  non_comment_seen = parse_comment container, tk, comment unless
1369
1381
  comment.empty?
1370
1382
 
1371
- comment = ''
1383
+ keep_comment = false
1372
1384
  end
1373
1385
 
1374
1386
  comment = '' unless keep_comment