rdoc 3.12.2 → 4.0.0.preview2

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 (200) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +3 -2
  5. data/DEVELOPERS.rdoc +53 -0
  6. data/History.rdoc +159 -25
  7. data/LEGAL.rdoc +12 -0
  8. data/Manifest.txt +56 -3
  9. data/README.rdoc +87 -19
  10. data/Rakefile +11 -2
  11. data/TODO.rdoc +20 -13
  12. data/bin/rdoc +4 -0
  13. data/lib/gauntlet_rdoc.rb +1 -1
  14. data/lib/rdoc.rb +32 -71
  15. data/lib/rdoc/any_method.rb +75 -21
  16. data/lib/rdoc/attr.rb +49 -10
  17. data/lib/rdoc/class_module.rb +182 -32
  18. data/lib/rdoc/code_object.rb +54 -12
  19. data/lib/rdoc/comment.rb +8 -1
  20. data/lib/rdoc/constant.rb +100 -6
  21. data/lib/rdoc/context.rb +93 -41
  22. data/lib/rdoc/context/section.rb +143 -28
  23. data/lib/rdoc/cross_reference.rb +58 -50
  24. data/lib/rdoc/encoding.rb +34 -29
  25. data/lib/rdoc/erb_partial.rb +18 -0
  26. data/lib/rdoc/extend.rb +117 -0
  27. data/lib/rdoc/generator.rb +11 -6
  28. data/lib/rdoc/generator/darkfish.rb +250 -62
  29. data/lib/rdoc/generator/json_index.rb +20 -12
  30. data/lib/rdoc/generator/markup.rb +10 -12
  31. data/lib/rdoc/generator/ri.rb +7 -60
  32. data/lib/rdoc/generator/template/darkfish/_head.rhtml +7 -7
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +16 -0
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +1 -1
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +14 -0
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +1 -1
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +13 -0
  38. data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -1
  39. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  40. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -3
  41. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -9
  42. data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -0
  43. data/lib/rdoc/generator/template/darkfish/rdoc.css +31 -0
  44. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  45. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +37 -0
  46. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
  47. data/lib/rdoc/include.rb +12 -3
  48. data/lib/rdoc/markdown.kpeg +1186 -0
  49. data/lib/rdoc/markdown.rb +16336 -0
  50. data/lib/rdoc/markdown/entities.rb +2128 -0
  51. data/lib/rdoc/markdown/literals_1_8.kpeg +18 -0
  52. data/lib/rdoc/markdown/literals_1_8.rb +454 -0
  53. data/lib/rdoc/markdown/literals_1_9.kpeg +22 -0
  54. data/lib/rdoc/markdown/literals_1_9.rb +417 -0
  55. data/lib/rdoc/markup.rb +69 -10
  56. data/lib/rdoc/markup/attr_changer.rb +2 -5
  57. data/lib/rdoc/markup/attribute_manager.rb +23 -14
  58. data/lib/rdoc/markup/attributes.rb +70 -0
  59. data/lib/rdoc/markup/block_quote.rb +14 -0
  60. data/lib/rdoc/markup/document.rb +20 -4
  61. data/lib/rdoc/markup/formatter.rb +17 -6
  62. data/lib/rdoc/markup/formatter_test_case.rb +93 -24
  63. data/lib/rdoc/markup/hard_break.rb +31 -0
  64. data/lib/rdoc/markup/heading.rb +1 -1
  65. data/lib/rdoc/markup/indented_paragraph.rb +14 -0
  66. data/lib/rdoc/markup/list.rb +23 -4
  67. data/lib/rdoc/markup/list_item.rb +17 -4
  68. data/lib/rdoc/markup/paragraph.rb +14 -0
  69. data/lib/rdoc/markup/parser.rb +107 -60
  70. data/lib/rdoc/markup/raw.rb +4 -4
  71. data/lib/rdoc/markup/special.rb +3 -3
  72. data/lib/rdoc/markup/to_ansi.rb +7 -1
  73. data/lib/rdoc/markup/to_html.rb +42 -14
  74. data/lib/rdoc/markup/to_html_crossref.rb +10 -9
  75. data/lib/rdoc/markup/to_html_snippet.rb +20 -4
  76. data/lib/rdoc/markup/to_joined_paragraph.rb +68 -0
  77. data/lib/rdoc/markup/to_label.rb +20 -1
  78. data/lib/rdoc/markup/to_markdown.rb +134 -0
  79. data/lib/rdoc/markup/to_rdoc.rb +36 -5
  80. data/lib/rdoc/markup/to_table_of_contents.rb +6 -1
  81. data/lib/rdoc/markup/to_tt_only.rb +11 -2
  82. data/lib/rdoc/markup/verbatim.rb +19 -0
  83. data/lib/rdoc/method_attr.rb +33 -19
  84. data/lib/rdoc/normal_class.rb +26 -7
  85. data/lib/rdoc/normal_module.rb +10 -5
  86. data/lib/rdoc/options.rb +95 -21
  87. data/lib/rdoc/parser.rb +6 -2
  88. data/lib/rdoc/parser/c.rb +212 -97
  89. data/lib/rdoc/parser/markdown.rb +23 -0
  90. data/lib/rdoc/parser/ruby.rb +115 -35
  91. data/lib/rdoc/parser/ruby_tools.rb +8 -3
  92. data/lib/rdoc/rd.rb +8 -4
  93. data/lib/rdoc/rd/block_parser.rb +1 -1
  94. data/lib/rdoc/rd/block_parser.ry +1 -1
  95. data/lib/rdoc/rdoc.rb +45 -21
  96. data/lib/rdoc/ri/driver.rb +322 -76
  97. data/lib/rdoc/ri/paths.rb +90 -31
  98. data/lib/rdoc/ri/store.rb +2 -353
  99. data/lib/rdoc/ruby_lex.rb +5 -21
  100. data/lib/rdoc/ruby_token.rb +2 -3
  101. data/lib/rdoc/rubygems_hook.rb +21 -9
  102. data/lib/rdoc/servlet.rb +302 -0
  103. data/lib/rdoc/stats.rb +28 -20
  104. data/lib/rdoc/store.rb +881 -0
  105. data/lib/rdoc/task.rb +2 -1
  106. data/lib/rdoc/test_case.rb +103 -1
  107. data/lib/rdoc/text.rb +5 -4
  108. data/lib/rdoc/tom_doc.rb +17 -16
  109. data/lib/rdoc/top_level.rb +43 -285
  110. data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +21 -0
  111. data/test/MarkdownTest_1.0.3/Auto links.text +13 -0
  112. data/test/MarkdownTest_1.0.3/Backslash escapes.text +120 -0
  113. data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +11 -0
  114. data/test/MarkdownTest_1.0.3/Code Blocks.text +14 -0
  115. data/test/MarkdownTest_1.0.3/Code Spans.text +6 -0
  116. data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +8 -0
  117. data/test/MarkdownTest_1.0.3/Horizontal rules.text +67 -0
  118. data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +15 -0
  119. data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +69 -0
  120. data/test/MarkdownTest_1.0.3/Inline HTML comments.text +13 -0
  121. data/test/MarkdownTest_1.0.3/Links, inline style.text +12 -0
  122. data/test/MarkdownTest_1.0.3/Links, reference style.text +71 -0
  123. data/test/MarkdownTest_1.0.3/Links, shortcut references.text +20 -0
  124. data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +7 -0
  125. data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +306 -0
  126. data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +888 -0
  127. data/test/MarkdownTest_1.0.3/Nested blockquotes.text +5 -0
  128. data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +131 -0
  129. data/test/MarkdownTest_1.0.3/Strong and em together.text +7 -0
  130. data/test/MarkdownTest_1.0.3/Tabs.text +21 -0
  131. data/test/MarkdownTest_1.0.3/Tidyness.text +5 -0
  132. data/test/test_attribute_manager.rb +7 -4
  133. data/test/test_rdoc_any_method.rb +84 -13
  134. data/test/test_rdoc_attr.rb +59 -9
  135. data/test/test_rdoc_class_module.rb +670 -73
  136. data/test/test_rdoc_code_object.rb +21 -1
  137. data/test/test_rdoc_comment.rb +1 -1
  138. data/test/test_rdoc_constant.rb +132 -0
  139. data/test/test_rdoc_context.rb +84 -18
  140. data/test/test_rdoc_context_section.rb +99 -15
  141. data/test/test_rdoc_cross_reference.rb +1 -1
  142. data/test/test_rdoc_encoding.rb +17 -1
  143. data/test/test_rdoc_extend.rb +94 -0
  144. data/test/test_rdoc_generator_darkfish.rb +45 -19
  145. data/test/test_rdoc_generator_json_index.rb +27 -7
  146. data/test/test_rdoc_generator_markup.rb +3 -3
  147. data/test/test_rdoc_generator_ri.rb +11 -9
  148. data/test/test_rdoc_include.rb +12 -0
  149. data/test/test_rdoc_markdown.rb +977 -0
  150. data/test/test_rdoc_markdown_test.rb +1891 -0
  151. data/test/test_rdoc_markup.rb +1 -1
  152. data/test/test_rdoc_markup_attribute_manager.rb +2 -2
  153. data/test/test_rdoc_markup_attributes.rb +39 -0
  154. data/test/test_rdoc_markup_document.rb +16 -1
  155. data/test/test_rdoc_markup_formatter.rb +7 -4
  156. data/test/test_rdoc_markup_hard_break.rb +31 -0
  157. data/test/test_rdoc_markup_indented_paragraph.rb +14 -0
  158. data/test/test_rdoc_markup_paragraph.rb +15 -1
  159. data/test/test_rdoc_markup_parser.rb +152 -89
  160. data/test/test_rdoc_markup_to_ansi.rb +23 -2
  161. data/test/test_rdoc_markup_to_bs.rb +24 -0
  162. data/test/test_rdoc_markup_to_html.rb +50 -19
  163. data/test/test_rdoc_markup_to_html_crossref.rb +23 -5
  164. data/test/test_rdoc_markup_to_html_snippet.rb +49 -8
  165. data/test/test_rdoc_markup_to_joined_paragraph.rb +32 -0
  166. data/test/test_rdoc_markup_to_label.rb +63 -1
  167. data/test/test_rdoc_markup_to_markdown.rb +352 -0
  168. data/test/test_rdoc_markup_to_rdoc.rb +22 -2
  169. data/test/test_rdoc_markup_to_table_of_contents.rb +44 -39
  170. data/test/test_rdoc_markup_to_tt_only.rb +20 -0
  171. data/test/test_rdoc_markup_verbatim.rb +13 -0
  172. data/test/test_rdoc_method_attr.rb +5 -0
  173. data/test/test_rdoc_normal_class.rb +24 -5
  174. data/test/test_rdoc_normal_module.rb +1 -1
  175. data/test/test_rdoc_options.rb +21 -6
  176. data/test/test_rdoc_parser.rb +24 -0
  177. data/test/test_rdoc_parser_c.rb +151 -26
  178. data/test/test_rdoc_parser_markdown.rb +55 -0
  179. data/test/test_rdoc_parser_rd.rb +2 -2
  180. data/test/test_rdoc_parser_ruby.rb +468 -109
  181. data/test/test_rdoc_parser_simple.rb +2 -2
  182. data/test/test_rdoc_rd_block_parser.rb +0 -4
  183. data/test/test_rdoc_rdoc.rb +110 -22
  184. data/test/test_rdoc_ri_driver.rb +415 -80
  185. data/test/test_rdoc_ri_paths.rb +122 -13
  186. data/test/test_rdoc_ruby_lex.rb +5 -61
  187. data/test/test_rdoc_ruby_token.rb +19 -0
  188. data/test/test_rdoc_rubygems_hook.rb +64 -43
  189. data/test/test_rdoc_servlet.rb +429 -0
  190. data/test/test_rdoc_stats.rb +83 -24
  191. data/test/{test_rdoc_ri_store.rb → test_rdoc_store.rb} +395 -22
  192. data/test/test_rdoc_task.rb +2 -2
  193. data/test/test_rdoc_text.rb +37 -11
  194. data/test/test_rdoc_tom_doc.rb +59 -62
  195. data/test/test_rdoc_top_level.rb +71 -113
  196. data/test/xref_test_case.rb +7 -9
  197. metadata +122 -39
  198. metadata.gz.sig +0 -0
  199. data/CVE-2013-0256.rdoc +0 -49
  200. data/lib/rdoc/markup/attribute.rb +0 -51
@@ -46,45 +46,50 @@ class TestRDocMarkupToTableOfContents < RDoc::Markup::FormatterTestCase
46
46
  assert_equal [@RM::Heading.new(1, '\\Hello')], @to.res
47
47
  end
48
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
49
+ alias accept_blank_line empty
50
+ alias accept_block_quote empty
51
+ alias accept_document empty
52
+ alias accept_list_end_bullet empty
53
+ alias accept_list_end_label empty
54
+ alias accept_list_end_lalpha empty
55
+ alias accept_list_end_note empty
56
+ alias accept_list_end_number empty
57
+ alias accept_list_end_ualpha empty
58
+ alias accept_list_item_end_bullet empty
59
+ alias accept_list_item_end_label empty
60
+ alias accept_list_item_end_lalpha empty
61
+ alias accept_list_item_end_note empty
62
+ alias accept_list_item_end_number empty
63
+ alias accept_list_item_end_ualpha empty
64
+ alias accept_list_item_start_bullet empty
65
+ alias accept_list_item_start_label empty
66
+ alias accept_list_item_start_lalpha empty
67
+ alias accept_list_item_start_note empty
68
+ alias accept_list_item_start_note_2 empty
69
+ alias accept_list_item_start_note_multi_description empty
70
+ alias accept_list_item_start_note_multi_label empty
71
+ alias accept_list_item_start_number empty
72
+ alias accept_list_item_start_ualpha empty
73
+ alias accept_list_start_bullet empty
74
+ alias accept_list_start_label empty
75
+ alias accept_list_start_lalpha empty
76
+ alias accept_list_start_note empty
77
+ alias accept_list_start_number empty
78
+ alias accept_list_start_ualpha empty
79
+ alias accept_paragraph empty
80
+ alias accept_paragraph_b empty
81
+ alias accept_paragraph_br empty
82
+ alias accept_paragraph_break empty
83
+ alias accept_paragraph_i empty
84
+ alias accept_paragraph_plus empty
85
+ alias accept_paragraph_star empty
86
+ alias accept_paragraph_underscore empty
87
+ alias accept_raw empty
88
+ alias accept_rule empty
89
+ alias accept_verbatim empty
90
+ alias list_nested empty
91
+ alias list_verbatim empty
92
+ alias start_accepting empty
88
93
 
89
94
  end
90
95
 
@@ -14,6 +14,10 @@ class TestRDocMarkupToTtOnly < RDoc::Markup::FormatterTestCase
14
14
  assert_empty @to.end_accepting
15
15
  end
16
16
 
17
+ def accept_block_quote
18
+ assert_empty @to.end_accepting
19
+ end
20
+
17
21
  def accept_document
18
22
  assert_equal [], @to.res
19
23
  end
@@ -122,6 +126,10 @@ class TestRDocMarkupToTtOnly < RDoc::Markup::FormatterTestCase
122
126
  assert_empty @to.end_accepting
123
127
  end
124
128
 
129
+ def accept_paragraph_break
130
+ assert_empty @to.end_accepting
131
+ end
132
+
125
133
  def accept_raw
126
134
  assert_empty @to.end_accepting
127
135
  end
@@ -174,10 +182,22 @@ class TestRDocMarkupToTtOnly < RDoc::Markup::FormatterTestCase
174
182
  assert_equal [nil, 'teletype', nil], @to.res
175
183
  end
176
184
 
185
+ def accept_list_item_start_note_multi_description
186
+ assert_empty @to.res
187
+ end
188
+
189
+ def accept_list_item_start_note_multi_label
190
+ assert_empty @to.res
191
+ end
192
+
177
193
  def accept_paragraph_b
178
194
  assert_empty @to.end_accepting
179
195
  end
180
196
 
197
+ def accept_paragraph_br
198
+ assert_empty @to.end_accepting
199
+ end
200
+
181
201
  def accept_paragraph_i
182
202
  assert_empty @to.end_accepting
183
203
  end
@@ -2,6 +2,19 @@ require 'rdoc/test_case'
2
2
 
3
3
  class TestRDocMarkupVerbatim < RDoc::TestCase
4
4
 
5
+ def test_equals2
6
+ v1 = verb('1 + 1')
7
+ v2 = verb('1 + 1')
8
+ v3 = verb('1 + 2')
9
+ v4 = verb('1 + 1')
10
+ v4.format = :ruby
11
+
12
+ assert_equal v1, v2
13
+
14
+ refute_equal v1, v3
15
+ refute_equal v1, v4
16
+ end
17
+
5
18
  def test_ruby_eh
6
19
  verbatim = RDoc::Markup::Verbatim.new
7
20
 
@@ -140,6 +140,11 @@ class TestRDocMethodAttr < XrefTestCase
140
140
  assert_equal expected, @c1_m.search_record
141
141
  end
142
142
 
143
+ def test_equals2
144
+ assert_equal @c1_m, @c1_m
145
+ refute_equal @c1_m, @parent_m
146
+ end
147
+
143
148
  def test_to_s
144
149
  assert_equal 'RDoc::AnyMethod: C1#m', @c1_m.to_s
145
150
  assert_equal 'RDoc::AnyMethod: C2#b', @c2_b.to_s
@@ -2,15 +2,34 @@ require File.expand_path '../xref_test_case', __FILE__
2
2
 
3
3
  class TestRDocNormalClass < XrefTestCase
4
4
 
5
- def test_ancestors_class
6
- top_level = RDoc::TopLevel.new 'file.rb'
7
- klass = top_level.add_class RDoc::NormalClass, 'Klass'
5
+ def test_ancestors
6
+ klass = @top_level.add_class RDoc::NormalClass, 'Klass'
8
7
  incl = RDoc::Include.new 'Incl', ''
9
8
 
10
- sub_klass = klass.add_class RDoc::NormalClass, 'SubClass', 'Klass'
9
+ sub_klass = @top_level.add_class RDoc::NormalClass, 'SubClass'
10
+ sub_klass.superclass = klass
11
11
  sub_klass.add_include incl
12
12
 
13
- assert_equal [incl.name, klass], sub_klass.ancestors
13
+ assert_equal [incl.name, klass, 'Object'], sub_klass.ancestors
14
+ end
15
+
16
+ def test_ancestors_multilevel
17
+ c1 = @top_level.add_class RDoc::NormalClass, 'Outer'
18
+ c2 = @top_level.add_class RDoc::NormalClass, 'Middle', c1
19
+ c3 = @top_level.add_class RDoc::NormalClass, 'Inner', c2
20
+
21
+ assert_equal [c2, c1, 'Object'], c3.ancestors
22
+ end
23
+
24
+ def test_direct_ancestors
25
+ incl = RDoc::Include.new 'Incl', ''
26
+
27
+ c1 = @top_level.add_class RDoc::NormalClass, 'Outer'
28
+ c2 = @top_level.add_class RDoc::NormalClass, 'Middle', c1
29
+ c3 = @top_level.add_class RDoc::NormalClass, 'Inner', c2
30
+ c3.add_include incl
31
+
32
+ assert_equal [incl.name, c2], c3.direct_ancestors
14
33
  end
15
34
 
16
35
  def test_definition
@@ -9,7 +9,7 @@ class TestRDocNormalModule < XrefTestCase
9
9
  end
10
10
 
11
11
  def test_ancestors_module
12
- top_level = RDoc::TopLevel.new 'file.rb'
12
+ top_level = @store.add_file 'file.rb'
13
13
  mod = top_level.add_module RDoc::NormalModule, 'Mod'
14
14
  incl = RDoc::Include.new 'Incl', ''
15
15
 
@@ -45,7 +45,7 @@ class TestRDocOptions < RDoc::TestCase
45
45
  def test_check_files_warn
46
46
  @options.verbosity = 2
47
47
 
48
- out, err = capture_io do
48
+ out, err = verbose_capture_io do
49
49
  @options.files = %w[nonexistent]
50
50
 
51
51
  @options.check_files
@@ -124,7 +124,7 @@ class TestRDocOptions < RDoc::TestCase
124
124
  def test_encoding_default
125
125
  skip "Encoding not implemented" unless Object.const_defined? :Encoding
126
126
 
127
- assert_equal Encoding.default_external, @options.encoding
127
+ assert_equal Encoding::UTF_8, @options.encoding
128
128
  end
129
129
 
130
130
  def test_generator_descriptions
@@ -195,7 +195,9 @@ rdoc_include:
195
195
  def test_parse_copy_files_directory_absolute
196
196
  @options.parse %w[--copy-files /]
197
197
 
198
- assert_equal ['/'], @options.static_path
198
+ assert_equal 1, @options.static_path.length
199
+
200
+ assert_match %r%^([A-Z]:)?/$%i, @options.static_path.first
199
201
  end
200
202
 
201
203
  def test_parse_coverage
@@ -428,6 +430,19 @@ rdoc_include:
428
430
  assert_equal 'tomdoc', @options.markup
429
431
  end
430
432
 
433
+ def test_parse_root
434
+ assert_equal Pathname(Dir.pwd), @options.root
435
+
436
+ out, err = capture_io do
437
+ @options.parse %W[--root #{Dir.tmpdir}]
438
+ end
439
+
440
+ assert_empty out
441
+ assert_empty err
442
+
443
+ assert_equal Pathname(Dir.tmpdir), @options.root
444
+ end
445
+
431
446
  def test_parse_template
432
447
  out, err = capture_io do
433
448
  @options.parse %w[--template darkfish]
@@ -489,7 +504,7 @@ rdoc_include:
489
504
  end
490
505
 
491
506
  assert_equal 0, e.status
492
-
507
+
493
508
  assert File.exist? '.rdoc_options'
494
509
  end
495
510
  ensure
@@ -557,7 +572,7 @@ rdoc_include:
557
572
 
558
573
  @options.verbosity = 2
559
574
 
560
- out, err = capture_io do
575
+ out, err = verbose_capture_io do
561
576
  @options.warn "warnings on"
562
577
  end
563
578
 
@@ -568,7 +583,7 @@ rdoc_include:
568
583
  def test_write_options
569
584
  temp_dir do |dir|
570
585
  @options.write_options
571
-
586
+
572
587
  assert File.exist? '.rdoc_options'
573
588
 
574
589
  assert_equal @options, YAML.load(File.read('.rdoc_options'))
@@ -61,6 +61,20 @@ class TestRDocParser < RDoc::TestCase
61
61
  assert_equal @RP::Simple, @RP.can_parse(readme_file_name)
62
62
  end
63
63
 
64
+ def test_class_can_parse_forbidden
65
+ skip 'chmod not supported' if Gem.win_platform?
66
+
67
+ Tempfile.open 'forbidden' do |io|
68
+ begin
69
+ File.chmod 0000, io.path
70
+
71
+ assert_nil @RP.can_parse io.path
72
+ ensure
73
+ File.chmod 0400, io.path
74
+ end
75
+ end
76
+ end
77
+
64
78
  ##
65
79
  # Selenium hides a .jar file using a .txt extension.
66
80
 
@@ -101,6 +115,16 @@ class TestRDocParser < RDoc::TestCase
101
115
  assert_equal @RP::RD, parser
102
116
  end
103
117
 
118
+ def test_class_use_markup_markdown
119
+ content = <<-CONTENT
120
+ # coding: utf-8 markup: markdown
121
+ CONTENT
122
+
123
+ parser = @RP.use_markup content
124
+
125
+ assert_equal @RP::Ruby, parser
126
+ end
127
+
104
128
  def test_class_use_markup_modeline
105
129
  content = <<-CONTENT
106
130
  # -*- coding: utf-8 -*-
@@ -54,11 +54,11 @@ class TestRDocParserC < RDoc::TestCase
54
54
  @tempfile = Tempfile.new self.class.name
55
55
  filename = @tempfile.path
56
56
 
57
- @top_level = RDoc::TopLevel.new filename
57
+ @top_level = @store.add_file filename
58
58
  @fn = filename
59
59
  @options = RDoc::Options.new
60
60
  @options.verbosity = 2
61
- @stats = RDoc::Stats.new 0
61
+ @stats = RDoc::Stats.new @store, 0
62
62
  end
63
63
 
64
64
  def teardown
@@ -244,11 +244,11 @@ void Init_Blah(void) {
244
244
  }
245
245
  EOF
246
246
 
247
- _, err = capture_io do
247
+ _, err = verbose_capture_io do
248
248
  refute util_get_class(content, 'cDate')
249
249
  end
250
250
 
251
- assert_equal "Enclosing class/module \"cDate\" for alias b a not known\n",
251
+ assert_equal "Enclosing class or module \"cDate\" for alias b a is not known\n",
252
252
  err
253
253
  end
254
254
 
@@ -388,6 +388,12 @@ void Init_foo(){
388
388
  */
389
389
  rb_define_const(cFoo, "MULTILINE_NOT_EMPTY", INT2FIX(1));
390
390
 
391
+ /*
392
+ * Multiline comment goes here because this comment spans multiple lines.
393
+ * 1: However, the value extraction should only happen for the first line
394
+ */
395
+ rb_define_const(cFoo, "MULTILINE_COLON_ON_SECOND_LINE", INT2FIX(1));
396
+
391
397
  }
392
398
  EOF
393
399
 
@@ -437,6 +443,13 @@ Multiline comment goes here because this comment spans multiple lines.
437
443
  assert_equal ['MULTILINE_VALUE', '1', comment], constants.shift
438
444
  assert_equal ['MULTILINE_NOT_EMPTY', 'INT2FIX(1)', comment], constants.shift
439
445
 
446
+ comment = <<-EOF.chomp
447
+ Multiline comment goes here because this comment spans multiple lines.
448
+ 1: However, the value extraction should only happen for the first line
449
+ EOF
450
+ assert_equal ['MULTILINE_COLON_ON_SECOND_LINE', 'INT2FIX(1)', comment],
451
+ constants.shift
452
+
440
453
  assert constants.empty?, constants.inspect
441
454
  end
442
455
 
@@ -456,6 +469,7 @@ void Init_curses(){
456
469
 
457
470
  @parser = util_parser content
458
471
 
472
+ @parser.do_modules
459
473
  @parser.do_classes
460
474
  @parser.do_constants
461
475
 
@@ -469,6 +483,39 @@ void Init_curses(){
469
483
  assert_equal 'Value of the color black', constants.first.comment.text
470
484
  end
471
485
 
486
+ def test_do_constants_file
487
+ content = <<-EOF
488
+ void Init_File(void) {
489
+ rb_cFile = rb_define_class("File", rb_cIO);
490
+ rb_mFConst = rb_define_module_under(rb_cFile, "Constants");
491
+ rb_include_module(rb_cIO, rb_mFConst);
492
+
493
+ /* Document-const: LOCK_SH
494
+ *
495
+ * Shared lock
496
+ */
497
+ rb_file_const("LOCK_SH", INT2FIX(LOCK_SH));
498
+ }
499
+ EOF
500
+
501
+ @parser = util_parser content
502
+
503
+ @parser.do_modules
504
+ @parser.do_classes
505
+ @parser.do_constants
506
+
507
+ klass = @parser.classes['rb_mFConst']
508
+
509
+ constants = klass.constants
510
+ refute_empty klass.constants
511
+
512
+ constant = constants.first
513
+
514
+ assert_equal 'LOCK_SH', constant.name
515
+ assert_equal 'INT2FIX(LOCK_SH)', constant.value
516
+ assert_equal 'Shared lock', constant.comment.text
517
+ end
518
+
472
519
  def test_do_includes
473
520
  content = <<-EOF
474
521
  Init_foo() {
@@ -502,7 +549,7 @@ void Init_Blah(void) {
502
549
 
503
550
  klass = nil
504
551
 
505
- _, err = capture_io do
552
+ _, err = verbose_capture_io do
506
553
  klass = util_get_class content, 'cDate'
507
554
  end
508
555
 
@@ -524,7 +571,7 @@ void Init_Blah(void) {
524
571
 
525
572
  klass = nil
526
573
 
527
- _, err = capture_io do
574
+ _, err = verbose_capture_io do
528
575
  klass = util_get_class content, 'cDate'
529
576
  end
530
577
 
@@ -546,7 +593,7 @@ void Init_Blah(void) {
546
593
 
547
594
  klass = nil
548
595
 
549
- _, err = capture_io do
596
+ _, err = verbose_capture_io do
550
597
  klass = util_get_class content, 'cDate'
551
598
  end
552
599
 
@@ -574,8 +621,59 @@ void Init_Blah(void) {
574
621
  assert methods.first.singleton
575
622
  end
576
623
 
624
+ def test_do_missing
625
+ parser = util_parser
626
+
627
+ klass_a = @top_level.add_class RDoc::ClassModule, 'A'
628
+ parser.classes['a'] = klass_a
629
+
630
+ parser.enclosure_dependencies['c'] << 'b'
631
+ parser.enclosure_dependencies['b'] << 'a'
632
+ parser.enclosure_dependencies['d'] << 'a'
633
+
634
+ parser.missing_dependencies['d'] = ['d', :class, 'D', 'Object', 'a']
635
+ parser.missing_dependencies['c'] = ['c', :class, 'C', 'Object', 'b']
636
+ parser.missing_dependencies['b'] = ['b', :class, 'B', 'Object', 'a']
637
+
638
+ parser.do_missing
639
+
640
+ assert_equal %w[A A::B A::B::C A::D],
641
+ @store.all_classes_and_modules.map { |m| m.full_name }.sort
642
+ end
643
+
644
+ def test_do_missing_cycle
645
+ parser = util_parser
646
+
647
+ klass_a = @top_level.add_class RDoc::ClassModule, 'A'
648
+ parser.classes['a'] = klass_a
649
+
650
+ parser.enclosure_dependencies['c'] << 'b'
651
+ parser.enclosure_dependencies['b'] << 'a'
652
+
653
+ parser.missing_dependencies['c'] = ['c', :class, 'C', 'Object', 'b']
654
+ parser.missing_dependencies['b'] = ['b', :class, 'B', 'Object', 'a']
655
+
656
+ parser.enclosure_dependencies['y'] << 'z'
657
+ parser.enclosure_dependencies['z'] << 'y'
658
+
659
+ parser.missing_dependencies['y'] = ['y', :class, 'Y', 'Object', 'z']
660
+ parser.missing_dependencies['z'] = ['z', :class, 'Z', 'Object', 'y']
661
+
662
+ _, err = verbose_capture_io do
663
+ parser.do_missing
664
+ end
665
+
666
+ expected = 'Unable to create class Y (y), class Z (z) ' +
667
+ 'due to a cyclic class or module creation'
668
+
669
+ assert_equal expected, err.chomp
670
+
671
+ assert_equal %w[A A::B A::B::C],
672
+ @store.all_classes_and_modules.map { |m| m.full_name }.sort
673
+ end
674
+
577
675
  def test_find_alias_comment
578
- parser = util_parser ''
676
+ parser = util_parser
579
677
 
580
678
  comment = parser.find_alias_comment 'C', '[]', 'index'
581
679
 
@@ -594,24 +692,25 @@ rb_define_alias(C, "[]", "index");
594
692
  assert_equal "/*\n * comment\n */\n\n", comment.text
595
693
  end
596
694
 
597
- def test_find_class_comment_include
695
+ def test_find_class_comment
598
696
  @options.rdoc_include << File.dirname(__FILE__)
599
697
 
600
698
  content = <<-EOF
601
699
  /*
602
- * a comment for class Foo
603
- *
604
- * :include: test.txt
700
+ * Comment 1
605
701
  */
606
- void
607
- Init_Foo(void) {
608
- VALUE foo = rb_define_class("Foo", rb_cObject);
609
- }
702
+ foo = rb_define_class("MyClassName1", rb_cObject);
703
+
704
+ /*
705
+ * Comment 2
706
+ */
707
+ bar = rb_define_class("MyClassName2", rb_cObject);
610
708
  EOF
611
709
 
612
- klass = util_get_class content, 'foo'
710
+ util_get_class content
613
711
 
614
- assert_equal "a comment for class Foo\n\ntest file\n", klass.comment.text
712
+ assert_equal "Comment 1", @parser.classes['foo'].comment.text
713
+ assert_equal "Comment 2", @parser.classes['bar'].comment.text
615
714
  end
616
715
 
617
716
  def test_find_class_comment_init
@@ -1041,7 +1140,7 @@ If no arguments are given:
1041
1140
 
1042
1141
  COMMENT
1043
1142
 
1044
- parser = util_parser ''
1143
+ parser = util_parser
1045
1144
  method_obj = RDoc::AnyMethod.new nil, 'blah'
1046
1145
 
1047
1146
  parser.find_modifiers comment, method_obj
@@ -1063,7 +1162,7 @@ commercial() -> Date <br />
1063
1162
 
1064
1163
  COMMENT
1065
1164
 
1066
- parser = util_parser ''
1165
+ parser = util_parser
1067
1166
  method_obj = RDoc::AnyMethod.new nil, 'blah'
1068
1167
 
1069
1168
  parser.find_modifiers comment, method_obj
@@ -1080,7 +1179,7 @@ commercial() -> Date <br />
1080
1179
 
1081
1180
  COMMENT
1082
1181
 
1083
- parser = util_parser ''
1182
+ parser = util_parser
1084
1183
  method_obj = RDoc::AnyMethod.new nil, 'blah'
1085
1184
 
1086
1185
  parser.find_modifiers comment, method_obj
@@ -1208,7 +1307,7 @@ void Init_Blah(void) {
1208
1307
  end
1209
1308
 
1210
1309
  def test_look_for_directives_in
1211
- parser = util_parser ''
1310
+ parser = util_parser
1212
1311
 
1213
1312
  comment = RDoc::Comment.new "# :other: not_handled\n"
1214
1313
 
@@ -1366,7 +1465,7 @@ Init_IO(void) {
1366
1465
  end
1367
1466
 
1368
1467
  def test_rb_scan_args
1369
- parser = util_parser ''
1468
+ parser = util_parser
1370
1469
 
1371
1470
  assert_equal '(p1)',
1372
1471
  parser.rb_scan_args('rb_scan_args(a, b, "1",)')
@@ -1424,13 +1523,39 @@ Init_IO(void) {
1424
1523
  parser.rb_scan_args('rb_scan_args(a, b, "*:&",)')
1425
1524
  end
1426
1525
 
1427
- def util_get_class(content, name)
1526
+ def test_scan_order_dependent
1527
+ parser = util_parser <<-C
1528
+ void a(void) {
1529
+ mA = rb_define_module("A");
1530
+ }
1531
+
1532
+ void b(void) {
1533
+ cB = rb_define_class_under(mA, "B", rb_cObject);
1534
+ }
1535
+
1536
+ void c(void) {
1537
+ mC = rb_define_module_under(cB, "C");
1538
+ }
1539
+
1540
+ void d(void) {
1541
+ mD = rb_define_class_under(mC, "D");
1542
+ }
1543
+ C
1544
+
1545
+ parser.scan
1546
+
1547
+ assert_equal %w[A A::B A::B::C],
1548
+ @store.all_classes_and_modules.map { |m| m.full_name }.sort
1549
+ end
1550
+
1551
+ def util_get_class content, name = nil
1428
1552
  @parser = util_parser content
1429
1553
  @parser.scan
1430
- @parser.classes[name]
1554
+
1555
+ @parser.classes[name] if name
1431
1556
  end
1432
1557
 
1433
- def util_parser(content)
1558
+ def util_parser content = ''
1434
1559
  RDoc::Parser::C.new @top_level, @fn, content, @options, @stats
1435
1560
  end
1436
1561