rdoc 4.0.1 → 4.1.0.preview.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.

Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +1 -3
  5. data/{DEVELOPERS.rdoc → CONTRIBUTING.rdoc} +28 -3
  6. data/ExampleMarkdown.md +37 -0
  7. data/ExampleRDoc.rdoc +208 -0
  8. data/History.rdoc +81 -0
  9. data/Manifest.txt +11 -2
  10. data/README.rdoc +5 -5
  11. data/Rakefile +34 -4
  12. data/lib/rdoc.rb +4 -3
  13. data/lib/rdoc/any_method.rb +48 -4
  14. data/lib/rdoc/class_module.rb +16 -2
  15. data/lib/rdoc/code_object.rb +85 -24
  16. data/lib/rdoc/comment.rb +0 -3
  17. data/lib/rdoc/constant.rb +9 -1
  18. data/lib/rdoc/context.rb +20 -2
  19. data/lib/rdoc/cross_reference.rb +1 -1
  20. data/lib/rdoc/extend.rb +4 -112
  21. data/lib/rdoc/generator/darkfish.rb +46 -7
  22. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +4 -4
  23. data/lib/rdoc/generator/template/darkfish/_head.rhtml +14 -8
  24. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +4 -3
  25. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +3 -3
  26. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +3 -4
  27. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +4 -3
  28. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +3 -4
  29. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +3 -3
  30. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +4 -4
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +9 -5
  32. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -3
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +12 -7
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +5 -4
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +6 -7
  37. data/lib/rdoc/generator/template/darkfish/class.rhtml +36 -41
  38. data/lib/rdoc/generator/template/darkfish/fonts.css +167 -0
  39. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  40. data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  41. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  42. data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  43. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  44. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  45. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  46. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  47. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  48. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  49. data/lib/rdoc/generator/template/darkfish/index.rhtml +11 -7
  50. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +0 -15
  51. data/lib/rdoc/generator/template/darkfish/js/search.js +12 -4
  52. data/lib/rdoc/generator/template/darkfish/page.rhtml +9 -9
  53. data/lib/rdoc/generator/template/darkfish/rdoc.css +226 -241
  54. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +5 -5
  55. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +13 -6
  56. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +17 -14
  57. data/lib/rdoc/include.rb +4 -114
  58. data/lib/rdoc/known_classes.rb +1 -0
  59. data/lib/rdoc/markdown.kpeg +126 -117
  60. data/lib/rdoc/markdown.rb +404 -389
  61. data/lib/rdoc/markdown/literals_1_8.kpeg +1 -1
  62. data/lib/rdoc/markdown/literals_1_8.rb +15 -12
  63. data/lib/rdoc/markdown/literals_1_9.kpeg +1 -1
  64. data/lib/rdoc/markdown/literals_1_9.rb +15 -12
  65. data/lib/rdoc/markup.rb +10 -13
  66. data/lib/rdoc/markup/attribute_manager.rb +3 -2
  67. data/lib/rdoc/markup/formatter.rb +3 -3
  68. data/lib/rdoc/markup/heading.rb +13 -0
  69. data/lib/rdoc/markup/parser.rb +10 -3
  70. data/lib/rdoc/markup/pre_process.rb +1 -1
  71. data/lib/rdoc/markup/to_html.rb +46 -31
  72. data/lib/rdoc/markup/to_html_crossref.rb +3 -0
  73. data/lib/rdoc/markup/to_joined_paragraph.rb +1 -1
  74. data/lib/rdoc/markup/to_markdown.rb +7 -5
  75. data/lib/rdoc/markup/verbatim.rb +1 -1
  76. data/lib/rdoc/method_attr.rb +13 -1
  77. data/lib/rdoc/mixin.rb +120 -0
  78. data/lib/rdoc/normal_class.rb +4 -0
  79. data/lib/rdoc/normal_module.rb +4 -0
  80. data/lib/rdoc/options.rb +42 -8
  81. data/lib/rdoc/parser.rb +4 -2
  82. data/lib/rdoc/parser/c.rb +13 -7
  83. data/lib/rdoc/parser/ruby.rb +683 -480
  84. data/lib/rdoc/rdoc.rb +4 -3
  85. data/lib/rdoc/ri/driver.rb +174 -103
  86. data/lib/rdoc/ri/paths.rb +6 -6
  87. data/lib/rdoc/ruby_lex.rb +125 -102
  88. data/lib/rdoc/ruby_token.rb +41 -40
  89. data/lib/rdoc/servlet.rb +16 -6
  90. data/lib/rdoc/stats.rb +61 -48
  91. data/lib/rdoc/store.rb +5 -3
  92. data/lib/rdoc/test_case.rb +39 -0
  93. data/lib/rdoc/tom_doc.rb +28 -4
  94. data/lib/rdoc/top_level.rb +2 -2
  95. data/test/test_rdoc_any_method.rb +104 -1
  96. data/test/test_rdoc_class_module.rb +9 -15
  97. data/test/test_rdoc_code_object.rb +133 -8
  98. data/test/test_rdoc_context.rb +17 -0
  99. data/test/test_rdoc_context_section.rb +0 -7
  100. data/test/test_rdoc_cross_reference.rb +4 -3
  101. data/test/test_rdoc_generator_darkfish.rb +61 -19
  102. data/test/test_rdoc_generator_json_index.rb +0 -11
  103. data/test/test_rdoc_generator_ri.rb +0 -8
  104. data/test/test_rdoc_markdown.rb +15 -12
  105. data/test/test_rdoc_markdown_test.rb +0 -7
  106. data/test/test_rdoc_markup_attribute_manager.rb +121 -0
  107. data/test/test_rdoc_markup_document.rb +0 -7
  108. data/test/test_rdoc_markup_formatter.rb +29 -3
  109. data/test/test_rdoc_markup_heading.rb +9 -0
  110. data/test/test_rdoc_markup_parser.rb +0 -7
  111. data/test/test_rdoc_markup_pre_process.rb +15 -3
  112. data/test/test_rdoc_markup_raw.rb +0 -7
  113. data/test/test_rdoc_markup_to_html.rb +50 -8
  114. data/test/test_rdoc_markup_to_html_crossref.rb +7 -0
  115. data/test/test_rdoc_markup_to_html_snippet.rb +4 -4
  116. data/test/test_rdoc_markup_to_markdown.rb +6 -0
  117. data/test/test_rdoc_method_attr.rb +8 -0
  118. data/test/test_rdoc_normal_class.rb +5 -0
  119. data/test/test_rdoc_normal_module.rb +5 -0
  120. data/test/test_rdoc_options.rb +61 -22
  121. data/test/test_rdoc_parser.rb +10 -0
  122. data/test/test_rdoc_parser_c.rb +17 -5
  123. data/test/test_rdoc_parser_changelog.rb +0 -7
  124. data/test/test_rdoc_parser_rd.rb +0 -7
  125. data/test/test_rdoc_parser_ruby.rb +305 -28
  126. data/test/test_rdoc_rd_block_parser.rb +0 -8
  127. data/test/test_rdoc_rd_inline_parser.rb +0 -1
  128. data/test/test_rdoc_rdoc.rb +27 -1
  129. data/test/test_rdoc_ri_driver.rb +19 -7
  130. data/test/test_rdoc_ruby_lex.rb +116 -9
  131. data/test/test_rdoc_rubygems_hook.rb +1 -1
  132. data/test/test_rdoc_servlet.rb +44 -6
  133. data/test/test_rdoc_stats.rb +161 -141
  134. data/test/test_rdoc_store.rb +11 -19
  135. data/test/test_rdoc_text.rb +0 -7
  136. data/test/test_rdoc_tom_doc.rb +44 -16
  137. data/test/xref_test_case.rb +2 -0
  138. metadata +28 -27
  139. metadata.gz.sig +0 -0
  140. data/test/test_attribute_manager.rb +0 -120
@@ -19,9 +19,10 @@ class TestRDocCrossReference < XrefTestCase
19
19
  def test_METHOD_REGEXP_STR
20
20
  re = /#{RDoc::CrossReference::METHOD_REGEXP_STR}/
21
21
 
22
- re =~ '==='
23
-
24
- assert_equal '===', $&
22
+ %w'=== [] []= << >>'.each do |x|
23
+ re =~ x
24
+ assert_equal x, $&
25
+ end
25
26
  end
26
27
 
27
28
  def test_resolve_C2
@@ -65,21 +65,6 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
65
65
  FileUtils.rm_rf @tmpdir
66
66
  end
67
67
 
68
- def assert_file path
69
- assert File.file?(path), "#{path} is not a file"
70
- end
71
-
72
- def refute_file path
73
- refute File.exist?(path), "#{path} exists"
74
- end
75
-
76
- def mu_pp obj
77
- s = ''
78
- s = PP.pp obj, s
79
- s = s.force_encoding Encoding.default_external if defined? Encoding
80
- s.chomp
81
- end
82
-
83
68
  def test_generate
84
69
  top_level = @store.add_file 'file.rb'
85
70
  top_level.add_class @klass.class, @klass.name
@@ -91,16 +76,20 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
91
76
  assert_file 'table_of_contents.html'
92
77
  assert_file 'js/search_index.js'
93
78
 
79
+ assert_hard_link 'rdoc.css'
80
+ assert_hard_link 'fonts.css'
81
+
82
+ assert_hard_link 'fonts/SourceCodePro-Bold.ttf'
83
+ assert_hard_link 'fonts/SourceCodePro-Regular.ttf'
84
+
94
85
  encoding = if Object.const_defined? :Encoding then
95
86
  Regexp.escape Encoding::UTF_8.name
96
87
  else
97
88
  Regexp.escape 'UTF-8'
98
89
  end
99
90
 
100
- assert_match(/<meta content="text\/html; charset=#{encoding}"/,
101
- File.read('index.html'))
102
- assert_match(/<meta content="text\/html; charset=#{encoding}"/,
103
- File.read('Object.html'))
91
+ assert_match %r%<meta charset="#{encoding}">%, File.read('index.html')
92
+ assert_match %r%<meta charset="#{encoding}">%, File.read('Object.html')
104
93
 
105
94
  refute_match(/Ignored/, File.read('index.html'))
106
95
  end
@@ -145,6 +134,36 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
145
134
  refute_file 'image.png'
146
135
  end
147
136
 
137
+ def test_install_rdoc_static_file
138
+ src = Pathname(__FILE__)
139
+ dst = File.join @tmpdir, File.basename(src)
140
+ options = {}
141
+
142
+ @g.install_rdoc_static_file src, dst, options
143
+
144
+ assert_file dst
145
+
146
+ begin
147
+ assert_hard_link dst
148
+ rescue MiniTest::Assertion
149
+ return # hard links are not supported, no further tests needed
150
+ end
151
+
152
+ @g.install_rdoc_static_file src, dst, options
153
+
154
+ assert_hard_link dst
155
+ end
156
+
157
+ def test_install_rdoc_static_file_missing
158
+ src = Pathname(__FILE__) + 'nonexistent'
159
+ dst = File.join @tmpdir, File.basename(src)
160
+ options = {}
161
+
162
+ @g.install_rdoc_static_file src, dst, options
163
+
164
+ refute_file dst
165
+ end
166
+
148
167
  def test_setup
149
168
  @g.setup
150
169
 
@@ -183,5 +202,28 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
183
202
  assert_same template, @g.send(:template_for, partial)
184
203
  end
185
204
 
205
+ ##
206
+ # Asserts that +filename+ has a link count greater than 1 if hard links to
207
+ # @tmpdir are supported.
208
+
209
+ def assert_hard_link filename
210
+ assert_file filename
211
+
212
+ src = @g.template_dir + '_head.rhtml'
213
+ dst = File.join @tmpdir, 'hardlinktest'
214
+
215
+ begin
216
+ FileUtils.ln src, dst
217
+ nlink = File.stat(dst).nlink if File.identical? src, dst
218
+ FileUtils.rm dst
219
+ return if nlink == 1
220
+ rescue SystemCallError
221
+ return
222
+ end
223
+
224
+ assert_operator File.stat(filename).nlink, :>, 1,
225
+ "#{filename} is not hard-linked"
226
+ end
227
+
186
228
  end
187
229
 
@@ -57,17 +57,6 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase
57
57
  FileUtils.rm_rf @tmpdir
58
58
  end
59
59
 
60
- def assert_file path
61
- assert File.file?(path), "#{path} is not a file"
62
- end
63
-
64
- def mu_pp obj
65
- s = ''
66
- s = PP.pp obj, s
67
- s = s.force_encoding Encoding.default_external if defined? Encoding
68
- s.chomp
69
- end
70
-
71
60
  def test_build_index
72
61
  index = @g.build_index
73
62
 
@@ -42,14 +42,6 @@ class TestRDocGeneratorRI < RDoc::TestCase
42
42
  FileUtils.rm_rf @tmpdir
43
43
  end
44
44
 
45
- def assert_file path
46
- assert File.file?(path), "#{path} is not a file"
47
- end
48
-
49
- def refute_file path
50
- refute File.exist?(path), "#{path} exists"
51
- end
52
-
53
45
  def test_generate
54
46
  @g.generate
55
47
 
@@ -1,10 +1,6 @@
1
1
  # coding: UTF-8
2
2
 
3
- require 'rubygems'
4
- require 'minitest/autorun'
5
- require 'pp'
6
-
7
- require 'rdoc'
3
+ require 'rdoc/test_case'
8
4
  require 'rdoc/markup/block_quote'
9
5
  require 'rdoc/markdown'
10
6
 
@@ -14,13 +10,8 @@ class TestRDocMarkdown < RDoc::TestCase
14
10
  @RM = RDoc::Markup
15
11
 
16
12
  @parser = RDoc::Markdown.new
17
- end
18
13
 
19
- def mu_pp obj
20
- s = ''
21
- s = PP.pp obj, s
22
- s.force_encoding Encoding.default_external if defined? Encoding
23
- s.chomp
14
+ @to_html = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil)
24
15
  end
25
16
 
26
17
  def test_class_parse
@@ -439,7 +430,19 @@ heading
439
430
  def test_parse_image
440
431
  doc = parse "image ![alt text](path/to/image.jpg)"
441
432
 
442
- expected = doc(para("image {alt text}[path/to/image.jpg]"))
433
+ expected = doc(para("image rdoc-image:path/to/image.jpg"))
434
+
435
+ assert_equal expected, doc
436
+ end
437
+
438
+ def test_parse_image_link
439
+ @parser.html = true
440
+
441
+ doc = parse "[![alt text](path/to/image.jpg)](http://example.com)"
442
+
443
+ expected =
444
+ doc(
445
+ para('{rdoc-image:path/to/image.jpg}[http://example.com]'))
443
446
 
444
447
  assert_equal expected, doc
445
448
  end
@@ -15,13 +15,6 @@ class TestRDocMarkdownTest < RDoc::TestCase
15
15
  @parser = RDoc::Markdown.new
16
16
  end
17
17
 
18
- def mu_pp obj
19
- s = ''
20
- s = PP.pp obj, s
21
- s.force_encoding Encoding.default_external if defined? Encoding
22
- s.chomp
23
- end
24
-
25
18
  def test_amps_and_angle_encoding
26
19
  input = File.read "#{MARKDOWN_TEST_PATH}/Amps and angle encoding.text"
27
20
 
@@ -26,6 +26,12 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
26
26
  @am.add_word_pair("{", "}", :WOMBAT)
27
27
  @wombat_on = @am.changed_attribute_by_name([], [:WOMBAT])
28
28
  @wombat_off = @am.changed_attribute_by_name([:WOMBAT], [])
29
+
30
+ @klass = RDoc::Markup::AttributeManager
31
+ @formatter = RDoc::Markup::Formatter.new @rdoc.options
32
+ @formatter.add_tag :BOLD, '<B>', '</B>'
33
+ @formatter.add_tag :EM, '<EM>', '</EM>'
34
+ @formatter.add_tag :TT, '<CODE>', '</CODE>'
29
35
  end
30
36
 
31
37
  def crossref(text)
@@ -44,6 +50,21 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
44
50
  #assert_equal(["cat {and} dog" ], @am.flow("cat \\{and} dog"))
45
51
  end
46
52
 
53
+ def test_add_html_tag
54
+ @am.add_html("Test", :TEST)
55
+ tags = @am.html_tags
56
+ assert_equal(6, tags.size)
57
+ assert(tags.has_key?("test"))
58
+ end
59
+
60
+ def test_add_special
61
+ @am.add_special "WikiWord", :WIKIWORD
62
+ specials = @am.special
63
+
64
+ assert_equal 1, specials.size
65
+ assert specials.assoc "WikiWord"
66
+ end
67
+
47
68
  def test_add_word_pair
48
69
  @am.add_word_pair '%', '&', 'percent and'
49
70
 
@@ -60,6 +81,20 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
60
81
  assert_equal "Word flags may not start with '<'", e.message
61
82
  end
62
83
 
84
+ def test_add_word_pair_invalid
85
+ assert_raises ArgumentError do
86
+ @am.add_word_pair("<", "<", :TEST)
87
+ end
88
+ end
89
+
90
+ def test_add_word_pair_map
91
+ @am.add_word_pair("x", "y", :TEST)
92
+
93
+ word_pair_map = @am.word_pair_map
94
+
95
+ assert_includes word_pair_map.keys.map { |r| r.source }, "(x)(\\S+)(y)"
96
+ end
97
+
63
98
  def test_add_word_pair_matching
64
99
  @am.add_word_pair '^', '^', 'caret'
65
100
 
@@ -151,6 +186,56 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
151
186
  assert_equal "\000x-y\000", str
152
187
  end
153
188
 
189
+ def test_convert_attrs_ignores_code
190
+ assert_equal 'foo <CODE>__send__</CODE> bar', output('foo <code>__send__</code> bar')
191
+ end
192
+
193
+ def test_convert_attrs_ignores_tt
194
+ assert_equal 'foo <CODE>__send__</CODE> bar', output('foo <tt>__send__</tt> bar')
195
+ end
196
+
197
+ def test_convert_attrs_preserves_double
198
+ assert_equal 'foo.__send__ :bar', output('foo.__send__ :bar')
199
+ assert_equal 'use __FILE__ to', output('use __FILE__ to')
200
+ end
201
+
202
+ def test_convert_attrs_does_not_ignore_after_tt
203
+ assert_equal 'the <CODE>IF:</CODE><EM>key</EM> directive', output('the <tt>IF:</tt>_key_ directive')
204
+ end
205
+
206
+ def test_escapes
207
+ assert_equal '<CODE>text</CODE>', output('<tt>text</tt>')
208
+ assert_equal '<tt>text</tt>', output('\\<tt>text</tt>')
209
+ assert_equal '<tt>', output('\\<tt>')
210
+ assert_equal '<CODE><tt></CODE>', output('<tt>\\<tt></tt>')
211
+ assert_equal '<CODE>\\<tt></CODE>', output('<tt>\\\\<tt></tt>')
212
+ assert_equal '<B>text</B>', output('*text*')
213
+ assert_equal '*text*', output('\\*text*')
214
+ assert_equal '\\', output('\\')
215
+ assert_equal '\\text', output('\\text')
216
+ assert_equal '\\\\text', output('\\\\text')
217
+ assert_equal 'text \\ text', output('text \\ text')
218
+
219
+ assert_equal 'and <CODE>\\s</CODE> matches space',
220
+ output('and <tt>\\s</tt> matches space')
221
+ assert_equal 'use <CODE><tt>text</CODE></tt> for code',
222
+ output('use <tt>\\<tt>text</tt></tt> for code')
223
+ assert_equal 'use <CODE><tt>text</tt></CODE> for code',
224
+ output('use <tt>\\<tt>text\\</tt></tt> for code')
225
+ assert_equal 'use <tt><tt>text</tt></tt> for code',
226
+ output('use \\<tt>\\<tt>text</tt></tt> for code')
227
+ assert_equal 'use <tt><CODE>text</CODE></tt> for code',
228
+ output('use \\<tt><tt>text</tt></tt> for code')
229
+ assert_equal 'use <CODE>+text+</CODE> for code',
230
+ output('use <tt>\\+text+</tt> for code')
231
+ assert_equal 'use <tt><CODE>text</CODE></tt> for code',
232
+ output('use \\<tt>+text+</tt> for code')
233
+ assert_equal 'illegal <tag>not</tag> changed',
234
+ output('illegal <tag>not</tag> changed')
235
+ assert_equal 'unhandled <p>tag</p> unchanged',
236
+ output('unhandled <p>tag</p> unchanged')
237
+ end
238
+
154
239
  def test_html_like_em_bold
155
240
  assert_equal ["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
156
241
  @am.flow("cat <i>and </i><b>dog</b>")
@@ -191,6 +276,38 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
191
276
  @am.flow("<tt>cat</tt> <i>and <b></i>dog</b>")
192
277
  end
193
278
 
279
+ def test_initial_html
280
+ html_tags = @am.html_tags
281
+ assert html_tags.is_a?(Hash)
282
+ assert_equal(5, html_tags.size)
283
+ end
284
+
285
+ def test_initial_word_pairs
286
+ word_pairs = @am.matching_word_pairs
287
+ assert word_pairs.is_a?(Hash)
288
+ assert_equal(3, word_pairs.size)
289
+ end
290
+
291
+ def test_mask_protected_sequence
292
+ def @am.str() @str end
293
+ def @am.str=(str) @str = str end
294
+
295
+ @am.str = '<code>foo</code>'
296
+ @am.mask_protected_sequences
297
+
298
+ assert_equal "<code>foo</code>", @am.str
299
+
300
+ @am.str = '<code>foo\\</code>'
301
+ @am.mask_protected_sequences
302
+
303
+ assert_equal "<code>foo<\x04/code>", @am.str, 'escaped close'
304
+
305
+ @am.str = '<code>foo\\\\</code>'
306
+ @am.mask_protected_sequences
307
+
308
+ assert_equal "<code>foo\\</code>", @am.str, 'escaped backslash'
309
+ end
310
+
194
311
  def test_protect
195
312
  assert_equal(['cat \\ dog'],
196
313
  @am.flow('cat \\ dog'))
@@ -233,5 +350,9 @@ class TestRDocMarkupAttributeManager < RDoc::TestCase
233
350
  @am.flow('<tt>"\n"</tt>')
234
351
  end
235
352
 
353
+ def output str
354
+ @formatter.convert_flow @am.flow str
355
+ end
356
+
236
357
  end
237
358
 
@@ -8,13 +8,6 @@ class TestRDocMarkupDocument < RDoc::TestCase
8
8
  @d = @RM::Document.new
9
9
  end
10
10
 
11
- def mu_pp obj
12
- s = ''
13
- s = PP.pp obj, s
14
- s.force_encoding Encoding.default_external if defined? Encoding
15
- s.chomp
16
- end
17
-
18
11
  def test_append
19
12
  @d << @RM::Paragraph.new('hi')
20
13
 
@@ -71,20 +71,46 @@ class TestRDocMarkupFormatter < RDoc::TestCase
71
71
  @to.add_special_RDOCLINK
72
72
 
73
73
  assert_includes special_names, 'RDOCLINK'
74
+
75
+ def @to.handle_special_RDOCLINK special
76
+ "<#{special.text}>"
77
+ end
78
+
79
+ document = doc(para('{foo}[rdoc-label:bar].'))
80
+
81
+ formatted = document.accept @to
82
+
83
+ assert_equal '{foo}[<rdoc-label:bar>].', formatted
74
84
  end
75
85
 
76
86
  def test_add_special_TIDYLINK
77
87
  @to.add_special_TIDYLINK
78
88
 
79
89
  assert_includes special_names, 'TIDYLINK'
90
+
91
+ def @to.handle_special_TIDYLINK special
92
+ "<#{special.text}>"
93
+ end
94
+
95
+ document = doc(para('foo[rdoc-label:bar].'))
96
+
97
+ formatted = document.accept @to
98
+
99
+ assert_equal '<foo[rdoc-label:bar]>.', formatted
100
+
101
+ document = doc(para('{foo}[rdoc-label:bar].'))
102
+
103
+ formatted = document.accept @to
104
+
105
+ assert_equal '<{foo}[rdoc-label:bar]>.', formatted
80
106
  end
81
107
 
82
108
  def test_parse_url
83
109
  scheme, url, id = @to.parse_url 'example/foo'
84
110
 
85
- assert_equal 'http', scheme
86
- assert_equal 'http://example/foo', url
87
- assert_equal nil, id
111
+ assert_equal 'http', scheme
112
+ assert_equal 'example/foo', url
113
+ assert_equal nil, id
88
114
  end
89
115
 
90
116
  def test_parse_url_anchor
@@ -12,6 +12,15 @@ class TestRDocMarkupHeading < RDoc::TestCase
12
12
  assert_equal 'label-Hello+Friend%21', @h.aref
13
13
  end
14
14
 
15
+ def test_label
16
+ assert_equal 'label-Hello+Friend%21', @h.label
17
+ assert_equal 'label-Hello+Friend%21', @h.label(nil)
18
+
19
+ context = RDoc::NormalClass.new 'Foo'
20
+
21
+ assert_equal 'class-Foo-label-Hello+Friend%21', @h.label(context)
22
+ end
23
+
15
24
  def test_plain_html
16
25
  assert_equal 'Hello <strong>Friend</strong>!', @h.plain_html
17
26
  end