rdoc 3.9.5 → 3.10.pre.1

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 (183) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +6 -3
  3. data/History.txt +63 -13
  4. data/LICENSE.rdoc +57 -0
  5. data/Manifest.txt +60 -6
  6. data/Rakefile +24 -12
  7. data/TODO.rdoc +30 -0
  8. data/bin/rdoc +0 -2
  9. data/lib/rdoc.rb +55 -2
  10. data/lib/rdoc/alias.rb +0 -2
  11. data/lib/rdoc/anon_class.rb +0 -2
  12. data/lib/rdoc/any_method.rb +0 -3
  13. data/lib/rdoc/attr.rb +0 -2
  14. data/lib/rdoc/class_module.rb +40 -7
  15. data/lib/rdoc/code_object.rb +1 -3
  16. data/lib/rdoc/code_objects.rb +3 -21
  17. data/lib/rdoc/comment.rb +225 -0
  18. data/lib/rdoc/constant.rb +0 -2
  19. data/lib/rdoc/context.rb +37 -120
  20. data/lib/rdoc/context/section.rb +114 -0
  21. data/lib/rdoc/cross_reference.rb +16 -7
  22. data/lib/rdoc/encoding.rb +0 -2
  23. data/lib/rdoc/gauntlet.rb +1 -1
  24. data/lib/rdoc/generator.rb +7 -2
  25. data/lib/rdoc/generator/darkfish.rb +126 -20
  26. data/lib/rdoc/generator/json_index.rb +240 -0
  27. data/lib/rdoc/generator/markup.rb +17 -54
  28. data/lib/rdoc/generator/ri.rb +0 -3
  29. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  30. data/lib/rdoc/generator/template/darkfish/_head.rhtml +16 -0
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +18 -0
  32. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +8 -0
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +16 -0
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +7 -0
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +10 -0
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +10 -0
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +10 -0
  41. data/lib/rdoc/generator/template/darkfish/class.rhtml +161 -0
  42. data/lib/rdoc/generator/template/darkfish/fileinfo.rhtml +32 -0
  43. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  44. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  45. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  46. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  47. data/lib/rdoc/generator/template/darkfish/index.rhtml +16 -61
  48. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +99 -64
  49. data/lib/rdoc/generator/template/darkfish/js/jquery.js +15 -29
  50. data/lib/rdoc/generator/template/darkfish/js/search.js +94 -0
  51. data/lib/rdoc/generator/template/darkfish/page.rhtml +16 -0
  52. data/lib/rdoc/generator/template/darkfish/rdoc.css +126 -286
  53. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +50 -0
  54. data/lib/rdoc/generator/template/json_index/js/navigation.js +142 -0
  55. data/lib/rdoc/generator/template/json_index/js/searcher.js +228 -0
  56. data/lib/rdoc/ghost_method.rb +0 -2
  57. data/lib/rdoc/include.rb +0 -2
  58. data/lib/rdoc/markup.rb +204 -43
  59. data/lib/rdoc/markup/attr_changer.rb +25 -0
  60. data/lib/rdoc/markup/attr_span.rb +29 -0
  61. data/lib/rdoc/markup/attribute.rb +51 -0
  62. data/lib/rdoc/markup/document.rb +22 -1
  63. data/lib/rdoc/markup/formatter.rb +4 -11
  64. data/lib/rdoc/markup/formatter_test_case.rb +1 -2
  65. data/lib/rdoc/markup/heading.rb +44 -0
  66. data/lib/rdoc/markup/include.rb +42 -0
  67. data/lib/rdoc/markup/inline.rb +1 -144
  68. data/lib/rdoc/markup/list.rb +2 -1
  69. data/lib/rdoc/markup/parser.rb +6 -16
  70. data/lib/rdoc/markup/pre_process.rb +64 -10
  71. data/lib/rdoc/markup/raw.rb +1 -1
  72. data/lib/rdoc/markup/special.rb +40 -0
  73. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -2
  74. data/lib/rdoc/markup/to_ansi.rb +0 -2
  75. data/lib/rdoc/markup/to_bs.rb +0 -2
  76. data/lib/rdoc/markup/to_html.rb +102 -34
  77. data/lib/rdoc/markup/to_html_crossref.rb +36 -5
  78. data/lib/rdoc/markup/to_html_snippet.rb +270 -0
  79. data/lib/rdoc/markup/to_label.rb +55 -0
  80. data/lib/rdoc/markup/to_rdoc.rb +0 -3
  81. data/lib/rdoc/markup/to_table_of_contents.rb +62 -0
  82. data/lib/rdoc/markup/to_test.rb +0 -3
  83. data/lib/rdoc/markup/to_tt_only.rb +0 -3
  84. data/lib/rdoc/markup/verbatim.rb +18 -0
  85. data/lib/rdoc/meta_method.rb +0 -2
  86. data/lib/rdoc/method_attr.rb +17 -1
  87. data/lib/rdoc/normal_class.rb +0 -2
  88. data/lib/rdoc/normal_module.rb +0 -2
  89. data/lib/rdoc/options.rb +18 -3
  90. data/lib/rdoc/parser.rb +74 -42
  91. data/lib/rdoc/parser/c.rb +79 -118
  92. data/lib/rdoc/parser/rd.rb +22 -0
  93. data/lib/rdoc/parser/ruby.rb +86 -54
  94. data/lib/rdoc/parser/simple.rb +21 -9
  95. data/lib/rdoc/parser/text.rb +11 -0
  96. data/lib/rdoc/rd.rb +95 -0
  97. data/lib/rdoc/rd/block_parser.ry +638 -0
  98. data/lib/rdoc/rd/inline.rb +71 -0
  99. data/lib/rdoc/rd/inline_parser.ry +575 -0
  100. data/lib/rdoc/rdoc.rb +8 -23
  101. data/lib/rdoc/require.rb +0 -2
  102. data/lib/rdoc/ri.rb +4 -2
  103. data/lib/rdoc/ri/driver.rb +2 -6
  104. data/lib/rdoc/ri/store.rb +0 -1
  105. data/lib/rdoc/ruby_lex.rb +43 -20
  106. data/lib/rdoc/ruby_token.rb +44 -2
  107. data/lib/rdoc/single_class.rb +0 -2
  108. data/lib/rdoc/stats.rb +0 -5
  109. data/lib/rdoc/task.rb +2 -6
  110. data/lib/rdoc/test_case.rb +59 -0
  111. data/lib/rdoc/text.rb +42 -30
  112. data/lib/rdoc/token_stream.rb +45 -0
  113. data/lib/rdoc/tom_doc.rb +232 -0
  114. data/lib/rdoc/top_level.rb +36 -4
  115. data/test/test_attribute_manager.rb +26 -29
  116. data/test/test_rdoc_any_method.rb +2 -26
  117. data/test/test_rdoc_attr.rb +4 -4
  118. data/test/test_rdoc_class_module.rb +95 -12
  119. data/test/test_rdoc_code_object.rb +10 -3
  120. data/test/test_rdoc_comment.rb +504 -0
  121. data/test/test_rdoc_context.rb +60 -11
  122. data/test/test_rdoc_context_section.rb +16 -17
  123. data/test/test_rdoc_cross_reference.rb +17 -2
  124. data/test/test_rdoc_encoding.rb +4 -7
  125. data/test/test_rdoc_generator_darkfish.rb +12 -11
  126. data/test/test_rdoc_generator_json_index.rb +255 -0
  127. data/test/test_rdoc_generator_markup.rb +56 -0
  128. data/test/test_rdoc_generator_ri.rb +8 -11
  129. data/test/test_rdoc_markup.rb +9 -5
  130. data/test/test_rdoc_markup_attribute_manager.rb +5 -8
  131. data/test/test_rdoc_markup_document.rb +34 -6
  132. data/test/test_rdoc_markup_formatter.rb +11 -13
  133. data/test/test_rdoc_markup_heading.rb +20 -0
  134. data/test/test_rdoc_markup_include.rb +19 -0
  135. data/test/test_rdoc_markup_indented_paragraph.rb +4 -5
  136. data/test/test_rdoc_markup_paragraph.rb +2 -5
  137. data/test/test_rdoc_markup_parser.rb +87 -7
  138. data/test/test_rdoc_markup_pre_process.rb +60 -9
  139. data/test/test_rdoc_markup_raw.rb +4 -6
  140. data/test/test_rdoc_markup_to_ansi.rb +1 -4
  141. data/test/test_rdoc_markup_to_bs.rb +1 -4
  142. data/test/test_rdoc_markup_to_html.rb +170 -31
  143. data/test/test_rdoc_markup_to_html_crossref.rb +89 -11
  144. data/test/test_rdoc_markup_to_html_snippet.rb +668 -0
  145. data/test/test_rdoc_markup_to_label.rb +50 -0
  146. data/test/test_rdoc_markup_to_rdoc.rb +1 -4
  147. data/test/test_rdoc_markup_to_table_of_contents.rb +90 -0
  148. data/test/test_rdoc_markup_to_tt_only.rb +1 -4
  149. data/test/test_rdoc_markup_verbatim.rb +16 -0
  150. data/test/test_rdoc_method_attr.rb +16 -1
  151. data/test/test_rdoc_options.rb +17 -7
  152. data/test/test_rdoc_parser.rb +75 -6
  153. data/test/test_rdoc_parser_c.rb +56 -104
  154. data/test/test_rdoc_parser_rd.rb +52 -0
  155. data/test/test_rdoc_parser_ruby.rb +264 -323
  156. data/test/test_rdoc_parser_simple.rb +33 -17
  157. data/test/test_rdoc_rd.rb +30 -0
  158. data/test/test_rdoc_rd_block_parser.rb +527 -0
  159. data/test/test_rdoc_rd_inline.rb +63 -0
  160. data/test/test_rdoc_rd_inline_parser.rb +173 -0
  161. data/test/test_rdoc_rdoc.rb +7 -9
  162. data/test/test_rdoc_ri_driver.rb +10 -15
  163. data/test/test_rdoc_ri_paths.rb +6 -6
  164. data/test/test_rdoc_ri_store.rb +6 -13
  165. data/test/test_rdoc_ruby_lex.rb +53 -5
  166. data/test/test_rdoc_rubygems_hook.rb +2 -1
  167. data/test/test_rdoc_stats.rb +83 -103
  168. data/test/test_rdoc_task.rb +5 -4
  169. data/test/test_rdoc_text.rb +156 -11
  170. data/test/test_rdoc_token_stream.rb +42 -0
  171. data/test/test_rdoc_tom_doc.rb +458 -0
  172. data/test/test_rdoc_top_level.rb +49 -2
  173. data/test/xref_test_case.rb +4 -8
  174. metadata +217 -111
  175. metadata.gz.sig +0 -0
  176. checksums.yaml +0 -7
  177. checksums.yaml.gz.sig +0 -0
  178. data/CVE-2013-0256.rdoc +0 -49
  179. data/LICENSE.txt +0 -57
  180. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -321
  181. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
  182. data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
  183. data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
@@ -0,0 +1,50 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocMarkupToLabel < RDoc::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ @to = RDoc::Markup::ToLabel.new
9
+ end
10
+
11
+ def test_convert_bold
12
+ assert_equal 'bold', @to.convert('<b>bold</b>')
13
+ assert_equal 'bold', @to.convert('*bold*')
14
+ end
15
+
16
+ def test_convert_crossref
17
+ assert_equal 'SomeClass', @to.convert('SomeClass')
18
+ assert_equal 'SomeClass', @to.convert('\\SomeClass')
19
+
20
+ assert_equal 'some_method', @to.convert('some_method')
21
+ assert_equal 'some_method', @to.convert('\\some_method')
22
+
23
+ assert_equal '%23some_method', @to.convert('#some_method')
24
+ assert_equal '%23some_method', @to.convert('\\#some_method')
25
+ end
26
+
27
+ def test_convert_em
28
+ assert_equal 'em', @to.convert('<em>em</em>')
29
+ assert_equal 'em', @to.convert('*em*')
30
+ end
31
+
32
+ def test_convert_em_dash # for HTML conversion
33
+ assert_equal '--', @to.convert('--')
34
+ end
35
+
36
+ def test_convert_escape
37
+ assert_equal 'a+%3E+b', @to.convert('a > b')
38
+ end
39
+
40
+ def test_convert_tidylink
41
+ assert_equal 'text', @to.convert('{text}[stuff]')
42
+ assert_equal 'text', @to.convert('text[stuff]')
43
+ end
44
+
45
+ def test_convert_tt
46
+ assert_equal 'tt', @to.convert('<tt>tt</tt>')
47
+ end
48
+
49
+ end
50
+
@@ -1,7 +1,4 @@
1
- require 'rubygems'
2
- require 'rdoc/markup/text_formatter_test_case'
3
- require 'rdoc/markup/to_rdoc'
4
- require 'minitest/autorun'
1
+ require 'rdoc/test_case'
5
2
 
6
3
  class TestRDocMarkupToRDoc < RDoc::Markup::TextFormatterTestCase
7
4
 
@@ -0,0 +1,90 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocMarkupToTableOfContents < RDoc::Markup::FormatterTestCase
4
+
5
+ add_visitor_tests
6
+
7
+ def setup
8
+ super
9
+
10
+ @to = RDoc::Markup::ToTableOfContents.new
11
+ end
12
+
13
+ def end_accepting
14
+ assert_equal %w[hi], @to.res
15
+ end
16
+
17
+ def empty
18
+ assert_empty @to.res
19
+ end
20
+
21
+ def accept_heading
22
+ assert_equal [@RM::Heading.new(5, 'Hello')], @to.res
23
+ end
24
+
25
+ def accept_heading_1
26
+ assert_equal [@RM::Heading.new(1, 'Hello')], @to.res
27
+ end
28
+
29
+ def accept_heading_2
30
+ assert_equal [@RM::Heading.new(2, 'Hello')], @to.res
31
+ end
32
+
33
+ def accept_heading_3
34
+ assert_equal [@RM::Heading.new(3, 'Hello')], @to.res
35
+ end
36
+
37
+ def accept_heading_4
38
+ assert_equal [@RM::Heading.new(4, 'Hello')], @to.res
39
+ end
40
+
41
+ def accept_heading_b
42
+ assert_equal [@RM::Heading.new(1, '*Hello*')], @to.res
43
+ end
44
+
45
+ def accept_heading_suppressed_crossref
46
+ assert_equal [@RM::Heading.new(1, '\\Hello')], @to.res
47
+ end
48
+
49
+ alias accept_blank_line empty
50
+ alias accept_document empty
51
+ alias accept_list_end_bullet empty
52
+ alias accept_list_end_label empty
53
+ alias accept_list_end_lalpha empty
54
+ alias accept_list_end_note empty
55
+ alias accept_list_end_number empty
56
+ alias accept_list_end_ualpha empty
57
+ alias accept_list_item_end_bullet empty
58
+ alias accept_list_item_end_label empty
59
+ alias accept_list_item_end_lalpha empty
60
+ alias accept_list_item_end_note empty
61
+ alias accept_list_item_end_number empty
62
+ alias accept_list_item_end_ualpha empty
63
+ alias accept_list_item_start_bullet empty
64
+ alias accept_list_item_start_label empty
65
+ alias accept_list_item_start_lalpha empty
66
+ alias accept_list_item_start_note empty
67
+ alias accept_list_item_start_note_2 empty
68
+ alias accept_list_item_start_number empty
69
+ alias accept_list_item_start_ualpha empty
70
+ alias accept_list_start_bullet empty
71
+ alias accept_list_start_label empty
72
+ alias accept_list_start_lalpha empty
73
+ alias accept_list_start_note empty
74
+ alias accept_list_start_number empty
75
+ alias accept_list_start_ualpha empty
76
+ alias accept_paragraph empty
77
+ alias accept_paragraph_b empty
78
+ alias accept_paragraph_i empty
79
+ alias accept_paragraph_plus empty
80
+ alias accept_paragraph_star empty
81
+ alias accept_paragraph_underscore empty
82
+ alias accept_raw empty
83
+ alias accept_rule empty
84
+ alias accept_verbatim empty
85
+ alias list_nested empty
86
+ alias list_verbatim empty
87
+ alias start_accepting empty
88
+
89
+ end
90
+
@@ -1,7 +1,4 @@
1
- require 'rubygems'
2
- require 'rdoc/markup/formatter_test_case'
3
- require 'rdoc/markup/to_tt_only'
4
- require 'minitest/autorun'
1
+ require 'rdoc/test_case'
5
2
 
6
3
  class TestRDocMarkupToTtOnly < RDoc::Markup::FormatterTestCase
7
4
 
@@ -0,0 +1,16 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocMarkupVerbatim < RDoc::TestCase
4
+
5
+ def test_ruby_eh
6
+ verbatim = RDoc::Markup::Verbatim.new
7
+
8
+ refute verbatim.ruby?
9
+
10
+ verbatim.format = :ruby
11
+
12
+ assert verbatim.ruby?
13
+ end
14
+
15
+ end
16
+
@@ -111,12 +111,27 @@ class TestRDocMethodAttr < XrefTestCase
111
111
  assert_nil @m1_m.find_method_or_attribute 'm'
112
112
  end
113
113
 
114
+ def test_search_record
115
+ @c1_m.comment = 'This is a comment.'
116
+
117
+ expected = [
118
+ 'm',
119
+ 'C1#m',
120
+ 'm',
121
+ 'C1',
122
+ 'C1.html#method-i-m',
123
+ '(foo)',
124
+ "<p>This is a comment.\n",
125
+ ]
126
+
127
+ assert_equal expected, @c1_m.search_record
128
+ end
129
+
114
130
  def test_to_s
115
131
  assert_equal 'RDoc::AnyMethod: C1#m', @c1_m.to_s
116
132
  assert_equal 'RDoc::AnyMethod: C2#b', @c2_b.to_s
117
133
  assert_equal 'RDoc::AnyMethod: C1::m', @c1__m.to_s
118
134
  end
119
135
 
120
-
121
136
  end
122
137
 
@@ -1,18 +1,17 @@
1
- require 'rubygems'
2
- require 'minitest/autorun'
3
- require 'rdoc/options'
1
+ require 'rdoc/test_case'
4
2
 
5
- require 'fileutils'
6
- require 'tmpdir'
7
-
8
- class TestRDocOptions < MiniTest::Unit::TestCase
3
+ class TestRDocOptions < RDoc::TestCase
9
4
 
10
5
  def setup
6
+ super
7
+
11
8
  @options = RDoc::Options.new
12
9
  @generators = RDoc::RDoc::GENERATORS.dup
13
10
  end
14
11
 
15
12
  def teardown
13
+ super
14
+
16
15
  RDoc::RDoc::GENERATORS.replace @generators
17
16
  end
18
17
 
@@ -286,6 +285,17 @@ file 'unreadable' not readable
286
285
  assert_equal 'MAIN', @options.main_page
287
286
  end
288
287
 
288
+ def test_parse_markup
289
+ out, err = capture_io do
290
+ @options.parse %w[--markup tomdoc]
291
+ end
292
+
293
+ assert_empty out
294
+ assert_empty err
295
+
296
+ assert_equal 'tomdoc', @options.markup
297
+ end
298
+
289
299
  def test_parse_template
290
300
  out, err = capture_io do
291
301
  @options.parse %w[--template darkfish]
@@ -1,14 +1,16 @@
1
- require 'rubygems'
2
- require 'minitest/autorun'
3
- require 'rdoc/parser'
4
- require 'rdoc/parser/ruby'
5
- require 'tmpdir'
1
+ require 'rdoc/test_case'
6
2
 
7
- class TestRDocParser < MiniTest::Unit::TestCase
3
+ class TestRDocParser < RDoc::TestCase
8
4
 
9
5
  def setup
6
+ super
7
+
10
8
  @RP = RDoc::Parser
11
9
  @binary_dat = File.expand_path '../binary.dat', __FILE__
10
+
11
+ @fn = 'file.rb'
12
+ @top_level = RDoc::TopLevel.new @fn
13
+ @options = RDoc::Options.new
12
14
  end
13
15
 
14
16
  def test_class_binary_eh_marshal
@@ -79,5 +81,72 @@ class TestRDocParser < MiniTest::Unit::TestCase
79
81
  assert_nil @RP.for(nil, @binary_dat, nil, nil, nil)
80
82
  end
81
83
 
84
+ def test_class_for_format
85
+ content = <<-CONTENT
86
+ # coding: utf-8 format: rd
87
+ CONTENT
88
+
89
+ parser = @RP.for @top_level, __FILE__, content, @options, nil
90
+
91
+ assert_kind_of @RP::RD, parser
92
+ end
93
+
94
+ def test_class_use_format
95
+ content = <<-CONTENT
96
+ # coding: utf-8 format: rd
97
+ CONTENT
98
+
99
+ parser = @RP.use_format content
100
+
101
+ assert_equal @RP::RD, parser
102
+ end
103
+
104
+ def test_class_use_format_modeline
105
+ content = <<-CONTENT
106
+ # -*- coding: utf-8 -*-
107
+ # format: rd
108
+ CONTENT
109
+
110
+ parser = @RP.use_format content
111
+
112
+ assert_equal @RP::RD, parser
113
+ end
114
+
115
+ def test_class_use_format_modeline_shebang
116
+ content = <<-CONTENT
117
+ #!/bin/sh
118
+ /* -*- coding: utf-8 -*-
119
+ * format: rd
120
+ */
121
+ CONTENT
122
+
123
+ parser = @RP.use_format content
124
+
125
+ assert_equal @RP::RD, parser
126
+ end
127
+
128
+ def test_class_use_format_shebang
129
+ content = <<-CONTENT
130
+ #!/usr/bin/env ruby
131
+ # coding: utf-8 format: rd
132
+ CONTENT
133
+
134
+ parser = @RP.use_format content
135
+
136
+ assert_equal @RP::RD, parser
137
+ end
138
+
139
+ def test_class_use_format_none
140
+ parser = @RP.use_format ''
141
+
142
+ assert_nil parser
143
+ end
144
+
145
+ def test_initialize
146
+ @RP.new @top_level, @fn, '', @options, nil
147
+
148
+ assert_equal @RP, @top_level.parser
149
+ end
150
+
82
151
  end
83
152
 
@@ -1,9 +1,4 @@
1
- require 'stringio'
2
- require 'tempfile'
3
- require 'rubygems'
4
- require 'minitest/autorun'
5
- require 'rdoc/options'
6
- require 'rdoc/parser/c'
1
+ require 'rdoc/test_case'
7
2
 
8
3
  =begin
9
4
  TODO: test call-seq parsing
@@ -51,9 +46,11 @@ class RDoc::Parser::C
51
46
  public :do_classes, :do_constants
52
47
  end
53
48
 
54
- class TestRDocParserC < MiniTest::Unit::TestCase
49
+ class TestRDocParserC < RDoc::TestCase
55
50
 
56
51
  def setup
52
+ super
53
+
57
54
  @tempfile = Tempfile.new self.class.name
58
55
  filename = @tempfile.path
59
56
 
@@ -61,12 +58,11 @@ class TestRDocParserC < MiniTest::Unit::TestCase
61
58
  @fn = filename
62
59
  @options = RDoc::Options.new
63
60
  @stats = RDoc::Stats.new 0
64
-
65
- RDoc::Parser::C.reset
66
- RDoc::TopLevel.reset
67
61
  end
68
62
 
69
63
  def teardown
64
+ super
65
+
70
66
  @tempfile.close
71
67
  end
72
68
 
@@ -116,18 +112,18 @@ void Init_Blah(void) {
116
112
  accessor = attrs.shift
117
113
  assert_equal 'accessor', accessor.name
118
114
  assert_equal 'RW', accessor.rw
119
- assert_equal 'This is an accessor', accessor.comment
115
+ assert_equal 'This is an accessor', accessor.comment.text
120
116
  assert_equal @top_level, accessor.file
121
117
 
122
118
  reader = attrs.shift
123
119
  assert_equal 'reader', reader.name
124
120
  assert_equal 'R', reader.rw
125
- assert_equal 'This is a reader', reader.comment
121
+ assert_equal 'This is a reader', reader.comment.text
126
122
 
127
123
  writer = attrs.shift
128
124
  assert_equal 'writer', writer.name
129
125
  assert_equal 'W', writer.rw
130
- assert_equal 'This is a writer', writer.comment
126
+ assert_equal 'This is a writer', writer.comment.text
131
127
  end
132
128
 
133
129
  def test_do_attr_rb_define_attr
@@ -150,7 +146,7 @@ void Init_Blah(void) {
150
146
  accessor = attrs.shift
151
147
  assert_equal 'accessor', accessor.name
152
148
  assert_equal 'RW', accessor.rw
153
- assert_equal 'This is an accessor', accessor.comment
149
+ assert_equal 'This is an accessor', accessor.comment.text
154
150
  assert_equal @top_level, accessor.file
155
151
  end
156
152
 
@@ -211,7 +207,7 @@ void Init_Blah(void) {
211
207
  assert_equal 'bleh', methods.last.name
212
208
  assert methods.last.singleton
213
209
  assert_equal 'blah', methods.last.is_alias_for.name
214
- assert_equal 'This should show up as an alias', methods.last.comment
210
+ assert_equal 'This should show up as an alias', methods.last.comment.text
215
211
  end
216
212
 
217
213
  def test_do_classes_boot_class
@@ -223,7 +219,7 @@ VALUE cFoo = boot_defclass("Foo", rb_cObject);
223
219
  EOF
224
220
 
225
221
  klass = util_get_class content, 'cFoo'
226
- assert_equal "this is the Foo boot class", klass.comment
222
+ assert_equal "this is the Foo boot class", klass.comment.text
227
223
  assert_equal 'Object', klass.superclass
228
224
  end
229
225
 
@@ -236,7 +232,7 @@ VALUE cFoo = boot_defclass("Foo", 0);
236
232
  EOF
237
233
 
238
234
  klass = util_get_class content, 'cFoo'
239
- assert_equal "this is the Foo boot class", klass.comment
235
+ assert_equal "this is the Foo boot class", klass.comment.text
240
236
  assert_equal nil, klass.superclass
241
237
  end
242
238
 
@@ -264,7 +260,7 @@ VALUE cFoo = rb_define_class("Foo", rb_cObject);
264
260
  EOF
265
261
 
266
262
  klass = util_get_class content, 'cFoo'
267
- assert_equal "this is the Foo class", klass.comment
263
+ assert_equal "this is the Foo class", klass.comment.text
268
264
  end
269
265
 
270
266
  def test_do_classes_class_under
@@ -277,7 +273,7 @@ VALUE cFoo = rb_define_class_under(rb_mKernel, "Foo", rb_cObject);
277
273
 
278
274
  klass = util_get_class content, 'cFoo'
279
275
  assert_equal 'Kernel::Foo', klass.full_name
280
- assert_equal "this is the Foo class under Kernel", klass.comment
276
+ assert_equal "this is the Foo class under Kernel", klass.comment.text
281
277
  end
282
278
 
283
279
  def test_do_classes_class_under_rb_path2class
@@ -292,7 +288,7 @@ VALUE cFoo = rb_define_class_under(rb_mKernel, "Foo", rb_path2class("A::B"));
292
288
 
293
289
  assert_equal 'Kernel::Foo', klass.full_name
294
290
  assert_equal 'A::B', klass.superclass
295
- assert_equal 'this is Kernel::Foo < A::B', klass.comment
291
+ assert_equal 'this is Kernel::Foo < A::B', klass.comment.text
296
292
  end
297
293
 
298
294
  def test_do_classes_singleton
@@ -315,7 +311,7 @@ VALUE mFoo = rb_define_module("Foo");
315
311
  EOF
316
312
 
317
313
  klass = util_get_class content, 'mFoo'
318
- assert_equal "this is the Foo module", klass.comment
314
+ assert_equal "this is the Foo module", klass.comment.text
319
315
  end
320
316
 
321
317
  def test_do_classes_module_under
@@ -327,7 +323,7 @@ VALUE mFoo = rb_define_module_under(rb_mKernel, "Foo");
327
323
  EOF
328
324
 
329
325
  klass = util_get_class content, 'mFoo'
330
- assert_equal "this is the Foo module under Kernel", klass.comment
326
+ assert_equal "this is the Foo module under Kernel", klass.comment.text
331
327
  end
332
328
 
333
329
  def test_do_constants
@@ -393,7 +389,7 @@ void Init_foo(){
393
389
 
394
390
  assert_equal @top_level, constants.first.file
395
391
 
396
- constants = constants.map { |c| [c.name, c.value, c.comment] }
392
+ constants = constants.map { |c| [c.name, c.value, c.comment.text] }
397
393
 
398
394
  assert_equal ['PERFECT', '300', 'The highest possible score in bowling '],
399
395
  constants.shift
@@ -455,7 +451,7 @@ void Init_curses(){
455
451
 
456
452
  assert_equal 'COLOR_BLACK', constants.first.name
457
453
  assert_equal 'UINT2NUM(COLOR_BLACK)', constants.first.value
458
- assert_equal 'Value of the color black', constants.first.comment
454
+ assert_equal 'Value of the color black', constants.first.comment.text
459
455
  end
460
456
 
461
457
  def test_do_includes
@@ -472,7 +468,7 @@ Init_foo() {
472
468
 
473
469
  incl = klass.includes.first
474
470
  assert_equal 'Inc', incl.name
475
- assert_equal '', incl.comment
471
+ assert_equal '', incl.comment.text
476
472
  assert_equal @top_level, incl.file
477
473
  end
478
474
 
@@ -568,7 +564,7 @@ void Init_Blah(void) {
568
564
 
569
565
  comment = parser.find_alias_comment 'C', '[]', 'index'
570
566
 
571
- assert_equal '', comment
567
+ assert_equal '', comment.text
572
568
 
573
569
  parser = util_parser <<-C
574
570
  /*
@@ -580,7 +576,7 @@ rb_define_alias(C, "[]", "index");
580
576
 
581
577
  comment = parser.find_alias_comment 'C', '[]', 'index'
582
578
 
583
- assert_equal "/*\n * comment\n */\n\n", comment
579
+ assert_equal "/*\n * comment\n */\n\n", comment.text
584
580
  end
585
581
 
586
582
  def test_find_class_comment_include
@@ -600,7 +596,7 @@ Init_Foo(void) {
600
596
 
601
597
  klass = util_get_class content, 'foo'
602
598
 
603
- assert_equal "a comment for class Foo\n\ntest file", klass.comment
599
+ assert_equal "a comment for class Foo\n\ntest file\n", klass.comment.text
604
600
  end
605
601
 
606
602
  def test_find_class_comment_init
@@ -616,7 +612,7 @@ Init_Foo(void) {
616
612
 
617
613
  klass = util_get_class content, 'foo'
618
614
 
619
- assert_equal "a comment for class Foo", klass.comment
615
+ assert_equal "a comment for class Foo", klass.comment.text
620
616
  end
621
617
 
622
618
  def test_find_class_comment_define_class
@@ -629,7 +625,7 @@ VALUE foo = rb_define_class("Foo", rb_cObject);
629
625
 
630
626
  klass = util_get_class content, 'foo'
631
627
 
632
- assert_equal "a comment for class Foo", klass.comment
628
+ assert_equal "a comment for class Foo", klass.comment.text
633
629
  end
634
630
 
635
631
  def test_find_class_comment_define_class_Init_Foo
@@ -648,7 +644,7 @@ Init_Foo(void) {
648
644
 
649
645
  klass = util_get_class content, 'foo'
650
646
 
651
- assert_equal "a comment for class Foo on Init", klass.comment
647
+ assert_equal "a comment for class Foo on Init", klass.comment.text
652
648
  end
653
649
 
654
650
  def test_find_class_comment_define_class_Init_Foo_no_void
@@ -667,7 +663,7 @@ Init_Foo() {
667
663
 
668
664
  klass = util_get_class content, 'foo'
669
665
 
670
- assert_equal "a comment for class Foo on Init", klass.comment
666
+ assert_equal "a comment for class Foo on Init", klass.comment.text
671
667
  end
672
668
 
673
669
  def test_find_class_comment_define_class_bogus_comment
@@ -687,7 +683,7 @@ Init_Foo(void) {
687
683
 
688
684
  klass = util_get_class content, 'foo'
689
685
 
690
- assert_equal '', klass.comment
686
+ assert_equal '', klass.comment.text
691
687
  end
692
688
 
693
689
  def test_find_const_comment_rb_define
@@ -702,7 +698,7 @@ rb_define_const(cFoo, "CONST", value);
702
698
 
703
699
  comment = parser.find_const_comment 'const', 'CONST'
704
700
 
705
- assert_equal "/*\n * A comment\n */\n", comment
701
+ assert_equal "/*\n * A comment\n */\n", comment.text
706
702
  end
707
703
 
708
704
  def test_find_const_comment_document_const
@@ -718,7 +714,7 @@ rb_define_const(cFoo, "CONST", value);
718
714
 
719
715
  comment = parser.find_const_comment nil, 'CONST'
720
716
 
721
- assert_equal " *\n * A comment\n */", comment
717
+ assert_equal "/*\n *\n * A comment\n */", comment.text
722
718
  end
723
719
 
724
720
  def test_find_const_comment_document_const_full_name
@@ -734,7 +730,7 @@ rb_define_const(cFoo, "CONST", value);
734
730
 
735
731
  comment = parser.find_const_comment nil, 'CONST', 'Foo'
736
732
 
737
- assert_equal " *\n * A comment\n */", comment
733
+ assert_equal "/*\n *\n * A comment\n */", comment.text
738
734
  end
739
735
 
740
736
  def test_find_body
@@ -759,7 +755,7 @@ Init_Foo(void) {
759
755
 
760
756
  assert_equal 'my_method', other_function.name
761
757
  assert_equal "a comment for other_function",
762
- other_function.comment
758
+ other_function.comment.text
763
759
  assert_equal '()', other_function.params
764
760
 
765
761
  code = other_function.token_stream.first.text
@@ -832,7 +828,7 @@ Init_Foo(void) {
832
828
  other_function = klass.method_list.first
833
829
 
834
830
  assert_equal 'my_method', other_function.name
835
- assert_equal 'a comment for rb_other_function', other_function.comment
831
+ assert_equal 'a comment for rb_other_function', other_function.comment.text
836
832
  assert_equal '()', other_function.params
837
833
  assert_equal 118, other_function.offset
838
834
  assert_equal 8, other_function.line
@@ -866,7 +862,7 @@ Init_Foo(void) {
866
862
  other_function = klass.method_list.first
867
863
 
868
864
  assert_equal 'my_method', other_function.name
869
- assert_equal 'a comment for other_function', other_function.comment
865
+ assert_equal 'a comment for other_function', other_function.comment.text
870
866
  assert_equal '()', other_function.params
871
867
  assert_equal 39, other_function.offset
872
868
  assert_equal 4, other_function.line
@@ -904,11 +900,11 @@ Init_Foo(void) {
904
900
 
905
901
  bar = methods.first
906
902
  assert_equal 'Foo#bar', bar.full_name
907
- assert_equal "a comment for bar", bar.comment
903
+ assert_equal "a comment for bar", bar.comment.text
908
904
 
909
905
  baz = methods.last
910
906
  assert_equal 'Foo#baz', baz.full_name
911
- assert_equal "a comment for bar", baz.comment
907
+ assert_equal "a comment for bar", baz.comment.text
912
908
  end
913
909
 
914
910
  def test_find_body_document_method_equals
@@ -938,7 +934,7 @@ Init_zlib() {
938
934
 
939
935
  bar = methods.first
940
936
  assert_equal 'Zlib::GzipWriter#mtime=', bar.full_name
941
- assert_equal 'A comment', bar.comment
937
+ assert_equal 'A comment', bar.comment.text
942
938
  end
943
939
 
944
940
  def test_find_body_document_method_same
@@ -979,53 +975,19 @@ Init_Foo(void) {
979
975
 
980
976
  s_bar = methods.first
981
977
  assert_equal 'Foo::bar', s_bar.full_name
982
- assert_equal "a comment for Foo::bar", s_bar.comment
978
+ assert_equal "a comment for Foo::bar", s_bar.comment.text
983
979
 
984
980
  bar = methods.last
985
981
  assert_equal 'Foo#bar', bar.full_name
986
- assert_equal "a comment for Foo#bar", bar.comment
982
+ assert_equal "a comment for Foo#bar", bar.comment.text
987
983
  end
988
984
 
989
985
  def test_find_modifiers_call_seq
990
- comment = <<-COMMENT
991
- /* call-seq:
992
- * commercial() -> Date <br />
993
- * commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
994
- * commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
995
- *
996
- * If no arguments are given:
997
- * * ruby 1.8: returns a +Date+ for 1582-10-15 (the Day of Calendar Reform in
998
- * Italy)
999
- * * ruby 1.9: returns a +Date+ for julian day 0
1000
- *
1001
- * Otherwise, returns a +Date+ for the commercial week year, commercial week,
1002
- * and commercial week day given. Ignores the 4th argument.
1003
- */
1004
-
1005
- COMMENT
1006
-
1007
- parser = util_parser ''
1008
- method_obj = RDoc::AnyMethod.new nil, 'blah'
1009
-
1010
- parser.find_modifiers comment, method_obj
1011
-
1012
- expected = <<-CALL_SEQ.chomp
1013
- commercial() -> Date <br />
1014
- commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
1015
- commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
1016
-
1017
- CALL_SEQ
986
+ comment = RDoc::Comment.new <<-COMMENT
987
+ call-seq:
988
+ commercial() -> Date <br />
1018
989
 
1019
- assert_equal expected, method_obj.call_seq
1020
- end
1021
-
1022
- def test_find_modifiers_call_seq_no_blank
1023
- comment = <<-COMMENT
1024
- /* call-seq:
1025
- * commercial() -> Date <br />
1026
- * commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
1027
- * commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
1028
- */
990
+ If no arguments are given:
1029
991
 
1030
992
  COMMENT
1031
993
 
@@ -1036,16 +998,14 @@ commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
1036
998
 
1037
999
  expected = <<-CALL_SEQ.chomp
1038
1000
  commercial() -> Date <br />
1039
- commercial(cwyear, cweek=41, cwday=5, sg=nil) -> Date [ruby 1.8] <br />
1040
- commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
1041
-
1001
+
1042
1002
  CALL_SEQ
1043
1003
 
1044
1004
  assert_equal expected, method_obj.call_seq
1045
1005
  end
1046
1006
 
1047
1007
  def test_find_modifiers_nodoc
1048
- comment = <<-COMMENT
1008
+ comment = RDoc::Comment.new <<-COMMENT
1049
1009
  /* :nodoc:
1050
1010
  *
1051
1011
  * Blah
@@ -1062,7 +1022,7 @@ commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
1062
1022
  end
1063
1023
 
1064
1024
  def test_find_modifiers_yields
1065
- comment = <<-COMMENT
1025
+ comment = RDoc::Comment.new <<-COMMENT
1066
1026
  /* :yields: a, b
1067
1027
  *
1068
1028
  * Blah
@@ -1077,15 +1037,7 @@ commercial(cwyear, cweek=1, cwday=1, sg=nil) -> Date [ruby 1.9]
1077
1037
 
1078
1038
  assert_equal 'a, b', method_obj.block_params
1079
1039
 
1080
- expected = <<-EXPECTED
1081
- /*
1082
- *
1083
- * Blah
1084
- */
1085
-
1086
- EXPECTED
1087
-
1088
- assert_equal expected, comment
1040
+ assert_equal "\n\nBlah", comment.text
1089
1041
  end
1090
1042
 
1091
1043
  def test_handle_method_args_minus_1
@@ -1208,12 +1160,12 @@ void Init_Blah(void) {
1208
1160
  def test_look_for_directives_in
1209
1161
  parser = util_parser ''
1210
1162
 
1211
- comment = "# :markup: not_rdoc\n"
1163
+ comment = RDoc::Comment.new "# :other: not_handled\n"
1212
1164
 
1213
1165
  parser.look_for_directives_in @top_level, comment
1214
1166
 
1215
- assert_equal "# :markup: not_rdoc\n", comment
1216
- assert_equal 'not_rdoc', @top_level.metadata['markup']
1167
+ assert_equal "# :other: not_handled\n", comment.text
1168
+ assert_equal 'not_handled', @top_level.metadata['other']
1217
1169
  end
1218
1170
 
1219
1171
  def test_define_method
@@ -1240,7 +1192,7 @@ Init_IO(void) {
1240
1192
  klass = util_get_class content, 'rb_cIO'
1241
1193
  read_method = klass.method_list.first
1242
1194
  assert_equal "read", read_method.name
1243
- assert_equal "Method Comment! ", read_method.comment
1195
+ assert_equal "Method Comment! ", read_method.comment.text
1244
1196
  assert_equal "rb_io_s_read", read_method.c_function
1245
1197
  assert read_method.singleton
1246
1198
  end
@@ -1271,7 +1223,7 @@ Init_IO(void) {
1271
1223
  klass = util_get_class content, 'rb_cIO'
1272
1224
  read_method = klass.method_list.first
1273
1225
  assert_equal "read", read_method.name
1274
- assert_equal "Method Comment! ", read_method.comment
1226
+ assert_equal "Method Comment! ", read_method.comment.text
1275
1227
  assert_equal "rb_io_s_read", read_method.c_function
1276
1228
  assert read_method.singleton
1277
1229
  end
@@ -1301,7 +1253,7 @@ Init_IO(void) {
1301
1253
  read_method = klass.method_list.first
1302
1254
  assert_equal 'IO#read', read_method.full_name
1303
1255
  assert_equal :private, read_method.visibility
1304
- assert_equal "Method Comment! ", read_method.comment
1256
+ assert_equal "Method Comment! ", read_method.comment.text
1305
1257
  end
1306
1258
 
1307
1259
  def test_define_method_private_singleton
@@ -1329,7 +1281,7 @@ Init_IO(void) {
1329
1281
  klass = util_get_class content, 'rb_cIO'
1330
1282
  read_method = klass.method_list.first
1331
1283
  assert_equal "read", read_method.name
1332
- assert_equal "Method Comment! ", read_method.comment
1284
+ assert_equal "Method Comment! ", read_method.comment.text
1333
1285
  assert_equal :private, read_method.visibility
1334
1286
  assert read_method.singleton
1335
1287
  end
@@ -1359,7 +1311,7 @@ Init_IO(void) {
1359
1311
  klass = util_get_class content, 'rb_cIO'
1360
1312
  read_method = klass.method_list.first
1361
1313
  assert_equal "read", read_method.name
1362
- assert_equal "Method Comment! ", read_method.comment
1314
+ assert_equal "Method Comment! ", read_method.comment.text
1363
1315
  assert read_method.singleton
1364
1316
  end
1365
1317