rdoc 3.6.1 → 3.7

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 (66) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +45 -0
  3. data/Manifest.txt +4 -0
  4. data/lib/rdoc.rb +3 -2
  5. data/lib/rdoc/any_method.rb +12 -7
  6. data/lib/rdoc/attr.rb +16 -1
  7. data/lib/rdoc/class_module.rb +156 -42
  8. data/lib/rdoc/code_object.rb +8 -1
  9. data/lib/rdoc/context.rb +75 -29
  10. data/lib/rdoc/generator/markup.rb +3 -1
  11. data/lib/rdoc/generator/ri.rb +3 -2
  12. data/lib/rdoc/generator/template/darkfish/rdoc.css +4 -0
  13. data/lib/rdoc/known_classes.rb +2 -2
  14. data/lib/rdoc/markup.rb +63 -18
  15. data/lib/rdoc/markup/document.rb +43 -4
  16. data/lib/rdoc/markup/formatter.rb +13 -3
  17. data/lib/rdoc/markup/formatter_test_case.rb +13 -3
  18. data/lib/rdoc/markup/indented_paragraph.rb +33 -0
  19. data/lib/rdoc/markup/inline.rb +8 -1
  20. data/lib/rdoc/markup/parser.rb +1 -0
  21. data/lib/rdoc/markup/pre_process.rb +7 -0
  22. data/lib/rdoc/markup/to_ansi.rb +4 -4
  23. data/lib/rdoc/markup/to_bs.rb +1 -1
  24. data/lib/rdoc/markup/to_html.rb +2 -2
  25. data/lib/rdoc/markup/to_html_crossref.rb +3 -2
  26. data/lib/rdoc/markup/to_rdoc.rb +10 -1
  27. data/lib/rdoc/markup/to_test.rb +1 -1
  28. data/lib/rdoc/markup/to_tt_only.rb +1 -1
  29. data/lib/rdoc/parser.rb +1 -1
  30. data/lib/rdoc/parser/c.rb +69 -26
  31. data/lib/rdoc/parser/ruby.rb +19 -9
  32. data/lib/rdoc/rdoc.rb +14 -3
  33. data/lib/rdoc/ri/driver.rb +137 -103
  34. data/lib/rdoc/ri/store.rb +111 -26
  35. data/lib/rdoc/ruby_lex.rb +1 -1
  36. data/lib/rdoc/rubygems_hook.rb +220 -0
  37. data/lib/rdoc/text.rb +1 -1
  38. data/lib/rdoc/top_level.rb +31 -0
  39. data/test/test_rdoc_any_method.rb +68 -0
  40. data/test/test_rdoc_attr.rb +62 -0
  41. data/test/test_rdoc_class_module.rb +459 -29
  42. data/test/test_rdoc_code_object.rb +17 -0
  43. data/test/test_rdoc_context.rb +70 -0
  44. data/test/test_rdoc_context_section.rb +1 -1
  45. data/test/test_rdoc_generator_ri.rb +14 -3
  46. data/test/test_rdoc_markup.rb +55 -1
  47. data/test/test_rdoc_markup_document.rb +83 -0
  48. data/test/test_rdoc_markup_indented_paragraph.rb +40 -0
  49. data/test/test_rdoc_markup_paragraph.rb +12 -0
  50. data/test/test_rdoc_markup_pre_process.rb +13 -2
  51. data/test/test_rdoc_markup_to_ansi.rb +4 -0
  52. data/test/test_rdoc_markup_to_bs.rb +4 -0
  53. data/test/test_rdoc_markup_to_html.rb +7 -3
  54. data/test/test_rdoc_markup_to_rdoc.rb +14 -0
  55. data/test/test_rdoc_markup_to_tt_only.rb +4 -0
  56. data/test/test_rdoc_parser_c.rb +302 -2
  57. data/test/test_rdoc_parser_ruby.rb +48 -1
  58. data/test/test_rdoc_rdoc.rb +41 -10
  59. data/test/test_rdoc_ri_driver.rb +40 -7
  60. data/test/test_rdoc_ri_store.rb +111 -23
  61. data/test/test_rdoc_rubygems_hook.rb +201 -0
  62. data/test/test_rdoc_stats.rb +12 -12
  63. data/test/test_rdoc_text.rb +17 -0
  64. data/test/test_rdoc_top_level.rb +35 -0
  65. metadata +18 -14
  66. metadata.gz.sig +0 -0
@@ -30,6 +30,15 @@ class TestRDocCodeObject < XrefTestCase
30
30
  assert_equal 'I am a comment', @co.comment
31
31
  end
32
32
 
33
+ def test_comment_equals_document
34
+ doc = RDoc::Markup::Document.new
35
+ @co.comment = doc
36
+
37
+ @co.comment = ''
38
+
39
+ assert_equal doc, @co.comment
40
+ end
41
+
33
42
  def test_comment_equals_encoding
34
43
  skip "Encoding not implemented" unless Object.const_defined? :Encoding
35
44
 
@@ -129,6 +138,14 @@ class TestRDocCodeObject < XrefTestCase
129
138
  assert_equal [@parent, @xref_data], parents
130
139
  end
131
140
 
141
+ def test_file_name
142
+ assert_equal nil, @co.file_name
143
+
144
+ @co.record_location RDoc::TopLevel.new 'lib/file.rb'
145
+
146
+ assert_equal 'lib/file.rb', @co.file_name
147
+ end
148
+
132
149
  def test_full_name_equals
133
150
  @co.full_name = 'hi'
134
151
 
@@ -17,6 +17,7 @@ class TestRDocContext < XrefTestCase
17
17
  assert_equal nil, @context.parent
18
18
  assert_equal :public, @context.visibility
19
19
  assert_equal 1, @context.sections.length
20
+ assert_equal nil, @context.temporary_section
20
21
 
21
22
  assert_empty @context.classes_hash
22
23
  assert_empty @context.modules_hash
@@ -137,6 +138,13 @@ class TestRDocContext < XrefTestCase
137
138
  assert_equal 'Object', object.superclass.full_name
138
139
  end
139
140
 
141
+ def test_add_class_singleton
142
+ @c1.add_class RDoc::NormalClass, 'Klass', 'Object'
143
+
144
+ assert_includes @c1.classes.map { |k| k.full_name }, 'C1::Klass'
145
+ assert_includes RDoc::TopLevel.classes.map { |k| k.full_name }, 'C1::Klass'
146
+ end
147
+
140
148
  def test_add_class_superclass
141
149
  @c1.add_class RDoc::NormalClass, 'Klass', 'Object'
142
150
  @c1.add_class RDoc::NormalClass, 'Klass', 'Other'
@@ -244,6 +252,29 @@ class TestRDocContext < XrefTestCase
244
252
  assert_includes @c1.top_level.requires, req
245
253
  end
246
254
 
255
+ def test_add_section
256
+ default_section = @context.sections.first
257
+
258
+ @context.add_section nil, '# comment'
259
+
260
+ assert_equal 1, @context.sections.length
261
+ assert_equal '# comment', @context.sections.first.comment
262
+
263
+ @context.add_section nil, '# new comment'
264
+
265
+ assert_equal 1, @context.sections.length
266
+ assert_equal "# comment\n# ---\n# new comment",
267
+ @context.sections.first.comment
268
+
269
+ @context.add_section 'other', ''
270
+
271
+ assert_equal 2, @context.sections.length
272
+
273
+ new_section = @context.sections.find { |section| section.title == 'other' }
274
+ assert new_section
275
+ assert_equal default_section, @context.current_section
276
+ end
277
+
247
278
  def test_add_to
248
279
  incl = RDoc::Include.new 'Name', 'comment'
249
280
  arr = []
@@ -254,6 +285,19 @@ class TestRDocContext < XrefTestCase
254
285
  assert_equal @context.current_section, incl.section
255
286
  end
256
287
 
288
+ def test_add_to_temporary_section
289
+ incl = RDoc::Include.new 'Name', 'comment'
290
+ arr = []
291
+ section = @context.add_section 'temporary', ''
292
+ @context.temporary_section = section
293
+
294
+ @context.add_to arr, incl
295
+
296
+ assert_includes arr, incl
297
+ assert_equal @context, incl.parent
298
+ assert_equal section, incl.section
299
+ end
300
+
257
301
  def test_add_to_no_document_self
258
302
  incl = RDoc::Include.new 'Name', 'comment'
259
303
  arr = []
@@ -281,6 +325,16 @@ class TestRDocContext < XrefTestCase
281
325
  assert_equal %w[C3::H1 C3::H2], @c3.classes.map { |k| k.full_name }
282
326
  end
283
327
 
328
+ def test_current_section
329
+ default_section = @context.current_section
330
+
331
+ new_section = @context.add_section 'other', ''
332
+ @context.temporary_section = new_section
333
+
334
+ assert_equal new_section, @context.current_section
335
+ assert_equal default_section, @context.current_section
336
+ end
337
+
284
338
  def test_defined_in_eh
285
339
  assert @c1.defined_in?(@c1.top_level)
286
340
 
@@ -596,6 +650,22 @@ class TestRDocContext < XrefTestCase
596
650
  assert_equal [@pub, @prot, @priv], methods
597
651
  end
598
652
 
653
+ def test_set_current_section
654
+ default_section = @context.sections.first
655
+
656
+ @context.set_current_section nil, ''
657
+
658
+ assert_equal default_section, @context.current_section
659
+
660
+ @context.set_current_section 'other', ''
661
+
662
+ new_section = @context.sections.find { |section|
663
+ section != default_section
664
+ }
665
+
666
+ assert_equal new_section, @context.current_section
667
+ end
668
+
599
669
  def util_visibilities
600
670
  @pub = RDoc::AnyMethod.new nil, 'pub'
601
671
  @prot = RDoc::AnyMethod.new nil, 'prot'
@@ -5,7 +5,7 @@ require 'rdoc'
5
5
  require 'rdoc/code_objects'
6
6
 
7
7
  class TestRDocContextSection < MiniTest::Unit::TestCase
8
-
8
+
9
9
  def setup
10
10
  @S = RDoc::Context::Section
11
11
  @s = @S.new nil, 'section', '# comment'
@@ -9,6 +9,7 @@ class TestRDocGeneratorRI < MiniTest::Unit::TestCase
9
9
 
10
10
  def setup
11
11
  @options = RDoc::Options.new
12
+ @options.encoding = Encoding::UTF_8 if Object.const_defined? :Encoding
12
13
 
13
14
  @pwd = Dir.pwd
14
15
  RDoc::TopLevel.reset
@@ -21,9 +22,15 @@ class TestRDocGeneratorRI < MiniTest::Unit::TestCase
21
22
 
22
23
  @top_level = RDoc::TopLevel.new 'file.rb'
23
24
  @klass = @top_level.add_class RDoc::NormalClass, 'Object'
25
+
24
26
  @meth = RDoc::AnyMethod.new nil, 'method'
27
+ @meth.record_location @top_level
28
+
25
29
  @meth_bang = RDoc::AnyMethod.new nil, 'method!'
30
+ @meth_bang.record_location @top_level
31
+
26
32
  @attr = RDoc::Attr.new nil, 'attr', 'RW', ''
33
+ @attr.record_location @top_level
27
34
 
28
35
  @klass.add_method @meth
29
36
  @klass.add_method @meth_bang
@@ -44,9 +51,6 @@ class TestRDocGeneratorRI < MiniTest::Unit::TestCase
44
51
  end
45
52
 
46
53
  def test_generate
47
- top_level = RDoc::TopLevel.new 'file.rb'
48
- top_level.add_class @klass.class, @klass.name
49
-
50
54
  @g.generate nil
51
55
 
52
56
  assert_file File.join(@tmpdir, 'cache.ri')
@@ -56,6 +60,13 @@ class TestRDocGeneratorRI < MiniTest::Unit::TestCase
56
60
  assert_file File.join(@tmpdir, 'Object', 'attr-i.ri')
57
61
  assert_file File.join(@tmpdir, 'Object', 'method-i.ri')
58
62
  assert_file File.join(@tmpdir, 'Object', 'method%21-i.ri')
63
+
64
+ store = RDoc::RI::Store.new @tmpdir
65
+ store.load_cache
66
+
67
+ encoding = Object.const_defined?(:Encoding) ? Encoding::UTF_8 : nil
68
+
69
+ assert_equal encoding, store.encoding
59
70
  end
60
71
 
61
72
  def test_generate_dry_run
@@ -18,7 +18,61 @@ the time
18
18
  STR
19
19
 
20
20
  m = RDoc::Markup.new
21
- out = m.convert str, RDoc::Markup::ToTest.new
21
+
22
+ tt = RDoc::Markup::ToTest.new m
23
+
24
+ out = m.convert str, tt
25
+
26
+ expected = [
27
+ "now is the time",
28
+ "\n",
29
+ " hello\n dave\n",
30
+ "1: ",
31
+ "l1",
32
+ "1: ",
33
+ "l2",
34
+ ]
35
+
36
+ assert_equal expected, out
37
+ end
38
+
39
+ def test_convert_custom_markup
40
+ str = <<-STR
41
+ {stricken}
42
+ STR
43
+
44
+ m = RDoc::Markup.new
45
+ m.add_word_pair '{', '}', :STRIKE
46
+
47
+ tt = RDoc::Markup::ToTest.new m
48
+ tt.add_tag :STRIKE, 'STRIKE ', ' STRIKE'
49
+
50
+ out = m.convert str, tt
51
+
52
+ expected = [
53
+ "STRIKE stricken STRIKE",
54
+ ]
55
+
56
+ assert_equal expected, out
57
+ end
58
+
59
+ def test_convert_document
60
+ doc = RDoc::Markup::Parser.parse <<-STR
61
+ now is
62
+ the time
63
+
64
+ hello
65
+ dave
66
+
67
+ 1. l1
68
+ 2. l2
69
+ STR
70
+
71
+ m = RDoc::Markup.new
72
+
73
+ tt = RDoc::Markup::ToTest.new m
74
+
75
+ out = m.convert doc, tt
22
76
 
23
77
  expected = [
24
78
  "now is the time",
@@ -47,5 +47,88 @@ class TestRDocMarkupDocument < MiniTest::Unit::TestCase
47
47
  end
48
48
  end
49
49
 
50
+ def test_empty_eh
51
+ assert_empty @d
52
+
53
+ @d << @RM::BlankLine.new
54
+
55
+ refute_empty @d
56
+ end
57
+
58
+ def test_empty_eh_document
59
+ d = @RM::Document.new @d
60
+
61
+ assert_empty d
62
+ end
63
+
64
+ def test_equals2
65
+ d2 = @RM::Document.new
66
+
67
+ assert_equal @d, d2
68
+
69
+ d2 << @RM::BlankLine.new
70
+
71
+ refute_equal @d, d2
72
+ end
73
+
74
+ def test_equals2_file
75
+ d2 = @RM::Document.new
76
+ d2.file = 'file.rb'
77
+
78
+ refute_equal @d, d2
79
+
80
+ @d.file = 'file.rb'
81
+
82
+ assert_equal @d, d2
83
+ end
84
+
85
+ def test_lt2
86
+ @d << @RM::BlankLine.new
87
+
88
+ refute_empty @d
89
+ end
90
+
91
+ def test_merge
92
+ original = @RM::Document.new @RM::Paragraph.new 'original'
93
+ original.file = 'file.rb'
94
+ root = @RM::Document.new original
95
+
96
+ replace = @RM::Document.new @RM::Paragraph.new 'replace'
97
+ replace.file = 'file.rb'
98
+
99
+ other = @RM::Document.new replace
100
+
101
+ result = root.merge other
102
+
103
+ inner = @RM::Document.new @RM::Paragraph.new 'replace'
104
+ inner.file = 'file.rb'
105
+ expected = @RM::Document.new inner
106
+
107
+ assert_equal expected, result
108
+ end
109
+
110
+ def test_merge_add
111
+ original = @RM::Document.new @RM::Paragraph.new 'original'
112
+ original.file = 'file.rb'
113
+ root = @RM::Document.new original
114
+
115
+ addition = @RM::Document.new @RM::Paragraph.new 'addition'
116
+ addition.file = 'other.rb'
117
+
118
+ other = @RM::Document.new addition
119
+
120
+ result = root.merge other
121
+
122
+ expected = @RM::Document.new original, addition
123
+
124
+ assert_equal expected, result
125
+ end
126
+
127
+ def test_push
128
+ @d.push @RM::BlankLine.new, @RM::BlankLine.new
129
+
130
+ refute_empty @d
131
+ end
132
+
50
133
  end
51
134
 
@@ -0,0 +1,40 @@
1
+ require 'pp'
2
+ require 'rubygems'
3
+ require 'minitest/autorun'
4
+ require 'rdoc/markup'
5
+
6
+ class TestRDocMarkupIndentedParagraph < MiniTest::Unit::TestCase
7
+
8
+ def setup
9
+ @IP = RDoc::Markup::IndentedParagraph
10
+ end
11
+
12
+ def test_initialize
13
+ ip = @IP.new 2, 'a', 'b'
14
+
15
+ assert_equal 2, ip.indent
16
+ assert_equal %w[a b], ip.parts
17
+ end
18
+
19
+ def test_accept
20
+ visitor = Object.new
21
+ def visitor.accept_indented_paragraph(obj) @obj = obj end
22
+ def visitor.obj() @obj end
23
+
24
+ paragraph = @IP.new 0
25
+
26
+ paragraph.accept visitor
27
+
28
+ assert_equal paragraph, visitor.obj
29
+ end
30
+
31
+ def test_equals2
32
+ one = @IP.new 1
33
+ two = @IP.new 2
34
+
35
+ assert_equal one, one
36
+ refute_equal one, two
37
+ end
38
+
39
+ end
40
+
@@ -5,5 +5,17 @@ require 'rdoc/markup'
5
5
 
6
6
  class TestRDocMarkupParagraph < MiniTest::Unit::TestCase
7
7
 
8
+ def test_accept
9
+ visitor = Object.new
10
+ def visitor.accept_paragraph(obj) @obj = obj end
11
+ def visitor.obj() @obj end
12
+
13
+ paragraph = RDoc::Markup::Paragraph.new
14
+
15
+ paragraph.accept visitor
16
+
17
+ assert_equal paragraph, visitor.obj
18
+ end
19
+
8
20
  end
9
21
 
@@ -43,7 +43,7 @@ contents of a string.
43
43
  # FIXME 1.9 fix on windoze
44
44
  # preprocessor uses binread, so line endings are \r\n
45
45
  expected.gsub!("\n", "\r\n") if
46
- RUBY_VERSION =~ /^1.9/ && RUBY_PLATFORM =~ /mswin|mingw/
46
+ RUBY_VERSION < "1.9.3" && RUBY_PLATFORM =~ /mswin|mingw/
47
47
 
48
48
  assert_equal expected, content
49
49
  end
@@ -67,7 +67,7 @@ contents of a string.
67
67
  # FIXME 1.9 fix on windoze
68
68
  # preprocessor uses binread, so line endings are \r\n
69
69
  expected.gsub!("\n", "\r\n") if
70
- RUBY_VERSION =~ /^1.9/ && RUBY_PLATFORM =~ /mswin|mingw/
70
+ RUBY_VERSION < "1.9.3" && RUBY_PLATFORM =~ /mswin|mingw/
71
71
 
72
72
  assert_equal expected, content
73
73
  end
@@ -96,6 +96,17 @@ contents of a string.
96
96
  assert_equal "", text
97
97
  end
98
98
 
99
+ def test_handle_category
100
+ context = RDoc::Context.new
101
+ original_section = context.current_section
102
+
103
+ text = "# :category: other\n"
104
+
105
+ @pp.handle text, context
106
+
107
+ refute_equal original_section, context.current_section
108
+ end
109
+
99
110
  def test_handle_code_object
100
111
  cd = RDoc::CodeObject.new
101
112
  text = "# :x: y\n"
@@ -18,6 +18,10 @@ class TestRDocMarkupToAnsi < RDoc::Markup::TextFormatterTestCase
18
18
  assert_equal "\e[0m\n", @to.res.join
19
19
  end
20
20
 
21
+ def accept_document
22
+ assert_equal "\e[0mhello\n", @to.res.join
23
+ end
24
+
21
25
  def accept_heading
22
26
  assert_equal "\e[0mHello\n", @to.res.join
23
27
  end