rdoc 4.0.0.preview2.1 → 4.0.0.rc.2

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 (64) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CVE-2013-0256.rdoc +49 -0
  5. data/History.rdoc +33 -1
  6. data/Manifest.txt +3 -1
  7. data/Rakefile +2 -1
  8. data/lib/rdoc.rb +1 -1
  9. data/lib/rdoc/any_method.rb +2 -0
  10. data/lib/rdoc/attr.rb +2 -0
  11. data/lib/rdoc/class_module.rb +1 -0
  12. data/lib/rdoc/code_object.rb +7 -0
  13. data/lib/rdoc/cross_reference.rb +1 -1
  14. data/lib/rdoc/encoding.rb +3 -1
  15. data/lib/rdoc/generator/darkfish.rb +1 -1
  16. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +9 -7
  17. data/lib/rdoc/generator/template/darkfish/rdoc.css +21 -0
  18. data/lib/rdoc/generator/template/json_index/.document +1 -0
  19. data/lib/rdoc/markup/attribute_manager.rb +5 -7
  20. data/lib/rdoc/markup/formatter.rb +75 -0
  21. data/lib/rdoc/markup/to_html.rb +9 -57
  22. data/lib/rdoc/markup/to_markdown.rb +55 -0
  23. data/lib/rdoc/parser.rb +35 -11
  24. data/lib/rdoc/parser/changelog.rb +9 -1
  25. data/lib/rdoc/parser/ruby.rb +23 -4
  26. data/lib/rdoc/rd/block_parser.rb +3 -2
  27. data/lib/rdoc/rd/block_parser.ry +3 -2
  28. data/lib/rdoc/rd/inline_parser.rb +1 -1
  29. data/lib/rdoc/rd/inline_parser.ry +1 -1
  30. data/lib/rdoc/ruby_lex.rb +20 -4
  31. data/lib/rdoc/ruby_token.rb +1 -0
  32. data/lib/rdoc/servlet.rb +25 -16
  33. data/lib/rdoc/store.rb +9 -4
  34. data/lib/rdoc/tom_doc.rb +1 -1
  35. data/lib/rdoc/top_level.rb +2 -1
  36. data/test/{test.ja.large.rdoc → test.ja.largedoc} +0 -0
  37. data/test/test_rdoc_any_method.rb +16 -7
  38. data/test/test_rdoc_attr.rb +4 -0
  39. data/test/test_rdoc_class_module.rb +2 -0
  40. data/test/test_rdoc_comment.rb +1 -1
  41. data/test/test_rdoc_constant.rb +4 -0
  42. data/test/test_rdoc_cross_reference.rb +15 -0
  43. data/test/test_rdoc_encoding.rb +1 -1
  44. data/test/test_rdoc_generator_markup.rb +4 -1
  45. data/test/test_rdoc_markup_formatter.rb +91 -0
  46. data/test/test_rdoc_markup_to_html.rb +52 -23
  47. data/test/test_rdoc_markup_to_markdown.rb +31 -0
  48. data/test/test_rdoc_options.rb +11 -0
  49. data/test/test_rdoc_parser.rb +50 -5
  50. data/test/test_rdoc_parser_c.rb +34 -11
  51. data/test/test_rdoc_parser_changelog.rb +32 -4
  52. data/test/test_rdoc_parser_markdown.rb +11 -5
  53. data/test/test_rdoc_parser_rd.rb +15 -5
  54. data/test/test_rdoc_parser_ruby.rb +23 -0
  55. data/test/test_rdoc_rd_block_parser.rb +141 -123
  56. data/test/test_rdoc_rd_inline_parser.rb +6 -1
  57. data/test/test_rdoc_rdoc.rb +5 -2
  58. data/test/test_rdoc_ruby_lex.rb +51 -5
  59. data/test/test_rdoc_servlet.rb +43 -5
  60. data/test/test_rdoc_store.rb +55 -4
  61. data/test/test_rdoc_tom_doc.rb +37 -0
  62. data/test/test_rdoc_top_level.rb +17 -1
  63. metadata +29 -34
  64. metadata.gz.sig +0 -0
@@ -549,6 +549,17 @@ rdoc_include:
549
549
  FileUtils.rm_rf tmpdir
550
550
  end
551
551
 
552
+ def test_parse_extension_alias
553
+ out, err = capture_io do
554
+ @options.parse %w[--extension foobar=rdoc]
555
+ end
556
+
557
+ assert_includes RDoc::Parser.parsers, [/\.foobar$/, RDoc::Parser::Simple]
558
+
559
+ assert_empty out
560
+ assert_empty err
561
+ end
562
+
552
563
  def test_setup_generator
553
564
  test_generator = Class.new do
554
565
  def self.setup_options op
@@ -33,8 +33,18 @@ class TestRDocParser < RDoc::TestCase
33
33
  end
34
34
 
35
35
  def test_class_binary_large_japanese_rdoc
36
- file_name = File.expand_path '../test.ja.large.rdoc', __FILE__
37
- assert !@RP.binary?(file_name)
36
+ skip "Encoding not implemented" unless Object.const_defined? :Encoding
37
+
38
+ capture_io do
39
+ begin
40
+ extenc, Encoding.default_external =
41
+ Encoding.default_external, Encoding::US_ASCII
42
+ file_name = File.expand_path '../test.ja.largedoc', __FILE__
43
+ assert !@RP.binary?(file_name)
44
+ ensure
45
+ Encoding.default_external = extenc
46
+ end
47
+ end
38
48
  end
39
49
 
40
50
  def test_class_binary_japanese_rdoc
@@ -51,7 +61,7 @@ class TestRDocParser < RDoc::TestCase
51
61
 
52
62
  assert_equal @RP::Simple, @RP.can_parse(readme_file_name)
53
63
 
54
- assert_nil @RP.can_parse(@binary_dat)
64
+ assert_equal @RP::Simple, @RP.can_parse(@binary_dat)
55
65
 
56
66
  jtest_file_name = File.expand_path '../test.ja.txt', __FILE__
57
67
  assert_equal @RP::Simple, @RP.can_parse(jtest_file_name)
@@ -61,16 +71,39 @@ class TestRDocParser < RDoc::TestCase
61
71
 
62
72
  readme_file_name = File.expand_path '../README', __FILE__
63
73
  assert_equal @RP::Simple, @RP.can_parse(readme_file_name)
74
+
75
+ jtest_largerdoc_file_name = File.expand_path '../test.ja.largedoc', __FILE__
76
+ assert_equal @RP::Simple, @RP.can_parse(jtest_largerdoc_file_name)
77
+
78
+ @RP.alias_extension 'rdoc', 'largedoc'
79
+ assert_equal @RP::Simple, @RP.can_parse(jtest_largerdoc_file_name)
80
+ end
81
+
82
+ def test_class_for_executable
83
+ temp_dir do
84
+ content = "#!/usr/bin/env ruby -w\n"
85
+ open 'app', 'w' do |io| io.write content end
86
+ app = @store.add_file 'app'
87
+
88
+ parser = @RP.for app, 'app', content, @options, :stats
89
+
90
+ assert_kind_of RDoc::Parser::Ruby, parser
91
+
92
+ assert_equal 'app', parser.file_name
93
+ end
64
94
  end
65
95
 
66
- def test_class_can_parse_forbidden
96
+ def test_class_for_forbidden
67
97
  skip 'chmod not supported' if Gem.win_platform?
68
98
 
69
99
  Tempfile.open 'forbidden' do |io|
70
100
  begin
71
101
  File.chmod 0000, io.path
102
+ forbidden = @store.add_file io.path
103
+
104
+ parser = @RP.for forbidden, 'forbidden', '', @options, :stats
72
105
 
73
- assert_nil @RP.can_parse io.path
106
+ assert_nil parser
74
107
  ensure
75
108
  File.chmod 0400, io.path
76
109
  end
@@ -113,6 +146,18 @@ class TestRDocParser < RDoc::TestCase
113
146
  File.unlink readme_ext
114
147
  end
115
148
 
149
+ def test_check_modeline_coding
150
+ readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
151
+
152
+ open readme_ext, 'w' do |io|
153
+ io.puts "# -*- coding: utf-8 -*-"
154
+ end
155
+
156
+ assert_nil @RP.check_modeline readme_ext
157
+ ensure
158
+ File.unlink readme_ext
159
+ end
160
+
116
161
  def test_check_modeline_with_other
117
162
  readme_ext = File.join Dir.tmpdir, "README.EXT.#{$$}"
118
163
 
@@ -64,17 +64,40 @@ class TestRDocParserC < RDoc::TestCase
64
64
  def test_class_can_parse
65
65
  c_parser = RDoc::Parser::C
66
66
 
67
- assert_equal c_parser, c_parser.can_parse('file.C')
68
- assert_equal c_parser, c_parser.can_parse('file.CC')
69
- assert_equal c_parser, c_parser.can_parse('file.H')
70
- assert_equal c_parser, c_parser.can_parse('file.HH')
71
- assert_equal c_parser, c_parser.can_parse('file.c')
72
- assert_equal c_parser, c_parser.can_parse('file.cc')
73
- assert_equal c_parser, c_parser.can_parse('file.cpp')
74
- assert_equal c_parser, c_parser.can_parse('file.cxx')
75
- assert_equal c_parser, c_parser.can_parse('file.h')
76
- assert_equal c_parser, c_parser.can_parse('file.hh')
77
- assert_equal c_parser, c_parser.can_parse('file.y')
67
+ temp_dir do
68
+ FileUtils.touch 'file.C'
69
+ assert_equal c_parser, c_parser.can_parse('file.C')
70
+
71
+ FileUtils.touch 'file.CC'
72
+ assert_equal c_parser, c_parser.can_parse('file.CC')
73
+
74
+ FileUtils.touch 'file.H'
75
+ assert_equal c_parser, c_parser.can_parse('file.H')
76
+
77
+ FileUtils.touch 'file.HH'
78
+ assert_equal c_parser, c_parser.can_parse('file.HH')
79
+
80
+ FileUtils.touch 'file.c'
81
+ assert_equal c_parser, c_parser.can_parse('file.c')
82
+
83
+ FileUtils.touch 'file.cc'
84
+ assert_equal c_parser, c_parser.can_parse('file.cc')
85
+
86
+ FileUtils.touch 'file.cpp'
87
+ assert_equal c_parser, c_parser.can_parse('file.cpp')
88
+
89
+ FileUtils.touch 'file.cxx'
90
+ assert_equal c_parser, c_parser.can_parse('file.cxx')
91
+
92
+ FileUtils.touch 'file.h'
93
+ assert_equal c_parser, c_parser.can_parse('file.h')
94
+
95
+ FileUtils.touch 'file.hh'
96
+ assert_equal c_parser, c_parser.can_parse('file.hh')
97
+
98
+ FileUtils.touch 'file.y'
99
+ assert_equal c_parser, c_parser.can_parse('file.y')
100
+ end
78
101
  end
79
102
 
80
103
  def test_initialize
@@ -25,11 +25,15 @@ class TestRDocParserChangeLog < RDoc::TestCase
25
25
  def test_class_can_parse
26
26
  parser = RDoc::Parser::ChangeLog
27
27
 
28
- assert_equal parser, parser.can_parse('ChangeLog')
28
+ temp_dir do
29
+ FileUtils.touch 'ChangeLog'
30
+ assert_equal parser, parser.can_parse('ChangeLog')
29
31
 
30
- assert_equal parser, parser.can_parse(@tempfile.path)
32
+ assert_equal parser, parser.can_parse(@tempfile.path)
31
33
 
32
- assert_equal RDoc::Parser::Ruby, parser.can_parse('ChangeLog.rb')
34
+ FileUtils.touch 'ChangeLog.rb'
35
+ assert_equal RDoc::Parser::Ruby, parser.can_parse('ChangeLog.rb')
36
+ end
33
37
  end
34
38
 
35
39
  def test_continue_entry_body
@@ -178,7 +182,9 @@ class TestRDocParserChangeLog < RDoc::TestCase
178
182
  [ 'Tue Dec 4 08:32:10 2012 Eric Hodel <drbrain@segment7.net>',
179
183
  %w[three four]],
180
184
  [ 'Mon Dec 3 20:28:02 2012 Koichi Sasada <ko1@atdot.net>',
181
- %w[five six]]]
185
+ %w[five six]],
186
+ [ '2008-01-30 H.J. Lu <hongjiu.lu@intel.com>',
187
+ %w[seven eight]]]
182
188
 
183
189
  expected = {
184
190
  '2012-12-04' => [
@@ -189,6 +195,9 @@ class TestRDocParserChangeLog < RDoc::TestCase
189
195
  '2012-12-03' => [
190
196
  ['Mon Dec 3 20:28:02 2012 Koichi Sasada <ko1@atdot.net>',
191
197
  %w[five six]]],
198
+ '2008-01-30' => [
199
+ ['2008-01-30 H.J. Lu <hongjiu.lu@intel.com>',
200
+ %w[seven eight]]],
192
201
  }
193
202
 
194
203
  assert_equal expected, parser.group_entries(entries)
@@ -222,6 +231,25 @@ Other note that will be ignored
222
231
  assert_equal expected, parser.parse_entries
223
232
  end
224
233
 
234
+ def test_parse_entries_bad_time
235
+ parser = util_parser <<-ChangeLog
236
+ 2008-01-30 H.J. Lu <hongjiu.lu@intel.com>
237
+
238
+ PR libffi/34612
239
+ * src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when
240
+ returning struct.
241
+
242
+ ChangeLog
243
+
244
+ expected = [
245
+ [ '2008-01-30 H.J. Lu <hongjiu.lu@intel.com>',
246
+ [ 'src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when ' +
247
+ 'returning struct.']]
248
+ ]
249
+
250
+ assert_equal expected, parser.parse_entries
251
+ end
252
+
225
253
  def test_parse_entries_gnu
226
254
  parser = util_parser <<-ChangeLog
227
255
  1998-08-17 Richard Stallman <rms@gnu.org>
@@ -27,11 +27,17 @@ class TestRDocParserMarkdown < RDoc::TestCase
27
27
  end
28
28
 
29
29
  def test_class_can_parse
30
- assert_equal @RP::Markdown, @RP.can_parse('foo.md')
31
- assert_equal @RP::Markdown, @RP.can_parse('foo.md.ja')
32
-
33
- assert_equal @RP::Markdown, @RP.can_parse('foo.markdown')
34
- assert_equal @RP::Markdown, @RP.can_parse('foo.markdown.ja')
30
+ temp_dir do
31
+ FileUtils.touch 'foo.md'
32
+ assert_equal @RP::Markdown, @RP.can_parse('foo.md')
33
+ FileUtils.touch 'foo.md.ja'
34
+ assert_equal @RP::Markdown, @RP.can_parse('foo.md.ja')
35
+
36
+ FileUtils.touch 'foo.markdown'
37
+ assert_equal @RP::Markdown, @RP.can_parse('foo.markdown')
38
+ FileUtils.touch 'foo.markdown.ja'
39
+ assert_equal @RP::Markdown, @RP.can_parse('foo.markdown.ja')
40
+ end
35
41
  end
36
42
 
37
43
  def test_scan
@@ -22,21 +22,31 @@ class TestRDocParserRd < RDoc::TestCase
22
22
  @tempfile.close
23
23
  end
24
24
 
25
+ def mu_pp obj
26
+ s = ''
27
+ s = PP.pp obj, s
28
+ s = s.force_encoding Encoding.default_external if defined? Encoding
29
+ s.chomp
30
+ end
31
+
25
32
  def test_file
26
33
  assert_kind_of RDoc::Parser::Text, util_parser('')
27
34
  end
28
35
 
29
36
  def test_class_can_parse
30
- assert_equal @RP::RD, @RP.can_parse('foo.rd')
31
- assert_equal @RP::RD, @RP.can_parse('foo.rd.ja')
37
+ temp_dir do
38
+ FileUtils.touch 'foo.rd'
39
+ assert_equal @RP::RD, @RP.can_parse('foo.rd')
40
+
41
+ FileUtils.touch 'foo.rd.ja'
42
+ assert_equal @RP::RD, @RP.can_parse('foo.rd.ja')
43
+ end
32
44
  end
33
45
 
34
46
  def test_scan
35
47
  parser = util_parser 'it ((*really*)) works'
36
48
 
37
- expected =
38
- @RM::Document.new(
39
- @RM::Paragraph.new('it <em>really</em> works'))
49
+ expected = doc(para('it <em>really</em> works'))
40
50
  expected.file = @top_level
41
51
 
42
52
  parser.scan
@@ -1525,6 +1525,21 @@ end
1525
1525
  assert ampersand.singleton
1526
1526
  end
1527
1527
 
1528
+ def test_parse_method_constant
1529
+ c = RDoc::Constant.new 'CONST', nil, ''
1530
+ m = @top_level.add_class RDoc::NormalModule, 'M'
1531
+ m.add_constant c
1532
+
1533
+ util_parser "def CONST.m() end"
1534
+
1535
+ tk = @parser.get_tk
1536
+
1537
+ @parser.parse_method m, RDoc::Parser::Ruby::NORMAL, tk, @comment
1538
+
1539
+ assert_empty @store.modules_hash.keys
1540
+ assert_equal %w[M], @store.classes_hash.keys
1541
+ end
1542
+
1528
1543
  def test_parse_method_false
1529
1544
  util_parser "def false.foo() :bar end"
1530
1545
 
@@ -1766,6 +1781,14 @@ end
1766
1781
  assert_equal "def \317\211", omega.text
1767
1782
  end
1768
1783
 
1784
+ def test_parse_method_dummy
1785
+ util_parser ".method() end"
1786
+
1787
+ @parser.parse_method_dummy @top_level
1788
+
1789
+ assert_nil @parser.get_tk
1790
+ end
1791
+
1769
1792
  def test_parse_method_or_yield_parameters_hash
1770
1793
  util_parser "({})\n"
1771
1794
 
@@ -15,6 +15,23 @@ class TestRDocRdBlockParser < RDoc::TestCase
15
15
  s.chomp
16
16
  end
17
17
 
18
+ def test_add_footnote
19
+ index = @block_parser.add_footnote 'context'
20
+
21
+ assert_equal 1, index
22
+
23
+ expected = [
24
+ para('{^1}[rdoc-label:footmark-1:foottext-1]', ' ', 'context'),
25
+ blank_line,
26
+ ]
27
+
28
+ assert_equal expected, @block_parser.footnotes
29
+
30
+ index = @block_parser.add_footnote 'other'
31
+
32
+ assert_equal 2, index
33
+ end
34
+
18
35
  def test_parse_desclist
19
36
  list = <<-LIST
20
37
  :one
@@ -25,9 +42,9 @@ class TestRDocRdBlockParser < RDoc::TestCase
25
42
 
26
43
  expected =
27
44
  doc(
28
- @RM::List.new(:NOTE,
29
- @RM::ListItem.new("one", @RM::Paragraph.new("desc one")),
30
- @RM::ListItem.new("two", @RM::Paragraph.new("desc two"))))
45
+ list(:NOTE,
46
+ item("one", para("desc one")),
47
+ item("two", para("desc two"))))
31
48
 
32
49
  assert_equal expected, parse(list)
33
50
  end
@@ -40,9 +57,9 @@ class TestRDocRdBlockParser < RDoc::TestCase
40
57
 
41
58
  expected =
42
59
  doc(
43
- @RM::List.new(:NUMBER,
44
- @RM::ListItem.new(nil, @RM::Paragraph.new("one")),
45
- @RM::ListItem.new(nil, @RM::Paragraph.new("two"))))
60
+ list(:NUMBER,
61
+ item(nil, para("one")),
62
+ item(nil, para("two"))))
46
63
 
47
64
  assert_equal expected, parse(list)
48
65
  end
@@ -56,10 +73,10 @@ class TestRDocRdBlockParser < RDoc::TestCase
56
73
 
57
74
  expected =
58
75
  doc(
59
- @RM::List.new(:NUMBER,
60
- @RM::ListItem.new(nil,
61
- @RM::Paragraph.new("one"),
62
- @RM::Paragraph.new("two"))))
76
+ list(:NUMBER,
77
+ item(nil,
78
+ para("one"),
79
+ para("two"))))
63
80
 
64
81
  assert_equal expected, parse(list)
65
82
  end
@@ -74,8 +91,8 @@ class TestRDocRdBlockParser < RDoc::TestCase
74
91
 
75
92
  expected =
76
93
  doc(
77
- @RM::List.new(:NUMBER,
78
- @RM::ListItem.new(nil, @RM::Paragraph.new(*contents))))
94
+ list(:NUMBER,
95
+ item(nil, para(*contents))))
79
96
 
80
97
  assert_equal expected, parse(list)
81
98
  end
@@ -88,10 +105,10 @@ class TestRDocRdBlockParser < RDoc::TestCase
88
105
 
89
106
  expected =
90
107
  doc(
91
- @RM::List.new(:NUMBER,
92
- @RM::ListItem.new(nil,
93
- @RM::Paragraph.new("item"),
94
- @RM::Verbatim.new("verbatim\n"))))
108
+ list(:NUMBER,
109
+ item(nil,
110
+ para("item"),
111
+ verb("verbatim\n"))))
95
112
 
96
113
  assert_equal expected, parse(list)
97
114
  end
@@ -105,11 +122,11 @@ class TestRDocRdBlockParser < RDoc::TestCase
105
122
 
106
123
  expected =
107
124
  doc(
108
- @RM::List.new(:NUMBER,
109
- @RM::ListItem.new(nil,
110
- @RM::Paragraph.new("one"),
111
- @RM::Verbatim.new("verbatim\n"),
112
- @RM::Paragraph.new("two"))))
125
+ list(:NUMBER,
126
+ item(nil,
127
+ para("one"),
128
+ verb("verbatim\n"),
129
+ para("two"))))
113
130
 
114
131
  assert_equal expected, parse(list)
115
132
  end
@@ -117,9 +134,10 @@ class TestRDocRdBlockParser < RDoc::TestCase
117
134
  def test_parse_footnote
118
135
  expected =
119
136
  doc(
120
- @RM::Paragraph.new("{*1}[rdoc-label:foottext-1:footmark-1]"),
121
- @RM::Rule.new(1),
122
- @RM::Paragraph.new("{^1}[rdoc-label:footmark-1:foottext-1]", "text"))
137
+ para("{*1}[rdoc-label:foottext-1:footmark-1]"),
138
+ rule(1),
139
+ para("{^1}[rdoc-label:footmark-1:foottext-1]", " ", "text"),
140
+ blank_line)
123
141
 
124
142
  assert_equal expected, parse("((-text-))")
125
143
  end
@@ -137,10 +155,10 @@ class TestRDocRdBlockParser < RDoc::TestCase
137
155
 
138
156
  expected =
139
157
  doc(
140
- @RM::BlankLine.new,
141
- @RM::Paragraph.new("include <em>worked</em>"),
142
- @RM::BlankLine.new,
143
- @RM::BlankLine.new)
158
+ blank_line,
159
+ para("include <em>worked</em>"),
160
+ blank_line,
161
+ blank_line)
144
162
 
145
163
  Tempfile.open %w[parse_include .rd] do |io|
146
164
  io.puts "=begin\ninclude ((*worked*))\n=end"
@@ -155,12 +173,12 @@ class TestRDocRdBlockParser < RDoc::TestCase
155
173
  end
156
174
 
157
175
  def test_parse_heading
158
- assert_equal doc(@RM::Heading.new(1, "H")), parse("= H")
159
- assert_equal doc(@RM::Heading.new(2, "H")), parse("== H")
160
- assert_equal doc(@RM::Heading.new(3, "H")), parse("=== H")
161
- assert_equal doc(@RM::Heading.new(4, "H")), parse("==== H")
162
- assert_equal doc(@RM::Heading.new(5, "H")), parse("+ H")
163
- assert_equal doc(@RM::Heading.new(6, "H")), parse("++ H")
176
+ assert_equal doc(head(1, "H")), parse("= H")
177
+ assert_equal doc(head(2, "H")), parse("== H")
178
+ assert_equal doc(head(3, "H")), parse("=== H")
179
+ assert_equal doc(head(4, "H")), parse("==== H")
180
+ assert_equal doc(head(5, "H")), parse("+ H")
181
+ assert_equal doc(head(6, "H")), parse("++ H")
164
182
  end
165
183
 
166
184
  def test_parse_itemlist
@@ -171,9 +189,9 @@ class TestRDocRdBlockParser < RDoc::TestCase
171
189
 
172
190
  expected =
173
191
  doc(
174
- @RM::List.new(:BULLET,
175
- @RM::ListItem.new(nil, @RM::Paragraph.new("one")),
176
- @RM::ListItem.new(nil, @RM::Paragraph.new("two"))))
192
+ list(:BULLET,
193
+ item(nil, para("one")),
194
+ item(nil, para("two"))))
177
195
 
178
196
  assert_equal expected, parse(list)
179
197
  end
@@ -188,8 +206,8 @@ class TestRDocRdBlockParser < RDoc::TestCase
188
206
 
189
207
  expected =
190
208
  doc(
191
- @RM::List.new(:BULLET,
192
- @RM::ListItem.new(nil, @RM::Paragraph.new(*contents))))
209
+ list(:BULLET,
210
+ item(nil, para(*contents))))
193
211
 
194
212
  assert_equal expected, parse(list)
195
213
  end
@@ -203,13 +221,13 @@ class TestRDocRdBlockParser < RDoc::TestCase
203
221
 
204
222
  expected =
205
223
  doc(
206
- @RM::List.new(:BULLET,
207
- @RM::ListItem.new(nil,
208
- @RM::Paragraph.new("one"),
209
- @RM::List.new(:BULLET,
210
- @RM::ListItem.new(nil, @RM::Paragraph.new("inner")))),
211
- @RM::ListItem.new(nil,
212
- @RM::Paragraph.new("two"))))
224
+ list(:BULLET,
225
+ item(nil,
226
+ para("one"),
227
+ list(:BULLET,
228
+ item(nil, para("inner")))),
229
+ item(nil,
230
+ para("two"))))
213
231
 
214
232
  assert_equal expected, parse(list)
215
233
  end
@@ -223,10 +241,10 @@ class TestRDocRdBlockParser < RDoc::TestCase
223
241
 
224
242
  expected =
225
243
  doc(
226
- @RM::List.new(:BULLET,
227
- @RM::ListItem.new(nil,
228
- @RM::Paragraph.new("one"),
229
- @RM::Paragraph.new("two"))))
244
+ list(:BULLET,
245
+ item(nil,
246
+ para("one"),
247
+ para("two"))))
230
248
 
231
249
  assert_equal expected, parse(list)
232
250
  end
@@ -239,10 +257,10 @@ class TestRDocRdBlockParser < RDoc::TestCase
239
257
 
240
258
  expected =
241
259
  doc(
242
- @RM::List.new(:BULLET,
243
- @RM::ListItem.new(nil,
244
- @RM::Paragraph.new("item"),
245
- @RM::Verbatim.new("verbatim\n"))))
260
+ list(:BULLET,
261
+ item(nil,
262
+ para("item"),
263
+ verb("verbatim\n"))))
246
264
 
247
265
  assert_equal expected, parse(list)
248
266
  end
@@ -256,11 +274,11 @@ class TestRDocRdBlockParser < RDoc::TestCase
256
274
 
257
275
  expected =
258
276
  doc(
259
- @RM::List.new(:BULLET,
260
- @RM::ListItem.new(nil,
261
- @RM::Paragraph.new("one"),
262
- @RM::Verbatim.new("verbatim\n"),
263
- @RM::Paragraph.new("two"))))
277
+ list(:BULLET,
278
+ item(nil,
279
+ para("one"),
280
+ verb("verbatim\n"),
281
+ para("two"))))
264
282
 
265
283
  assert_equal expected, parse(list)
266
284
  end
@@ -277,15 +295,15 @@ class TestRDocRdBlockParser < RDoc::TestCase
277
295
 
278
296
  expected =
279
297
  doc(
280
- @RM::List.new(:NUMBER,
281
- @RM::ListItem.new(nil, @RM::Paragraph.new("one")),
282
- @RM::ListItem.new(nil, @RM::Paragraph.new("two"))),
283
- @RM::List.new(:BULLET,
284
- @RM::ListItem.new(nil, @RM::Paragraph.new("three")),
285
- @RM::ListItem.new(nil, @RM::Paragraph.new("four"))),
286
- @RM::List.new(:NUMBER,
287
- @RM::ListItem.new(nil, @RM::Paragraph.new("five")),
288
- @RM::ListItem.new(nil, @RM::Paragraph.new("six"))))
298
+ list(:NUMBER,
299
+ item(nil, para("one")),
300
+ item(nil, para("two"))),
301
+ list(:BULLET,
302
+ item(nil, para("three")),
303
+ item(nil, para("four"))),
304
+ list(:NUMBER,
305
+ item(nil, para("five")),
306
+ item(nil, para("six"))))
289
307
 
290
308
  assert_equal expected, parse(list)
291
309
  end
@@ -302,15 +320,15 @@ class TestRDocRdBlockParser < RDoc::TestCase
302
320
 
303
321
  expected =
304
322
  doc(
305
- @RM::List.new(:NUMBER,
306
- @RM::ListItem.new(nil, @RM::Paragraph.new("one")),
307
- @RM::ListItem.new(nil,
308
- @RM::Paragraph.new("two"),
309
- @RM::List.new(:BULLET,
310
- @RM::ListItem.new(nil, @RM::Paragraph.new("three")),
311
- @RM::ListItem.new(nil, @RM::Paragraph.new("four")))),
312
- @RM::ListItem.new(nil, @RM::Paragraph.new("five")),
313
- @RM::ListItem.new(nil, @RM::Paragraph.new("six"))))
323
+ list(:NUMBER,
324
+ item(nil, para("one")),
325
+ item(nil,
326
+ para("two"),
327
+ list(:BULLET,
328
+ item(nil, para("three")),
329
+ item(nil, para("four")))),
330
+ item(nil, para("five")),
331
+ item(nil, para("six"))))
314
332
 
315
333
  assert_equal expected, parse(list)
316
334
  end
@@ -328,16 +346,16 @@ class TestRDocRdBlockParser < RDoc::TestCase
328
346
 
329
347
  expected =
330
348
  doc(
331
- @RM::List.new(:NUMBER,
332
- @RM::ListItem.new(nil, @RM::Paragraph.new("one")),
333
- @RM::ListItem.new(nil,
334
- @RM::Paragraph.new("two"),
335
- @RM::List.new(:BULLET,
336
- @RM::ListItem.new(nil, @RM::Paragraph.new("three")),
337
- @RM::ListItem.new(nil, @RM::Paragraph.new("four"))),
338
- @RM::Verbatim.new("verbatim\n")),
339
- @RM::ListItem.new(nil, @RM::Paragraph.new("five")),
340
- @RM::ListItem.new(nil, @RM::Paragraph.new("six"))))
349
+ list(:NUMBER,
350
+ item(nil, para("one")),
351
+ item(nil,
352
+ para("two"),
353
+ list(:BULLET,
354
+ item(nil, para("three")),
355
+ item(nil, para("four"))),
356
+ verb("verbatim\n")),
357
+ item(nil, para("five")),
358
+ item(nil, para("six"))))
341
359
 
342
360
  assert_equal expected, parse(list)
343
361
  end
@@ -355,16 +373,16 @@ class TestRDocRdBlockParser < RDoc::TestCase
355
373
 
356
374
  expected =
357
375
  doc(
358
- @RM::List.new(:NUMBER,
359
- @RM::ListItem.new(nil, @RM::Paragraph.new("one")),
360
- @RM::ListItem.new(nil,
361
- @RM::Paragraph.new("two"),
362
- @RM::List.new(:BULLET,
363
- @RM::ListItem.new(nil, @RM::Paragraph.new("three")),
364
- @RM::ListItem.new(nil, @RM::Paragraph.new("four"))),
365
- @RM::Verbatim.new("verbatim\n")),
366
- @RM::ListItem.new(nil, @RM::Paragraph.new("five")),
367
- @RM::ListItem.new(nil, @RM::Paragraph.new("six"))))
376
+ list(:NUMBER,
377
+ item(nil, para("one")),
378
+ item(nil,
379
+ para("two"),
380
+ list(:BULLET,
381
+ item(nil, para("three")),
382
+ item(nil, para("four"))),
383
+ verb("verbatim\n")),
384
+ item(nil, para("five")),
385
+ item(nil, para("six"))))
368
386
 
369
387
  assert_equal expected, parse(list)
370
388
  end
@@ -380,13 +398,13 @@ class TestRDocRdBlockParser < RDoc::TestCase
380
398
 
381
399
  expected =
382
400
  doc(
383
- @RM::List.new(:LABEL,
384
- @RM::ListItem.new(
401
+ list(:LABEL,
402
+ item(
385
403
  "<tt>Array#each {|i| ... }</tt>",
386
- @RM::Paragraph.new("yield block for each item.")),
387
- @RM::ListItem.new(
404
+ para("yield block for each item.")),
405
+ item(
388
406
  "<tt>Array#index(val)</tt>",
389
- @RM::Paragraph.new("return index of first item which equals with val. if it hasn't same item, return nil."))))
407
+ para("return index of first item which equals with val. if it hasn't same item, return nil."))))
390
408
 
391
409
  assert_equal expected, parse(list)
392
410
  end
@@ -399,8 +417,8 @@ class TestRDocRdBlockParser < RDoc::TestCase
399
417
 
400
418
  expected =
401
419
  doc(
402
- @RM::List.new(:LABEL,
403
- @RM::ListItem.new("<tt>A#b</tt>")))
420
+ list(:LABEL,
421
+ item("<tt>A#b</tt>")))
404
422
 
405
423
  assert_equal expected, parse(list)
406
424
  end
@@ -414,10 +432,10 @@ class TestRDocRdBlockParser < RDoc::TestCase
414
432
 
415
433
  expected =
416
434
  doc(
417
- @RM::List.new(:LABEL,
418
- @RM::ListItem.new(
435
+ list(:LABEL,
436
+ item(
419
437
  "<tt>A#b</tt>",
420
- @RM::Paragraph.new("one"))))
438
+ para("one"))))
421
439
 
422
440
  assert_equal expected, parse(list)
423
441
  end
@@ -432,11 +450,11 @@ two
432
450
 
433
451
  expected =
434
452
  doc(
435
- @RM::List.new(:LABEL,
436
- @RM::ListItem.new(
453
+ list(:LABEL,
454
+ item(
437
455
  "<tt>A#b</tt>",
438
- @RM::Paragraph.new("one"))),
439
- @RM::Paragraph.new("two"))
456
+ para("one"))),
457
+ para("two"))
440
458
 
441
459
  assert_equal expected, parse(list)
442
460
  end
@@ -451,21 +469,21 @@ two
451
469
 
452
470
  expected =
453
471
  doc(
454
- @RM::List.new(:LABEL,
455
- @RM::ListItem.new(
472
+ list(:LABEL,
473
+ item(
456
474
  "<tt>A#b</tt>",
457
- @RM::Paragraph.new("text"),
458
- @RM::Verbatim.new("verbatim\n"))))
475
+ para("text"),
476
+ verb("verbatim\n"))))
459
477
 
460
478
  assert_equal expected, parse(list)
461
479
  end
462
480
 
463
481
  def test_parse_verbatim
464
- assert_equal doc(@RM::Verbatim.new("verbatim\n")), parse(" verbatim")
482
+ assert_equal doc(verb("verbatim\n")), parse(" verbatim")
465
483
  end
466
484
 
467
485
  def test_parse_verbatim_blankline
468
- expected = doc(@RM::Verbatim.new("one\n", "\n", "two\n"))
486
+ expected = doc(verb("one\n", "\n", "two\n"))
469
487
 
470
488
  verbatim = <<-VERBATIM
471
489
  one
@@ -477,7 +495,7 @@ two
477
495
  end
478
496
 
479
497
  def test_parse_verbatim_indent
480
- expected = doc(@RM::Verbatim.new("one\n", " two\n"))
498
+ expected = doc(verb("one\n", " two\n"))
481
499
 
482
500
  verbatim = <<-VERBATIM
483
501
  one
@@ -488,7 +506,7 @@ two
488
506
  end
489
507
 
490
508
  def test_parse_verbatim_multi
491
- expected = doc(@RM::Verbatim.new("one\n", "two\n"))
509
+ expected = doc(verb("one\n", "two\n"))
492
510
 
493
511
  verbatim = <<-VERBATIM
494
512
  one
@@ -499,11 +517,11 @@ two
499
517
  end
500
518
 
501
519
  def test_parse_textblock
502
- assert_equal doc(@RM::Paragraph.new("text")), parse("text")
520
+ assert_equal doc(para("text")), parse("text")
503
521
  end
504
522
 
505
523
  def test_parse_textblock_multi
506
- expected = doc(@RM::Paragraph.new("one two"))
524
+ expected = doc(para("one two"))
507
525
 
508
526
  assert_equal expected, parse("one\ntwo")
509
527
  end
@@ -513,8 +531,8 @@ two
513
531
 
514
532
  doc = @block_parser.parse text.lines.to_a
515
533
 
516
- assert_equal @RM::BlankLine.new, doc.parts.shift, "=begin blankline"
517
- assert_equal @RM::BlankLine.new, doc.parts.pop, "=end blankline"
534
+ assert_equal blank_line, doc.parts.shift, "=begin blankline"
535
+ assert_equal blank_line, doc.parts.pop, "=end blankline"
518
536
 
519
537
  doc
520
538
  end