rdoc 2.5.3 → 2.5.4

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,4 +1,4 @@
1
- === 2.5.3 / 2010-04
1
+ === 2.5.4 / 2010-04-18
2
2
 
3
3
  *NOTE*:
4
4
 
@@ -19,10 +19,21 @@ To have ri data for you gems you'll also need to run:
19
19
 
20
20
  If you don't want to rebuild the rdoc for `gem server`, add --no-rdoc.
21
21
 
22
+ * 2 Minor Enhancements
23
+ * Methods will now be cross-referenced when preceeded with ::. Ruby Bug
24
+ #3169 by Marc-Andre Lafortune.
25
+ * Methods now have human readable fragment identifiers for HTML output.
26
+ (#method-i-gsub vs #M000005). Ruby Bug #3023 by Marc-Andre Lafortune.
27
+ * 1 Bug Fixes
28
+ * RDoc::Parser::Ruby now handles <code>while begin a; b end # ...</code>.
29
+ Ruby Bug #3160 by Yusuke Endoh.
30
+
31
+ === 2.5.3 / 2010-04-10
32
+
22
33
  * 1 Minor Enhancement
23
34
  * RDoc::Parser::Simple and the include directive remove coding: comment from
24
35
  first line
25
- * 2 Bug Fixe
36
+ * 2 Bug Fixes
26
37
  * Fixed loading of created.rid when regenerating documentation. Ruby bug
27
38
  #3121 by Yusuke Endoh.
28
39
  * Compare times as Integers as created.rid doesn't store fractional times.
@@ -383,7 +383,7 @@ module RDoc
383
383
  ##
384
384
  # RDoc version you are using
385
385
 
386
- VERSION = '2.5.3'
386
+ VERSION = '2.5.4'
387
387
 
388
388
  ##
389
389
  # Name of the dotfile that contains the description of files to be processed
@@ -45,11 +45,6 @@ class RDoc::AnyMethod < RDoc::CodeObject
45
45
 
46
46
  attr_reader :aliases
47
47
 
48
- ##
49
- # Fragment reference for this method
50
-
51
- attr_reader :aref
52
-
53
48
  ##
54
49
  # The method we're aliasing
55
50
 
@@ -67,21 +62,13 @@ class RDoc::AnyMethod < RDoc::CodeObject
67
62
 
68
63
  include RDoc::TokenStream
69
64
 
70
- ##
71
- # Resets method fragment reference counter
72
-
73
- def self.reset
74
- @@aref = 'M000000'
75
- end
76
-
77
- reset
78
-
79
65
  def initialize(text, name)
80
66
  super()
81
67
 
82
68
  @text = text
83
69
  @name = name
84
70
 
71
+ @aref = nil
85
72
  @aliases = []
86
73
  @block_params = nil
87
74
  @call_seq = nil
@@ -92,9 +79,6 @@ class RDoc::AnyMethod < RDoc::CodeObject
92
79
  @singleton = nil
93
80
  @token_stream = nil
94
81
  @visibility = :public
95
-
96
- @aref = @@aref
97
- @@aref = @@aref.succ
98
82
  end
99
83
 
100
84
  ##
@@ -111,6 +95,15 @@ class RDoc::AnyMethod < RDoc::CodeObject
111
95
  @aliases << method
112
96
  end
113
97
 
98
+ ##
99
+ # HTML fragment reference for this method
100
+
101
+ def aref
102
+ type = singleton ? 'c' : 'i'
103
+
104
+ "method-#{type}-#{CGI.escape name}"
105
+ end
106
+
114
107
  ##
115
108
  # The call_seq or the param_seq with method name, if there is no call_seq.
116
109
  #
@@ -248,7 +241,7 @@ class RDoc::AnyMethod < RDoc::CodeObject
248
241
  # Path to this method
249
242
 
250
243
  def path
251
- "#{@parent.path}##{@aref}"
244
+ "#{@parent.path}##{aref}"
252
245
  end
253
246
 
254
247
  ##
@@ -6,6 +6,24 @@ require 'rdoc/text'
6
6
  #
7
7
  # We contain the common stuff for contexts (which are containers) and other
8
8
  # elements (methods, attributes and so on)
9
+ #
10
+ # Here's the tree of the CodeObject subclasses:
11
+ #
12
+ # * RDoc::Context
13
+ # * RDoc::TopLevel
14
+ # * RDoc::ClassModule
15
+ # * RDoc::AnonClass
16
+ # * RDoc::NormalClass
17
+ # * RDoc::NormalModule
18
+ # * RDoc::SingleClass
19
+ # * RDoc::AnyMethod
20
+ # * RDoc::GhostMethod
21
+ # * RDoc::MetaMethod
22
+ # * RDoc::Alias
23
+ # * RDoc::Attr
24
+ # * RDoc::Constant
25
+ # * RDoc::Require
26
+ # * RDoc::Include
9
27
 
10
28
  class RDoc::CodeObject
11
29
 
@@ -510,6 +510,13 @@ class RDoc::Context < RDoc::CodeObject
510
510
  @attributes.find { |m| m.name == name }
511
511
  end
512
512
 
513
+ ##
514
+ # Finds a class method with +name+ in this context
515
+
516
+ def find_class_method_named(name)
517
+ @method_list.find { |meth| meth.singleton && meth.name == name }
518
+ end
519
+
513
520
  ##
514
521
  # Finds a constant with +name+ in this context
515
522
 
@@ -535,7 +542,7 @@ class RDoc::Context < RDoc::CodeObject
535
542
  # Finds an instance method with +name+ in this context
536
543
 
537
544
  def find_instance_method_named(name)
538
- @method_list.find { |meth| meth.name == name && !meth.singleton }
545
+ @method_list.find { |meth| !meth.singleton && meth.name == name }
539
546
  end
540
547
 
541
548
  ##
@@ -554,7 +561,14 @@ class RDoc::Context < RDoc::CodeObject
554
561
  # Finds a instance or module method with +name+ in this context
555
562
 
556
563
  def find_method_named(name)
557
- @method_list.find { |meth| meth.name == name }
564
+ case name
565
+ when /\A#/ then
566
+ find_instance_method_named name[1..-1]
567
+ when /\A::/ then
568
+ find_class_method_named name[2..-1]
569
+ else
570
+ @method_list.find { |meth| meth.name == name }
571
+ end
558
572
  end
559
573
 
560
574
  ##
@@ -575,7 +589,7 @@ class RDoc::Context < RDoc::CodeObject
575
589
  result = nil
576
590
 
577
591
  case symbol
578
- when /^::(.*)/ then
592
+ when /^::([A-Z].*)/ then
579
593
  result = top_level.find_symbol($1)
580
594
  when /::/ then
581
595
  modules = symbol.split(/::/)
@@ -591,8 +605,9 @@ class RDoc::Context < RDoc::CodeObject
591
605
  end
592
606
  end
593
607
  end
608
+ end
594
609
 
595
- else
610
+ unless result then
596
611
  # if a method is specified, then we're definitely looking for
597
612
  # a module, otherwise it could be any symbol
598
613
  if method then
@@ -610,10 +625,7 @@ class RDoc::Context < RDoc::CodeObject
610
625
  end
611
626
  end
612
627
 
613
- if result and method then
614
- fail unless result.respond_to? :find_local_symbol
615
- result = result.find_local_symbol(method)
616
- end
628
+ result = result.find_local_symbol method if result and method
617
629
 
618
630
  result
619
631
  end
@@ -21,7 +21,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
21
21
  #
22
22
  # See CLASS_REGEXP_STR
23
23
 
24
- METHOD_REGEXP_STR = '(\w+[!?=]?)(?:\([\w.+*/=<>-]*\))?'
24
+ METHOD_REGEXP_STR = '([a-z]\w*[!?=]?)(?:\([\w.+*/=<>-]*\))?'
25
25
 
26
26
  ##
27
27
  # Regular expressions matching text that should potentially have
@@ -32,11 +32,14 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
32
32
 
33
33
  CROSSREF_REGEXP = /(
34
34
  # A::B::C.meth
35
- #{CLASS_REGEXP_STR}[\.\#]#{METHOD_REGEXP_STR}
35
+ #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
36
36
 
37
37
  # Stand-alone method (proceeded by a #)
38
38
  | \\?\##{METHOD_REGEXP_STR}
39
39
 
40
+ # Stand-alone method (proceeded by ::)
41
+ | ::#{METHOD_REGEXP_STR}
42
+
40
43
  # A::B::C
41
44
  # The stuff after CLASS_REGEXP_STR is a
42
45
  # nasty hack. CLASS_REGEXP_STR unfortunately matches
@@ -86,11 +89,11 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
86
89
  end
87
90
 
88
91
  ##
89
- # We're invoked when any text matches the CROSSREF pattern (defined in
90
- # MarkUp). If we find the corresponding reference, generate a hyperlink.
91
- # If the name we're looking for contains no punctuation, we look for it up
92
- # the module/class chain. For example, HyperlinkHtml is found, even without
93
- # the Generator:: prefix, because we look for it in module Generator first.
92
+ # We're invoked when any text matches the CROSSREF pattern. If we find the
93
+ # corresponding reference, generate a hyperlink. If the name we're looking
94
+ # for contains no punctuation, we look for it up the module/class chain.
95
+ # For example, HyperlinkHtml is found, even without the Generator:: prefix,
96
+ # because we look for it in module Generator first.
94
97
 
95
98
  def handle_special_CROSSREF(special)
96
99
  name = special.text
@@ -102,12 +105,9 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
102
105
 
103
106
  return @seen[name] if @seen.include? name
104
107
 
105
- if name[0, 1] == '#' then
106
- lookup = name[1..-1]
107
- name = lookup unless @show_hash
108
- else
109
- lookup = name
110
- end
108
+ lookup = name
109
+
110
+ name = name[0, 1] unless @show_hash if name[0, 1] == '#'
111
111
 
112
112
  # Find class, module, or method in class or module.
113
113
  #
@@ -119,9 +119,11 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
119
119
  # (in which case it would match the last pattern, which just checks
120
120
  # whether the string as a whole is a known symbol).
121
121
 
122
- if /#{CLASS_REGEXP_STR}[\.\#]#{METHOD_REGEXP_STR}/ =~ lookup then
122
+ if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/ =~ lookup then
123
123
  container = $1
124
- method = $2
124
+ type = $2
125
+ type = '#' if type == '.'
126
+ method = "#{type}#{$3}"
125
127
  ref = @context.find_symbol container, method
126
128
  end
127
129
 
@@ -132,7 +134,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
132
134
  elsif lookup =~ /^\\/ then
133
135
  $'
134
136
  elsif ref and ref.document_self then
135
- "<a href=\"#{ref.as_href(@from_path)}\">#{name}</a>"
137
+ "<a href=\"#{ref.as_href @from_path}\">#{name}</a>"
136
138
  else
137
139
  name
138
140
  end
@@ -1524,24 +1524,29 @@ class RDoc::Parser::Ruby < RDoc::Parser
1524
1524
  skip_tkspace false
1525
1525
  tk = get_tk
1526
1526
  case tk
1527
- when TkLPAREN, TkfLPAREN
1527
+ when TkLPAREN, TkfLPAREN then
1528
1528
  end_token = TkRPAREN
1529
1529
  else
1530
1530
  end_token = TkNL
1531
1531
  end
1532
1532
 
1533
+ b_nest = 0
1533
1534
  nest = 0
1534
- @scanner.instance_eval{@continue = false}
1535
+ @scanner.instance_eval { @continue = false }
1535
1536
 
1536
1537
  loop do
1537
1538
  case tk
1538
- when TkSEMICOLON
1539
- break
1540
- when TkLPAREN, TkfLPAREN
1539
+ when TkSEMICOLON then
1540
+ break if b_nest.zero?
1541
+ when TkLPAREN, TkfLPAREN then
1541
1542
  nest += 1
1543
+ when TkBEGIN then
1544
+ b_nest += 1
1545
+ when TkEND then
1546
+ b_nest -= 1
1542
1547
  when TkDO
1543
1548
  break if nest.zero?
1544
- when end_token
1549
+ when end_token then
1545
1550
  if end_token == TkRPAREN
1546
1551
  nest -= 1
1547
1552
  break if @scanner.lex_state == EXPR_END and nest.zero?
@@ -1553,6 +1558,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
1553
1558
  end
1554
1559
  tk = get_tk
1555
1560
  end
1561
+
1556
1562
  skip_tkspace false
1557
1563
 
1558
1564
  get_tk if TkDO === peek_tk
@@ -353,7 +353,6 @@ The internal error was:
353
353
  def document(argv)
354
354
  RDoc::TopLevel.reset
355
355
  RDoc::Parser::C.reset
356
- RDoc::AnyMethod.reset
357
356
 
358
357
  @options = RDoc::Options.new
359
358
  @options.parse argv
@@ -2,6 +2,16 @@ require File.expand_path '../xref_test_case', __FILE__
2
2
 
3
3
  class RDocAnyMethodTest < XrefTestCase
4
4
 
5
+ def test_aref
6
+ m = RDoc::AnyMethod.new nil, 'method?'
7
+
8
+ assert_equal 'method-i-method%3F', m.aref
9
+
10
+ m.singleton = true
11
+
12
+ assert_equal 'method-c-method%3F', m.aref
13
+ end
14
+
5
15
  def test_arglists
6
16
  m = RDoc::AnyMethod.new nil, 'method'
7
17
 
@@ -227,6 +227,14 @@ class TestRDocContext < XrefTestCase
227
227
  assert_equal 'RW', @c1.find_attribute_named('attr_accessor').rw
228
228
  end
229
229
 
230
+ def test_find_class_method_named
231
+ assert_equal nil, @c1.find_class_method_named('none')
232
+
233
+ m = @c1.find_class_method_named('m')
234
+ assert_instance_of RDoc::AnyMethod, m
235
+ assert m.singleton
236
+ end
237
+
230
238
  def test_find_constant_named
231
239
  assert_equal nil, @c1.find_constant_named('NONE')
232
240
  assert_equal ':const', @c1.find_constant_named('CONST').value
@@ -248,7 +256,7 @@ class TestRDocContext < XrefTestCase
248
256
 
249
257
  m = @c1.find_instance_method_named('m')
250
258
  assert_instance_of RDoc::AnyMethod, m
251
- assert_equal false, m.singleton
259
+ refute m.singleton
252
260
  end
253
261
 
254
262
  def test_find_local_symbol
@@ -278,6 +286,12 @@ class TestRDocContext < XrefTestCase
278
286
  assert_equal @c2_c3, @c2.find_symbol('C3')
279
287
  end
280
288
 
289
+ def test_find_symbol_method
290
+ assert_equal @c1__m, @c1.find_symbol('m')
291
+ assert_equal @c1_m, @c1.find_symbol('#m')
292
+ assert_equal @c1__m, @c1.find_symbol('::m')
293
+ end
294
+
281
295
  def test_spaceship
282
296
  assert_equal(-1, @c2.<=>(@c3))
283
297
  assert_equal 0, @c2.<=>(@c2)
@@ -27,31 +27,30 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
27
27
 
28
28
  refute_ref '#m', '#m'
29
29
 
30
+ assert_ref '../C1.html#method-c-m', 'C1::m'
30
31
  assert_ref '../C2/C3.html', 'C2::C3'
31
- assert_ref '../C2/C3.html#M000002', 'C2::C3#m'
32
+ assert_ref '../C2/C3.html#method-i-m', 'C2::C3#m'
32
33
  assert_ref '../C2/C3/H1.html', 'C3::H1'
33
34
  assert_ref '../C4.html', 'C4'
34
35
 
35
- # TODO there is a C3::H2 in the top-level namespace and RDoc should follow
36
- # constant scoping rules
37
- refute_ref 'C3::H2', 'C3::H2'
36
+ assert_ref '../C3/H2.html', 'C3::H2'
38
37
  refute_ref 'H1', 'H1'
39
38
  end
40
39
 
41
40
  def test_handle_special_CROSSREF_C2_C3
42
41
  @xref = RDoc::Markup::ToHtmlCrossref.new 'classes/C2/C3.html', @c2_c3, true
43
42
 
44
- assert_ref '../../C2/C3.html#M000002', '#m'
43
+ assert_ref '../../C2/C3.html#method-i-m', '#m'
45
44
 
46
45
  assert_ref '../../C2/C3.html', 'C3'
47
- assert_ref '../../C2/C3.html#M000002', 'C3#m'
46
+ assert_ref '../../C2/C3.html#method-i-m', 'C3#m'
48
47
 
49
48
  assert_ref '../../C2/C3/H1.html', 'H1'
50
49
  assert_ref '../../C2/C3/H1.html', 'C3::H1'
51
50
 
52
51
  assert_ref '../../C4.html', 'C4'
53
52
 
54
- refute_ref 'C3::H2', 'C3::H2'
53
+ assert_ref '../../C3/H2.html', 'C3::H2'
55
54
  end
56
55
 
57
56
  def test_handle_special_CROSSREF_C3
@@ -105,30 +104,34 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase
105
104
 
106
105
  def test_handle_special_CROSSREF_method
107
106
  refute_ref 'm', 'm'
108
- assert_ref 'C1.html#M000000', '#m'
107
+ assert_ref 'C1.html#method-i-m', '#m'
108
+ assert_ref 'C1.html#method-c-m', '::m'
109
+
110
+ assert_ref 'C1.html#method-i-m', 'C1#m'
111
+ assert_ref 'C1.html#method-i-m', 'C1.m'
112
+ assert_ref 'C1.html#method-c-m', 'C1::m'
109
113
 
110
- assert_ref 'C1.html#M000000', 'C1#m'
111
- assert_ref 'C1.html#M000000', 'C1#m()'
112
- assert_ref 'C1.html#M000000', 'C1#m(*)'
114
+ assert_ref 'C1.html#method-i-m', 'C1#m'
115
+ assert_ref 'C1.html#method-i-m', 'C1#m()'
116
+ assert_ref 'C1.html#method-i-m', 'C1#m(*)'
113
117
 
114
- assert_ref 'C1.html#M000000', 'C1.m'
115
- assert_ref 'C1.html#M000000', 'C1.m()'
116
- assert_ref 'C1.html#M000000', 'C1.m(*)'
118
+ assert_ref 'C1.html#method-i-m', 'C1.m'
119
+ assert_ref 'C1.html#method-i-m', 'C1.m()'
120
+ assert_ref 'C1.html#method-i-m', 'C1.m(*)'
117
121
 
118
- # HACK should this work
119
- #assert_ref 'classes/C1.html#M000001', 'C1::m'
120
- #assert_ref 'classes/C1.html#M000001', 'C1::m()'
121
- #assert_ref 'classes/C1.html#M000001', 'C1::m(*)'
122
+ assert_ref 'C1.html#method-c-m', 'C1::m'
123
+ assert_ref 'C1.html#method-c-m', 'C1::m()'
124
+ assert_ref 'C1.html#method-c-m', 'C1::m(*)'
122
125
 
123
- assert_ref 'C2/C3.html#M000002', 'C2::C3#m'
126
+ assert_ref 'C2/C3.html#method-i-m', 'C2::C3#m'
124
127
 
125
- assert_ref 'C2/C3.html#M000002', 'C2::C3.m'
128
+ assert_ref 'C2/C3.html#method-i-m', 'C2::C3.m'
126
129
 
127
- assert_ref 'C2/C3/H1.html#M000003', 'C2::C3::H1#m?'
130
+ assert_ref 'C2/C3/H1.html#method-i-m%3F', 'C2::C3::H1#m?'
128
131
 
129
- assert_ref 'C2/C3.html#M000002', '::C2::C3#m'
130
- assert_ref 'C2/C3.html#M000002', '::C2::C3#m()'
131
- assert_ref 'C2/C3.html#M000002', '::C2::C3#m(*)'
132
+ assert_ref 'C2/C3.html#method-i-m', '::C2::C3#m'
133
+ assert_ref 'C2/C3.html#method-i-m', '::C2::C3#m()'
134
+ assert_ref 'C2/C3.html#method-i-m', '::C2::C3#m(*)'
132
135
  end
133
136
 
134
137
  def test_handle_special_CROSSREF_no_ref
@@ -1210,6 +1210,33 @@ EOF
1210
1210
  assert_equal 1, @top_level.requires.length
1211
1211
  end
1212
1212
 
1213
+ def test_parse_statements_while_begin
1214
+ util_parser <<-RUBY
1215
+ class A
1216
+ def a
1217
+ while begin a; b end
1218
+ end
1219
+ end
1220
+
1221
+ def b
1222
+ end
1223
+ end
1224
+ RUBY
1225
+
1226
+ @parser.parse_statements @top_level, RDoc::Parser::Ruby::NORMAL, nil, ''
1227
+
1228
+ c_a = @top_level.classes.first
1229
+ assert_equal 'A', c_a.full_name
1230
+
1231
+ assert_equal 1, @top_level.classes.length
1232
+
1233
+ m_a = c_a.method_list.first
1234
+ m_b = c_a.method_list.last
1235
+
1236
+ assert_equal 'A#a', m_a.full_name
1237
+ assert_equal 'A#b', m_b.full_name
1238
+ end
1239
+
1213
1240
  def test_parse_top_level_statements_alias_method
1214
1241
  content = <<-CONTENT
1215
1242
  class A
@@ -13,7 +13,6 @@ class XrefTestCase < MiniTest::Unit::TestCase
13
13
 
14
14
  def setup
15
15
  RDoc::TopLevel.reset
16
- RDoc::AnyMethod.reset
17
16
 
18
17
  @file_name = 'xref_data.rb'
19
18
  @xref_data = RDoc::TopLevel.new @file_name
@@ -36,6 +35,9 @@ class XrefTestCase < MiniTest::Unit::TestCase
36
35
  rdoc.generator = generator
37
36
 
38
37
  @c1 = @xref_data.find_module_named 'C1'
38
+ @c1_m = @c1.method_list.last # C1#m
39
+ @c1__m = @c1.method_list.first # C1::m
40
+
39
41
  @c2 = @xref_data.find_module_named 'C2'
40
42
  @c2_c3 = @xref_data.find_module_named 'C2::C3'
41
43
  @c3 = @xref_data.find_module_named 'C3'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 5
8
- - 3
9
- version: 2.5.3
8
+ - 4
9
+ version: 2.5.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Eric Hodel
@@ -38,7 +38,7 @@ cert_chain:
38
38
  x52qPcexcYZR7w==
39
39
  -----END CERTIFICATE-----
40
40
 
41
- date: 2010-04-10 00:00:00 -07:00
41
+ date: 2010-04-18 00:00:00 -07:00
42
42
  default_executable:
43
43
  dependencies:
44
44
  - !ruby/object:Gem::Dependency
metadata.gz.sig CHANGED
Binary file