rdoc 4.3.0 → 5.0.0.beta1

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 (248) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +13 -0
  3. data/.travis.yml +23 -0
  4. data/CONTRIBUTING.rdoc +4 -3
  5. data/Gemfile +3 -0
  6. data/History.rdoc +15 -4
  7. data/LEGAL.rdoc +2 -2
  8. data/README.rdoc +1 -0
  9. data/Rakefile +41 -79
  10. data/bin/console +7 -0
  11. data/bin/setup +6 -0
  12. data/{bin → exe}/rdoc +0 -0
  13. data/{bin → exe}/ri +0 -0
  14. data/lib/rdoc.rb +2 -1
  15. data/lib/rdoc/alias.rb +1 -0
  16. data/lib/rdoc/anon_class.rb +1 -0
  17. data/lib/rdoc/any_method.rb +1 -0
  18. data/lib/rdoc/attr.rb +1 -0
  19. data/lib/rdoc/class_module.rb +1 -0
  20. data/lib/rdoc/code_object.rb +1 -0
  21. data/lib/rdoc/code_objects.rb +1 -0
  22. data/lib/rdoc/comment.rb +1 -0
  23. data/lib/rdoc/constant.rb +1 -0
  24. data/lib/rdoc/context.rb +4 -1
  25. data/lib/rdoc/context/section.rb +7 -0
  26. data/lib/rdoc/cross_reference.rb +1 -0
  27. data/lib/rdoc/encoding.rb +14 -0
  28. data/lib/rdoc/erb_partial.rb +1 -0
  29. data/lib/rdoc/erbio.rb +1 -0
  30. data/lib/rdoc/extend.rb +1 -0
  31. data/lib/rdoc/generator.rb +1 -0
  32. data/lib/rdoc/generator/darkfish.rb +1 -0
  33. data/lib/rdoc/generator/json_index.rb +1 -0
  34. data/lib/rdoc/generator/markup.rb +1 -0
  35. data/lib/rdoc/generator/pot.rb +1 -0
  36. data/lib/rdoc/generator/pot/message_extractor.rb +1 -0
  37. data/lib/rdoc/generator/pot/po.rb +1 -0
  38. data/lib/rdoc/generator/pot/po_entry.rb +1 -0
  39. data/lib/rdoc/generator/ri.rb +1 -0
  40. data/lib/rdoc/generator/template/darkfish/_head.rhtml +2 -1
  41. data/lib/rdoc/generator/template/darkfish/css/fonts.css +6 -6
  42. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -7
  43. data/lib/rdoc/generator/template/json_index/js/searcher.js +1 -0
  44. data/lib/rdoc/ghost_method.rb +1 -0
  45. data/lib/rdoc/i18n.rb +1 -0
  46. data/lib/rdoc/i18n/locale.rb +1 -0
  47. data/lib/rdoc/i18n/text.rb +1 -0
  48. data/lib/rdoc/include.rb +1 -0
  49. data/lib/rdoc/known_classes.rb +1 -0
  50. data/lib/rdoc/markdown.kpeg +2 -6
  51. data/lib/rdoc/markdown.rb +2 -6
  52. data/lib/rdoc/markdown/entities.rb +1 -0
  53. data/lib/rdoc/markdown/{literals_1_9.kpeg → literals.kpeg} +0 -0
  54. data/lib/rdoc/markdown/{literals_1_9.rb → literals.rb} +1 -4
  55. data/lib/rdoc/markup.rb +1 -0
  56. data/lib/rdoc/markup/attr_changer.rb +1 -0
  57. data/lib/rdoc/markup/attr_span.rb +1 -0
  58. data/lib/rdoc/markup/attribute_manager.rb +1 -0
  59. data/lib/rdoc/markup/attributes.rb +1 -0
  60. data/lib/rdoc/markup/blank_line.rb +1 -0
  61. data/lib/rdoc/markup/block_quote.rb +1 -0
  62. data/lib/rdoc/markup/document.rb +1 -0
  63. data/lib/rdoc/markup/formatter.rb +1 -0
  64. data/lib/rdoc/markup/formatter_test_case.rb +1 -4
  65. data/lib/rdoc/markup/hard_break.rb +1 -0
  66. data/lib/rdoc/markup/heading.rb +1 -0
  67. data/lib/rdoc/markup/include.rb +1 -0
  68. data/lib/rdoc/markup/indented_paragraph.rb +1 -0
  69. data/lib/rdoc/markup/inline.rb +1 -0
  70. data/lib/rdoc/markup/list.rb +1 -0
  71. data/lib/rdoc/markup/list_item.rb +1 -0
  72. data/lib/rdoc/markup/paragraph.rb +1 -0
  73. data/lib/rdoc/markup/parser.rb +1 -0
  74. data/lib/rdoc/markup/pre_process.rb +1 -0
  75. data/lib/rdoc/markup/raw.rb +1 -0
  76. data/lib/rdoc/markup/rule.rb +1 -0
  77. data/lib/rdoc/markup/special.rb +1 -0
  78. data/lib/rdoc/markup/text_formatter_test_case.rb +1 -0
  79. data/lib/rdoc/markup/to_ansi.rb +1 -0
  80. data/lib/rdoc/markup/to_bs.rb +1 -0
  81. data/lib/rdoc/markup/to_html.rb +1 -0
  82. data/lib/rdoc/markup/to_html_crossref.rb +1 -0
  83. data/lib/rdoc/markup/to_html_snippet.rb +1 -0
  84. data/lib/rdoc/markup/to_joined_paragraph.rb +1 -0
  85. data/lib/rdoc/markup/to_label.rb +1 -0
  86. data/lib/rdoc/markup/to_markdown.rb +1 -0
  87. data/lib/rdoc/markup/to_rdoc.rb +1 -0
  88. data/lib/rdoc/markup/to_table_of_contents.rb +1 -0
  89. data/lib/rdoc/markup/to_test.rb +1 -0
  90. data/lib/rdoc/markup/to_tt_only.rb +1 -0
  91. data/lib/rdoc/markup/verbatim.rb +1 -0
  92. data/lib/rdoc/meta_method.rb +1 -0
  93. data/lib/rdoc/method_attr.rb +1 -0
  94. data/lib/rdoc/mixin.rb +1 -0
  95. data/lib/rdoc/normal_class.rb +1 -0
  96. data/lib/rdoc/normal_module.rb +1 -0
  97. data/lib/rdoc/options.rb +1 -0
  98. data/lib/rdoc/parser.rb +1 -0
  99. data/lib/rdoc/parser/c.rb +76 -33
  100. data/lib/rdoc/parser/changelog.rb +7 -1
  101. data/lib/rdoc/parser/markdown.rb +1 -0
  102. data/lib/rdoc/parser/rd.rb +1 -0
  103. data/lib/rdoc/parser/ruby.rb +1 -0
  104. data/lib/rdoc/parser/ruby_tools.rb +1 -0
  105. data/lib/rdoc/parser/simple.rb +1 -0
  106. data/lib/rdoc/parser/text.rb +1 -0
  107. data/lib/rdoc/rd.rb +1 -0
  108. data/lib/rdoc/rd/inline.rb +1 -0
  109. data/lib/rdoc/rdoc.rb +2 -1
  110. data/lib/rdoc/require.rb +1 -0
  111. data/lib/rdoc/ri.rb +1 -0
  112. data/lib/rdoc/ri/driver.rb +5 -19
  113. data/lib/rdoc/ri/formatter.rb +1 -0
  114. data/lib/rdoc/ri/paths.rb +1 -0
  115. data/lib/rdoc/ri/store.rb +1 -0
  116. data/lib/rdoc/ri/task.rb +72 -0
  117. data/lib/rdoc/ruby_lex.rb +11 -17
  118. data/lib/rdoc/ruby_token.rb +1 -0
  119. data/lib/rdoc/rubygems_hook.rb +1 -0
  120. data/lib/rdoc/servlet.rb +4 -3
  121. data/lib/rdoc/single_class.rb +1 -0
  122. data/lib/rdoc/stats.rb +1 -0
  123. data/lib/rdoc/stats/normal.rb +1 -0
  124. data/lib/rdoc/stats/quiet.rb +1 -0
  125. data/lib/rdoc/stats/verbose.rb +1 -0
  126. data/lib/rdoc/store.rb +3 -9
  127. data/lib/rdoc/task.rb +1 -0
  128. data/lib/rdoc/test_case.rb +1 -10
  129. data/lib/rdoc/text.rb +1 -0
  130. data/lib/rdoc/token_stream.rb +1 -0
  131. data/lib/rdoc/tom_doc.rb +1 -0
  132. data/lib/rdoc/top_level.rb +1 -0
  133. data/rdoc.gemspec +60 -0
  134. metadata +32 -155
  135. data/Manifest.txt +0 -309
  136. data/lib/rdoc/markdown/literals_1_8.kpeg +0 -18
  137. data/lib/rdoc/markdown/literals_1_8.rb +0 -416
  138. data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +0 -21
  139. data/test/MarkdownTest_1.0.3/Auto links.text +0 -13
  140. data/test/MarkdownTest_1.0.3/Backslash escapes.text +0 -120
  141. data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +0 -11
  142. data/test/MarkdownTest_1.0.3/Code Blocks.text +0 -14
  143. data/test/MarkdownTest_1.0.3/Code Spans.text +0 -6
  144. data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +0 -8
  145. data/test/MarkdownTest_1.0.3/Horizontal rules.text +0 -67
  146. data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +0 -15
  147. data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +0 -69
  148. data/test/MarkdownTest_1.0.3/Inline HTML comments.text +0 -13
  149. data/test/MarkdownTest_1.0.3/Links, inline style.text +0 -12
  150. data/test/MarkdownTest_1.0.3/Links, reference style.text +0 -71
  151. data/test/MarkdownTest_1.0.3/Links, shortcut references.text +0 -20
  152. data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +0 -7
  153. data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +0 -306
  154. data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +0 -888
  155. data/test/MarkdownTest_1.0.3/Nested blockquotes.text +0 -5
  156. data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +0 -131
  157. data/test/MarkdownTest_1.0.3/Strong and em together.text +0 -7
  158. data/test/MarkdownTest_1.0.3/Tabs.text +0 -21
  159. data/test/MarkdownTest_1.0.3/Tidyness.text +0 -5
  160. data/test/README +0 -1
  161. data/test/binary.dat +0 -0
  162. data/test/hidden.zip.txt +0 -1
  163. data/test/test.ja.largedoc +0 -3
  164. data/test/test.ja.rdoc +0 -10
  165. data/test/test.ja.txt +0 -8
  166. data/test/test.txt +0 -1
  167. data/test/test_rdoc_alias.rb +0 -13
  168. data/test/test_rdoc_any_method.rb +0 -460
  169. data/test/test_rdoc_attr.rb +0 -190
  170. data/test/test_rdoc_class_module.rb +0 -1492
  171. data/test/test_rdoc_code_object.rb +0 -450
  172. data/test/test_rdoc_comment.rb +0 -504
  173. data/test/test_rdoc_constant.rb +0 -181
  174. data/test/test_rdoc_context.rb +0 -901
  175. data/test/test_rdoc_context_section.rb +0 -130
  176. data/test/test_rdoc_cross_reference.rb +0 -192
  177. data/test/test_rdoc_encoding.rb +0 -227
  178. data/test/test_rdoc_extend.rb +0 -94
  179. data/test/test_rdoc_generator_darkfish.rb +0 -229
  180. data/test/test_rdoc_generator_json_index.rb +0 -324
  181. data/test/test_rdoc_generator_markup.rb +0 -59
  182. data/test/test_rdoc_generator_pot.rb +0 -91
  183. data/test/test_rdoc_generator_pot_po.rb +0 -51
  184. data/test/test_rdoc_generator_pot_po_entry.rb +0 -139
  185. data/test/test_rdoc_generator_ri.rb +0 -78
  186. data/test/test_rdoc_i18n_locale.rb +0 -73
  187. data/test/test_rdoc_i18n_text.rb +0 -123
  188. data/test/test_rdoc_include.rb +0 -108
  189. data/test/test_rdoc_markdown.rb +0 -980
  190. data/test/test_rdoc_markdown_test.rb +0 -1884
  191. data/test/test_rdoc_markup.rb +0 -95
  192. data/test/test_rdoc_markup_attribute_manager.rb +0 -364
  193. data/test/test_rdoc_markup_attributes.rb +0 -39
  194. data/test/test_rdoc_markup_document.rb +0 -207
  195. data/test/test_rdoc_markup_formatter.rb +0 -175
  196. data/test/test_rdoc_markup_hard_break.rb +0 -31
  197. data/test/test_rdoc_markup_heading.rb +0 -29
  198. data/test/test_rdoc_markup_include.rb +0 -19
  199. data/test/test_rdoc_markup_indented_paragraph.rb +0 -53
  200. data/test/test_rdoc_markup_paragraph.rb +0 -32
  201. data/test/test_rdoc_markup_parser.rb +0 -1680
  202. data/test/test_rdoc_markup_pre_process.rb +0 -473
  203. data/test/test_rdoc_markup_raw.rb +0 -22
  204. data/test/test_rdoc_markup_to_ansi.rb +0 -369
  205. data/test/test_rdoc_markup_to_bs.rb +0 -366
  206. data/test/test_rdoc_markup_to_html.rb +0 -662
  207. data/test/test_rdoc_markup_to_html_crossref.rb +0 -225
  208. data/test/test_rdoc_markup_to_html_snippet.rb +0 -711
  209. data/test/test_rdoc_markup_to_joined_paragraph.rb +0 -32
  210. data/test/test_rdoc_markup_to_label.rb +0 -112
  211. data/test/test_rdoc_markup_to_markdown.rb +0 -389
  212. data/test/test_rdoc_markup_to_rdoc.rb +0 -377
  213. data/test/test_rdoc_markup_to_table_of_contents.rb +0 -126
  214. data/test/test_rdoc_markup_to_tt_only.rb +0 -246
  215. data/test/test_rdoc_markup_verbatim.rb +0 -29
  216. data/test/test_rdoc_method_attr.rb +0 -193
  217. data/test/test_rdoc_normal_class.rb +0 -47
  218. data/test/test_rdoc_normal_module.rb +0 -42
  219. data/test/test_rdoc_options.rb +0 -766
  220. data/test/test_rdoc_parser.rb +0 -327
  221. data/test/test_rdoc_parser_c.rb +0 -1896
  222. data/test/test_rdoc_parser_changelog.rb +0 -315
  223. data/test/test_rdoc_parser_markdown.rb +0 -61
  224. data/test/test_rdoc_parser_rd.rb +0 -55
  225. data/test/test_rdoc_parser_ruby.rb +0 -3322
  226. data/test/test_rdoc_parser_simple.rb +0 -115
  227. data/test/test_rdoc_rd.rb +0 -30
  228. data/test/test_rdoc_rd_block_parser.rb +0 -535
  229. data/test/test_rdoc_rd_inline.rb +0 -63
  230. data/test/test_rdoc_rd_inline_parser.rb +0 -177
  231. data/test/test_rdoc_rdoc.rb +0 -455
  232. data/test/test_rdoc_require.rb +0 -25
  233. data/test/test_rdoc_ri_driver.rb +0 -1436
  234. data/test/test_rdoc_ri_paths.rb +0 -155
  235. data/test/test_rdoc_ruby_lex.rb +0 -421
  236. data/test/test_rdoc_ruby_token.rb +0 -19
  237. data/test/test_rdoc_rubygems_hook.rb +0 -251
  238. data/test/test_rdoc_servlet.rb +0 -534
  239. data/test/test_rdoc_single_class.rb +0 -20
  240. data/test/test_rdoc_stats.rb +0 -722
  241. data/test/test_rdoc_store.rb +0 -993
  242. data/test/test_rdoc_task.rb +0 -173
  243. data/test/test_rdoc_text.rb +0 -557
  244. data/test/test_rdoc_token_stream.rb +0 -42
  245. data/test/test_rdoc_tom_doc.rb +0 -520
  246. data/test/test_rdoc_top_level.rb +0 -287
  247. data/test/xref_data.rb +0 -76
  248. data/test/xref_test_case.rb +0 -67
@@ -1,25 +0,0 @@
1
- require File.expand_path '../xref_test_case', __FILE__
2
-
3
- class TestRDocRequire < XrefTestCase
4
-
5
- def setup
6
- super
7
-
8
- @req = RDoc::Require.new 'foo', 'comment'
9
- end
10
-
11
- def test_initialize
12
- assert_equal 'foo', @req.name
13
-
14
- req = RDoc::Require.new '"foo"', ''
15
- assert_equal 'foo', @req.name
16
-
17
- req = RDoc::Require.new '\'foo\'', ''
18
- assert_equal 'foo', @req.name
19
-
20
- req = RDoc::Require.new '|foo|', ''
21
- assert_equal 'foo', @req.name, 'for fortran?'
22
- end
23
-
24
- end
25
-
@@ -1,1436 +0,0 @@
1
- require 'rdoc/test_case'
2
-
3
- class TestRDocRIDriver < RDoc::TestCase
4
-
5
- def setup
6
- super
7
-
8
- @tmpdir = File.join Dir.tmpdir, "test_rdoc_ri_driver_#{$$}"
9
- @home_ri = File.join @tmpdir, 'dot_ri'
10
-
11
- FileUtils.mkdir_p @tmpdir
12
- FileUtils.mkdir_p @home_ri
13
-
14
- @orig_ri = ENV['RI']
15
- @orig_home = ENV['HOME']
16
- ENV['HOME'] = @tmpdir
17
- ENV.delete 'RI'
18
-
19
- @options = RDoc::RI::Driver.default_options
20
- @options[:use_system] = false
21
- @options[:use_site] = false
22
- @options[:use_home] = false
23
- @options[:use_gems] = false
24
-
25
- @options[:home] = @tmpdir
26
- @options[:use_stdout] = true
27
- @options[:formatter] = @RM::ToRdoc
28
-
29
- @driver = RDoc::RI::Driver.new @options
30
- end
31
-
32
- def teardown
33
- super
34
-
35
- ENV['HOME'] = @orig_home
36
- ENV['RI'] = @orig_ri
37
- FileUtils.rm_rf @tmpdir
38
- end
39
-
40
- DUMMY_PAGER = ":;\n"
41
-
42
- def with_dummy_pager
43
- pager_env, ENV['RI_PAGER'] = ENV['RI_PAGER'], DUMMY_PAGER
44
- yield
45
- ensure
46
- ENV['RI_PAGER'] = pager_env
47
- end
48
-
49
- def test_self_dump
50
- util_store
51
-
52
- out, = capture_io do
53
- RDoc::RI::Driver.dump @store1.cache_path
54
- end
55
-
56
- assert_match %r%:class_methods%, out
57
- assert_match %r%:modules%, out
58
- assert_match %r%:instance_methods%, out
59
- assert_match %r%:ancestors%, out
60
- end
61
-
62
- def test_add_also_in_empty
63
- out = @RM::Document.new
64
-
65
- @driver.add_also_in out, []
66
-
67
- assert_empty out
68
- end
69
-
70
- def test_add_also_in
71
- util_multi_store
72
- @store1.type = :system
73
- @store2.type = :home
74
-
75
- out = @RM::Document.new
76
-
77
- @driver.add_also_in out, [@store1, @store2]
78
-
79
- expected = @RM::Document.new(
80
- @RM::Rule.new(1),
81
- @RM::Paragraph.new('Also found in:'),
82
- @RM::Verbatim.new("ruby core", "\n",
83
- "~/.rdoc", "\n"))
84
-
85
- assert_equal expected, out
86
- end
87
-
88
- def test_add_class
89
- util_multi_store
90
-
91
- out = @RM::Document.new
92
-
93
- @driver.add_class out, 'Bar', [@cBar]
94
-
95
- expected = @RM::Document.new(
96
- @RM::Heading.new(1, 'Bar < Foo'),
97
- @RM::BlankLine.new)
98
-
99
- assert_equal expected, out
100
- end
101
-
102
- def test_add_from
103
- util_store
104
- @store1.type = :system
105
-
106
- out = @RM::Document.new
107
-
108
- @driver.add_from out, @store1
109
-
110
- expected = @RM::Document.new @RM::Paragraph.new("(from ruby core)")
111
-
112
- assert_equal expected, out
113
- end
114
-
115
- def test_add_extends
116
- util_store
117
-
118
- out = @RM::Document.new
119
-
120
- @driver.add_extends out, [[[@cFooExt], @store1]]
121
-
122
- expected = @RM::Document.new(
123
- @RM::Rule.new(1),
124
- @RM::Heading.new(1, "Extended by:"),
125
- @RM::Paragraph.new("Ext (from #{@store1.friendly_path})"),
126
- @RM::BlankLine.new,
127
- @RM::Paragraph.new("Extend thingy"),
128
- @RM::BlankLine.new)
129
-
130
- assert_equal expected, out
131
- end
132
-
133
- def test_add_extension_modules_empty
134
- out = @RM::Document.new
135
-
136
- @driver.add_extension_modules out, 'Includes', []
137
-
138
- assert_empty out
139
- end
140
-
141
- def test_add_extension_modules_many
142
- util_store
143
-
144
- out = @RM::Document.new
145
-
146
- enum = RDoc::Include.new 'Enumerable', nil
147
- @cFoo.add_include enum
148
-
149
- @driver.add_extension_modules out, 'Includes', [[[@cFooInc, enum], @store1]]
150
-
151
- expected = @RM::Document.new(
152
- @RM::Rule.new(1),
153
- @RM::Heading.new(1, "Includes:"),
154
- @RM::Paragraph.new("(from #{@store1.friendly_path})"),
155
- @RM::BlankLine.new,
156
- @RM::Paragraph.new("Inc"),
157
- @RM::BlankLine.new,
158
- @RM::Paragraph.new("Include thingy"),
159
- @RM::BlankLine.new,
160
- @RM::Verbatim.new("Enumerable", "\n"))
161
-
162
- assert_equal expected, out
163
- end
164
-
165
- def test_add_extension_modules_many_no_doc
166
- util_store
167
-
168
- out = @RM::Document.new
169
-
170
- enum = RDoc::Include.new 'Enumerable', nil
171
- @cFoo.add_include enum
172
- @cFooInc.instance_variable_set :@comment, ''
173
-
174
- @driver.add_extension_modules out, 'Includes', [[[@cFooInc, enum], @store1]]
175
-
176
- expected = @RM::Document.new(
177
- @RM::Rule.new(1),
178
- @RM::Heading.new(1, "Includes:"),
179
- @RM::Paragraph.new("(from #{@store1.friendly_path})"),
180
- @RM::Verbatim.new("Inc", "\n",
181
- "Enumerable", "\n"))
182
-
183
- assert_equal expected, out
184
- end
185
-
186
- def test_add_extension_modules_one
187
- util_store
188
-
189
- out = @RM::Document.new
190
-
191
- @driver.add_extension_modules out, 'Includes', [[[@cFooInc], @store1]]
192
-
193
- expected = @RM::Document.new(
194
- @RM::Rule.new(1),
195
- @RM::Heading.new(1, "Includes:"),
196
- @RM::Paragraph.new("Inc (from #{@store1.friendly_path})"),
197
- @RM::BlankLine.new,
198
- @RM::Paragraph.new("Include thingy"),
199
- @RM::BlankLine.new)
200
-
201
- assert_equal expected, out
202
- end
203
-
204
- def test_add_includes
205
- util_store
206
-
207
- out = @RM::Document.new
208
-
209
- @driver.add_includes out, [[[@cFooInc], @store1]]
210
-
211
- expected = @RM::Document.new(
212
- @RM::Rule.new(1),
213
- @RM::Heading.new(1, "Includes:"),
214
- @RM::Paragraph.new("Inc (from #{@store1.friendly_path})"),
215
- @RM::BlankLine.new,
216
- @RM::Paragraph.new("Include thingy"),
217
- @RM::BlankLine.new)
218
-
219
- assert_equal expected, out
220
- end
221
-
222
- def test_add_method
223
- util_store
224
-
225
- out = doc
226
-
227
- @driver.add_method out, 'Foo::Bar#blah'
228
-
229
- expected =
230
- doc(
231
- head(1, 'Foo::Bar#blah'),
232
- blank_line,
233
- para('(from ~/.rdoc)'),
234
- head(3, 'Implementation from Bar'),
235
- rule(1),
236
- verb("blah(5) => 5\n",
237
- "blah(6) => 6\n"),
238
- rule(1),
239
- blank_line,
240
- blank_line)
241
-
242
- assert_equal expected, out
243
- end
244
-
245
- def test_add_method_attribute
246
- util_store
247
-
248
- out = doc
249
-
250
- @driver.add_method out, 'Foo::Bar#attr'
251
-
252
- expected =
253
- doc(
254
- head(1, 'Foo::Bar#attr'),
255
- blank_line,
256
- para('(from ~/.rdoc)'),
257
- rule(1),
258
- blank_line,
259
- blank_line)
260
-
261
- assert_equal expected, out
262
- end
263
-
264
- def test_add_method_inherited
265
- util_multi_store
266
-
267
- out = doc
268
-
269
- @driver.add_method out, 'Bar#inherit'
270
-
271
- expected =
272
- doc(
273
- head(1, 'Bar#inherit'),
274
- blank_line,
275
- para('(from ~/.rdoc)'),
276
- head(3, 'Implementation from Foo'),
277
- rule(1),
278
- blank_line,
279
- blank_line)
280
-
281
- assert_equal expected, out
282
- end
283
-
284
- def test_add_method_overriden
285
- util_multi_store
286
-
287
- out = doc
288
-
289
- @driver.add_method out, 'Bar#override'
290
-
291
- expected =
292
- doc(
293
- head(1, 'Bar#override'),
294
- blank_line,
295
- para("(from #{@store2.path})"),
296
- rule(1),
297
- blank_line,
298
- para('must be displayed'),
299
- blank_line,
300
- blank_line)
301
-
302
- assert_equal expected, out
303
- end
304
-
305
- def test_add_method_documentation
306
- util_store
307
-
308
- out = doc()
309
-
310
- missing = RDoc::AnyMethod.new nil, 'missing'
311
- @cFoo.add_method missing
312
-
313
- @driver.add_method_documentation out, @cFoo
314
-
315
- expected =
316
- doc(
317
- head(1, 'Foo#inherit'),
318
- blank_line,
319
- para('(from ~/.rdoc)'),
320
- rule(1),
321
- blank_line,
322
- blank_line,
323
- head(1, 'Foo#override'),
324
- blank_line,
325
- para('(from ~/.rdoc)'),
326
- rule(1),
327
- blank_line,
328
- para('must not be displayed in Bar#override'),
329
- blank_line,
330
- blank_line)
331
-
332
- assert_equal expected, out
333
- end
334
-
335
- def test_add_method_list
336
- out = @RM::Document.new
337
-
338
- @driver.add_method_list out, %w[new parse], 'Class methods'
339
-
340
- expected = @RM::Document.new(
341
- @RM::Heading.new(1, 'Class methods:'),
342
- @RM::BlankLine.new,
343
- @RM::Verbatim.new('new'),
344
- @RM::Verbatim.new('parse'),
345
- @RM::BlankLine.new)
346
-
347
- assert_equal expected, out
348
- end
349
-
350
- def test_add_method_list_interative
351
- @options[:interactive] = true
352
- driver = RDoc::RI::Driver.new @options
353
-
354
- out = @RM::Document.new
355
-
356
- driver.add_method_list out, %w[new parse], 'Class methods'
357
-
358
- expected = @RM::Document.new(
359
- @RM::Heading.new(1, 'Class methods:'),
360
- @RM::BlankLine.new,
361
- @RM::IndentedParagraph.new(2, 'new, parse'),
362
- @RM::BlankLine.new)
363
-
364
- assert_equal expected, out
365
- end
366
-
367
- def test_add_method_list_none
368
- out = @RM::Document.new
369
-
370
- @driver.add_method_list out, [], 'Class'
371
-
372
- assert_equal @RM::Document.new, out
373
- end
374
-
375
- def test_ancestors_of
376
- util_ancestors_store
377
-
378
- assert_equal %w[X Mixin Object Foo], @driver.ancestors_of('Foo::Bar')
379
- end
380
-
381
- def test_classes
382
- util_multi_store
383
-
384
- expected = {
385
- 'Ambiguous' => [@store1, @store2],
386
- 'Bar' => [@store2],
387
- 'Ext' => [@store1],
388
- 'Foo' => [@store1, @store2],
389
- 'Foo::Bar' => [@store1],
390
- 'Foo::Baz' => [@store1, @store2],
391
- 'Inc' => [@store1],
392
- }
393
-
394
- classes = @driver.classes
395
-
396
- assert_equal expected.keys.sort, classes.keys.sort
397
-
398
- expected.each do |klass, stores|
399
- assert_equal stores, classes[klass].sort_by { |store| store.path },
400
- "mismatch for #{klass}"
401
- end
402
- end
403
-
404
- def test_class_document
405
- util_store
406
-
407
- tl1 = @store1.add_file 'one.rb'
408
- tl2 = @store1.add_file 'two.rb'
409
-
410
- @cFoo.add_comment 'one', tl1
411
- @cFoo.add_comment 'two', tl2
412
-
413
- @store1.save_class @cFoo
414
-
415
- found = [
416
- [@store1, @store1.load_class(@cFoo.full_name)]
417
- ]
418
-
419
- extends = [[[@cFooExt], @store1]]
420
- includes = [[[@cFooInc], @store1]]
421
-
422
- out = @driver.class_document @cFoo.full_name, found, [], includes, extends
423
-
424
- expected = @RM::Document.new
425
- @driver.add_class expected, 'Foo', []
426
- @driver.add_includes expected, includes
427
- @driver.add_extends expected, extends
428
- @driver.add_from expected, @store1
429
- expected << @RM::Rule.new(1)
430
-
431
- doc = @RM::Document.new(@RM::Paragraph.new('one'))
432
- doc.file = 'one.rb'
433
- expected.push doc
434
- expected << @RM::BlankLine.new
435
- doc = @RM::Document.new(@RM::Paragraph.new('two'))
436
- doc.file = 'two.rb'
437
- expected.push doc
438
-
439
- expected << @RM::Rule.new(1)
440
- expected << @RM::Heading.new(1, 'Instance methods:')
441
- expected << @RM::BlankLine.new
442
- expected << @RM::Verbatim.new('inherit')
443
- expected << @RM::Verbatim.new('override')
444
- expected << @RM::BlankLine.new
445
-
446
- assert_equal expected, out
447
- end
448
-
449
- def test_complete
450
- store = RDoc::RI::Store.new @home_ri
451
- store.cache[:ancestors] = {
452
- 'Foo' => %w[Object],
453
- 'Foo::Bar' => %w[Object],
454
- }
455
- store.cache[:class_methods] = {
456
- 'Foo' => %w[bar]
457
- }
458
- store.cache[:instance_methods] = {
459
- 'Foo' => %w[Bar]
460
- }
461
- store.cache[:modules] = %w[
462
- Foo
463
- Foo::Bar
464
- ]
465
-
466
- @driver.stores = [store]
467
-
468
- assert_equal %w[Foo ], @driver.complete('F')
469
- assert_equal %w[ Foo::Bar], @driver.complete('Foo::B')
470
-
471
- assert_equal %w[Foo#Bar], @driver.complete('Foo#'), 'Foo#'
472
- assert_equal %w[Foo#Bar Foo::bar], @driver.complete('Foo.'), 'Foo.'
473
- assert_equal %w[Foo::Bar Foo::bar], @driver.complete('Foo::'), 'Foo::'
474
-
475
- assert_equal %w[ Foo::bar], @driver.complete('Foo::b'), 'Foo::b'
476
- end
477
-
478
- def test_complete_ancestor
479
- util_ancestors_store
480
-
481
- assert_equal %w[Foo::Bar#i_method], @driver.complete('Foo::Bar#')
482
-
483
- assert_equal %w[Foo::Bar#i_method Foo::Bar::c_method Foo::Bar::new],
484
- @driver.complete('Foo::Bar.')
485
- end
486
-
487
- def test_complete_classes
488
- util_store
489
-
490
- assert_equal %w[ ], @driver.complete('[')
491
- assert_equal %w[ ], @driver.complete('[::')
492
- assert_equal %w[Foo ], @driver.complete('F')
493
- assert_equal %w[Foo:: Foo::Bar Foo::Baz], @driver.complete('Foo::')
494
- assert_equal %w[ Foo::Bar Foo::Baz], @driver.complete('Foo::B')
495
- end
496
-
497
- def test_complete_multistore
498
- util_multi_store
499
-
500
- assert_equal %w[Bar], @driver.complete('B')
501
- assert_equal %w[Foo], @driver.complete('F')
502
- assert_equal %w[Foo::Bar Foo::Baz], @driver.complete('Foo::B')
503
- end
504
-
505
- def test_display
506
- doc = @RM::Document.new(
507
- @RM::Paragraph.new('hi'))
508
-
509
- out, = capture_io do
510
- @driver.display doc
511
- end
512
-
513
- assert_equal "hi\n", out
514
- end
515
-
516
- def test_display_class
517
- util_store
518
-
519
- out, = capture_io do
520
- @driver.display_class 'Foo::Bar'
521
- end
522
-
523
- assert_match %r%^= Foo::Bar%, out
524
- assert_match %r%^\(from%, out
525
-
526
- assert_match %r%^= Class methods:%, out
527
- assert_match %r%^ new%, out
528
- assert_match %r%^= Instance methods:%, out
529
- assert_match %r%^ blah%, out
530
- assert_match %r%^= Attributes:%, out
531
- assert_match %r%^ attr_accessor attr%, out
532
-
533
- assert_equal 1, out.scan(/-\n/).length
534
-
535
- refute_match %r%Foo::Bar#blah%, out
536
- end
537
-
538
- def test_display_class_all
539
- util_store
540
-
541
- @driver.show_all = true
542
-
543
- out, = capture_io do
544
- @driver.display_class 'Foo::Bar'
545
- end
546
-
547
- assert_match %r%^= Foo::Bar%, out
548
- assert_match %r%^\(from%, out
549
-
550
- assert_match %r%^= Class methods:%, out
551
- assert_match %r%^ new%, out
552
- assert_match %r%^= Instance methods:%, out
553
- assert_match %r%^ blah%, out
554
- assert_match %r%^= Attributes:%, out
555
- assert_match %r%^ attr_accessor attr%, out
556
-
557
- assert_equal 6, out.scan(/-\n/).length
558
-
559
- assert_match %r%Foo::Bar#blah%, out
560
- end
561
-
562
- def test_display_class_ambiguous
563
- util_multi_store
564
-
565
- out, = capture_io do
566
- @driver.display_class 'Ambiguous'
567
- end
568
-
569
- assert_match %r%^= Ambiguous < Object$%, out
570
- end
571
-
572
- def test_display_class_multi_no_doc
573
- util_multi_store
574
-
575
- out, = capture_io do
576
- @driver.display_class 'Foo::Baz'
577
- end
578
-
579
- assert_match %r%^= Foo::Baz%, out
580
- assert_match %r%-\n%, out
581
- assert_match %r%Also found in:%, out
582
- assert_match %r%#{Regexp.escape @home_ri}%, out
583
- assert_match %r%#{Regexp.escape @home_ri2}%, out
584
- end
585
-
586
- def test_display_class_superclass
587
- util_multi_store
588
-
589
- out, = capture_io do
590
- @driver.display_class 'Bar'
591
- end
592
-
593
- assert_match %r%^= Bar < Foo%, out
594
- end
595
-
596
- def test_display_class_module
597
- util_store
598
-
599
- out, = capture_io do
600
- @driver.display_class 'Inc'
601
- end
602
-
603
- assert_match %r%^= Inc$%, out
604
- end
605
-
606
- def test_display_class_page
607
- out, = capture_io do
608
- @driver.display_class 'ruby:README'
609
- end
610
-
611
- assert_empty out
612
- end
613
-
614
- def test_display_method
615
- util_store
616
-
617
- out, = capture_io do
618
- @driver.display_method 'Foo::Bar#blah'
619
- end
620
-
621
- assert_match %r%Foo::Bar#blah%, out
622
- assert_match %r%blah.5%, out
623
- assert_match %r%blah.6%, out
624
- end
625
-
626
- def test_display_method_attribute
627
- util_store
628
-
629
- out, = capture_io do
630
- @driver.display_method 'Foo::Bar#attr'
631
- end
632
-
633
- assert_match %r%Foo::Bar#attr%, out
634
- refute_match %r%Implementation from%, out
635
- end
636
-
637
- def test_display_method_inherited
638
- util_multi_store
639
-
640
- out, = capture_io do
641
- @driver.display_method 'Bar#inherit'
642
- end
643
-
644
- assert_match %r%^= Bar#inherit%, out
645
- assert_match %r%^=== Implementation from Foo%, out
646
- end
647
-
648
- def test_display_method_overriden
649
- util_multi_store
650
-
651
- out, = capture_io do
652
- @driver.display_method 'Bar#override'
653
- end
654
-
655
- refute_match %r%must not be displayed%, out
656
- end
657
-
658
- def test_display_name_not_found_class
659
- util_store
660
-
661
- out, = capture_io do
662
- assert_equal false, @driver.display_name('Foo::B')
663
- end
664
-
665
- expected = <<-EXPECTED
666
- Foo::B not found, maybe you meant:
667
-
668
- Foo::Bar
669
- Foo::Baz
670
- EXPECTED
671
-
672
- assert_equal expected, out
673
- end
674
-
675
- def test_display_name_not_found_method
676
- util_store
677
-
678
- out, = capture_io do
679
- assert_equal false, @driver.display_name('Foo::Bar#b')
680
- end
681
-
682
- expected = <<-EXPECTED
683
- Foo::Bar#b not found, maybe you meant:
684
-
685
- Foo::Bar#blah
686
- Foo::Bar#bother
687
- EXPECTED
688
-
689
- assert_equal expected, out
690
- end
691
-
692
- def test_display_name_not_found_special
693
- util_store
694
-
695
- assert_raises RDoc::RI::Driver::NotFoundError do
696
- assert_equal false, @driver.display_name('Set#[]')
697
- end
698
- end
699
-
700
- def test_display_method_params
701
- util_store
702
-
703
- out, = capture_io do
704
- @driver.display_method 'Foo::Bar#bother'
705
- end
706
-
707
- assert_match %r%things.*stuff%, out
708
- end
709
-
710
- def test_display_page
711
- util_store
712
-
713
- out, = capture_io do
714
- @driver.display_page 'home:README.rdoc'
715
- end
716
-
717
- assert_match %r%= README%, out
718
- end
719
-
720
- def test_display_page_add_extension
721
- util_store
722
-
723
- out, = capture_io do
724
- @driver.display_page 'home:README'
725
- end
726
-
727
- assert_match %r%= README%, out
728
- end
729
-
730
- def test_display_page_ambiguous
731
- util_store
732
-
733
- other = @store1.add_file 'README.md'
734
- other.parser = RDoc::Parser::Simple
735
- other.comment =
736
- doc(
737
- head(1, 'README.md'),
738
- para('This is the other README'))
739
-
740
- @store1.save_page other
741
-
742
- out, = capture_io do
743
- @driver.display_page 'home:README'
744
- end
745
-
746
- assert_match %r%= README pages in ~/\.rdoc%, out
747
- assert_match %r%README\.rdoc%, out
748
- assert_match %r%README\.md%, out
749
- end
750
-
751
- def test_display_page_extension
752
- util_store
753
-
754
- other = @store1.add_file 'README.EXT'
755
- other.parser = RDoc::Parser::Simple
756
- other.comment =
757
- doc(
758
- head(1, 'README.EXT'),
759
- para('This is the other README'))
760
-
761
- @store1.save_page other
762
-
763
- out, = capture_io do
764
- @driver.display_page 'home:README.EXT'
765
- end
766
-
767
- assert_match 'other README', out
768
- end
769
-
770
- def test_display_page_ignore_directory
771
- util_store
772
-
773
- other = @store1.add_file 'doc/globals.rdoc'
774
- other.parser = RDoc::Parser::Simple
775
- other.comment =
776
- doc(
777
- head(1, 'globals.rdoc'),
778
- para('Globals go here'))
779
-
780
- @store1.save_page other
781
-
782
- out, = capture_io do
783
- @driver.display_page 'home:globals'
784
- end
785
-
786
- assert_match %r%= globals\.rdoc%, out
787
- end
788
-
789
- def test_display_page_missing
790
- util_store
791
-
792
- out, = capture_io do
793
- @driver.display_page 'home:missing'
794
- end
795
-
796
- out, = capture_io do
797
- @driver.display_page_list @store1
798
- end
799
-
800
- assert_match %r%= Pages in ~/\.rdoc%, out
801
- assert_match %r%README\.rdoc%, out
802
- end
803
-
804
- def test_display_page_list
805
- util_store
806
-
807
- other = @store1.add_file 'OTHER.rdoc'
808
- other.parser = RDoc::Parser::Simple
809
- other.comment =
810
- doc(
811
- head(1, 'OTHER'),
812
- para('This is OTHER'))
813
-
814
- @store1.save_page other
815
-
816
- out, = capture_io do
817
- @driver.display_page_list @store1
818
- end
819
-
820
- assert_match %r%= Pages in ~/\.rdoc%, out
821
- assert_match %r%README\.rdoc%, out
822
- assert_match %r%OTHER\.rdoc%, out
823
- end
824
-
825
- def test_expand_class
826
- util_store
827
-
828
- assert_equal 'Foo', @driver.expand_class('F')
829
- assert_equal 'Foo::Bar', @driver.expand_class('F::Bar')
830
-
831
- assert_raises RDoc::RI::Driver::NotFoundError do
832
- @driver.expand_class 'F::B'
833
- end
834
- end
835
-
836
- def test_expand_name
837
- util_store
838
-
839
- assert_equal '.b', @driver.expand_name('b')
840
- assert_equal 'Foo', @driver.expand_name('F')
841
- assert_equal 'Foo::Bar#', @driver.expand_name('F::Bar#')
842
-
843
- e = assert_raises RDoc::RI::Driver::NotFoundError do
844
- @driver.expand_name 'Z'
845
- end
846
-
847
- assert_equal 'Z', e.name
848
-
849
- @driver.stores << RDoc::Store.new(nil, :system)
850
-
851
- assert_equal 'ruby:README', @driver.expand_name('ruby:README')
852
- assert_equal 'ruby:', @driver.expand_name('ruby:')
853
-
854
- e = assert_raises RDoc::RI::Driver::NotFoundError do
855
- @driver.expand_name 'nonexistent_gem:'
856
- end
857
-
858
- assert_equal 'nonexistent_gem', e.name
859
- end
860
-
861
- def test_find_methods
862
- util_store
863
-
864
- items = []
865
-
866
- @driver.find_methods 'Foo::Bar.' do |store, klass, ancestor, types, method|
867
- items << [store, klass, ancestor, types, method]
868
- end
869
-
870
- expected = [
871
- [@store1, 'Foo::Bar', 'Foo::Bar', :both, nil],
872
- ]
873
-
874
- assert_equal expected, items
875
- end
876
-
877
- def test_find_methods_method
878
- util_store
879
-
880
- items = []
881
-
882
- @driver.find_methods '.blah' do |store, klass, ancestor, types, method|
883
- items << [store, klass, ancestor, types, method]
884
- end
885
-
886
- expected = [
887
- [@store1, 'Ambiguous', 'Ambiguous', :both, 'blah'],
888
- [@store1, 'Ext', 'Ext', :both, 'blah'],
889
- [@store1, 'Foo', 'Foo', :both, 'blah'],
890
- [@store1, 'Foo::Bar', 'Foo::Bar', :both, 'blah'],
891
- [@store1, 'Foo::Baz', 'Foo::Baz', :both, 'blah'],
892
- [@store1, 'Inc', 'Inc', :both, 'blah'],
893
- ]
894
-
895
- assert_equal expected, items
896
- end
897
-
898
- def test_filter_methods
899
- util_multi_store
900
-
901
- name = 'Bar#override'
902
-
903
- found = @driver.load_methods_matching name
904
-
905
- sorted = @driver.filter_methods found, name
906
-
907
- expected = [[@store2, [@override]]]
908
-
909
- assert_equal expected, sorted
910
- end
911
-
912
- def test_filter_methods_not_found
913
- util_multi_store
914
-
915
- name = 'Bar#inherit'
916
-
917
- found = @driver.load_methods_matching name
918
-
919
- sorted = @driver.filter_methods found, name
920
-
921
- assert_equal found, sorted
922
- end
923
-
924
- def test_find_store
925
- @driver.stores << RDoc::Store.new(nil, :system)
926
- @driver.stores << RDoc::Store.new('doc/gem-1.0/ri', :gem)
927
-
928
- assert_equal 'ruby', @driver.find_store('ruby')
929
- assert_equal 'gem-1.0', @driver.find_store('gem-1.0')
930
- assert_equal 'gem-1.0', @driver.find_store('gem')
931
-
932
- e = assert_raises RDoc::RI::Driver::NotFoundError do
933
- @driver.find_store 'nonexistent'
934
- end
935
-
936
- assert_equal 'nonexistent', e.name
937
- end
938
-
939
- def test_formatter
940
- tty = Object.new
941
- def tty.tty?() true; end
942
-
943
- @options.delete :use_stdout
944
- @options.delete :formatter
945
-
946
- driver = RDoc::RI::Driver.new @options
947
-
948
- assert_instance_of @RM::ToAnsi, driver.formatter(tty)
949
-
950
- assert_instance_of @RM::ToBs, driver.formatter(StringIO.new)
951
-
952
- driver.instance_variable_set :@paging, true
953
-
954
- assert_instance_of @RM::ToBs, driver.formatter(StringIO.new)
955
- end
956
-
957
- def test_in_path_eh
958
- path = ENV['PATH']
959
-
960
- test_path = File.expand_path '..', __FILE__
961
-
962
- temp_dir do |dir|
963
- nonexistent = File.join dir, 'nonexistent'
964
- refute @driver.in_path?(nonexistent)
965
-
966
- ENV['PATH'] = test_path
967
-
968
- assert @driver.in_path?(File.basename(__FILE__))
969
- end
970
- ensure
971
- ENV['PATH'] = path
972
- end
973
-
974
- def test_method_type
975
- assert_equal :both, @driver.method_type(nil)
976
- assert_equal :both, @driver.method_type('.')
977
- assert_equal :instance, @driver.method_type('#')
978
- assert_equal :class, @driver.method_type('::')
979
- end
980
-
981
- def test_name_regexp
982
- assert_equal %r%^RDoc::AnyMethod#new$%,
983
- @driver.name_regexp('RDoc::AnyMethod#new')
984
-
985
- assert_equal %r%^RDoc::AnyMethod::new$%,
986
- @driver.name_regexp('RDoc::AnyMethod::new')
987
-
988
- assert_equal %r%^RDoc::AnyMethod(#|::)new$%,
989
- @driver.name_regexp('RDoc::AnyMethod.new')
990
-
991
- assert_equal %r%^Hash(#|::)\[\]$%,
992
- @driver.name_regexp('Hash.[]')
993
-
994
- assert_equal %r%^Hash::\[\]$%,
995
- @driver.name_regexp('Hash::[]')
996
- end
997
-
998
- def test_list_known_classes
999
- util_store
1000
-
1001
- out, = capture_io do
1002
- @driver.list_known_classes
1003
- end
1004
-
1005
- assert_equal "Ambiguous\nExt\nFoo\nFoo::Bar\nFoo::Baz\nInc\n", out
1006
- end
1007
-
1008
- def test_list_known_classes_name
1009
- util_store
1010
-
1011
- out, = capture_io do
1012
- @driver.list_known_classes %w[F I]
1013
- end
1014
-
1015
- assert_equal "Foo\nFoo::Bar\nFoo::Baz\nInc\n", out
1016
- end
1017
-
1018
- def test_list_methods_matching
1019
- util_store
1020
-
1021
- assert_equal %w[
1022
- Foo::Bar#attr
1023
- Foo::Bar#blah
1024
- Foo::Bar#bother
1025
- Foo::Bar::new
1026
- ],
1027
- @driver.list_methods_matching('Foo::Bar.').sort
1028
- end
1029
-
1030
- def test_list_methods_matching_inherit
1031
- util_multi_store
1032
-
1033
- assert_equal %w[
1034
- Bar#baz
1035
- Bar#inherit
1036
- Bar#override
1037
- ],
1038
- @driver.list_methods_matching('Bar.').sort
1039
- end
1040
-
1041
- def test_list_methods_matching_regexp
1042
- util_store
1043
-
1044
- index = RDoc::AnyMethod.new nil, '[]'
1045
- index.record_location @top_level
1046
- @cFoo.add_method index
1047
- @store1.save_method @cFoo, index
1048
-
1049
- c_index = RDoc::AnyMethod.new nil, '[]'
1050
- c_index.singleton = true
1051
- c_index.record_location @top_level
1052
- @cFoo.add_method c_index
1053
- @store1.save_method @cFoo, c_index
1054
-
1055
- @store1.save_cache
1056
-
1057
- assert_equal %w[Foo#[]], @driver.list_methods_matching('Foo#[]')
1058
- assert_equal %w[Foo::[]], @driver.list_methods_matching('Foo::[]')
1059
- end
1060
-
1061
- def test_load_method
1062
- util_store
1063
-
1064
- method = @driver.load_method(@store1, :instance_methods, 'Foo', '#',
1065
- 'inherit')
1066
-
1067
- assert_equal @inherit, method
1068
- end
1069
-
1070
- def test_load_method_inherited
1071
- util_multi_store
1072
-
1073
- method = @driver.load_method(@store2, :instance_methods, 'Bar', '#',
1074
- 'inherit')
1075
-
1076
- assert_equal nil, method
1077
- end
1078
-
1079
- def test_load_methods_matching
1080
- util_store
1081
-
1082
- expected = [[@store1, [@inherit]]]
1083
-
1084
- assert_equal expected, @driver.load_methods_matching('Foo#inherit')
1085
-
1086
- expected = [[@store1, [@blah]]]
1087
-
1088
- assert_equal expected, @driver.load_methods_matching('.blah')
1089
-
1090
- assert_empty @driver.load_methods_matching('.b')
1091
- end
1092
-
1093
- def test_load_methods_matching_inherited
1094
- util_multi_store
1095
-
1096
- expected = [[@store1, [@inherit]]]
1097
-
1098
- assert_equal expected, @driver.load_methods_matching('Bar#inherit')
1099
- end
1100
-
1101
- def test_load_method_missing
1102
- util_store
1103
-
1104
- FileUtils.rm @store1.method_file 'Foo', '#inherit'
1105
-
1106
- method = @driver.load_method(@store1, :instance_methods, 'Foo', '#',
1107
- 'inherit')
1108
-
1109
- assert_equal '(unknown)#inherit', method.full_name
1110
- end
1111
-
1112
- def _test_page # this test doesn't do anything anymore :(
1113
- @driver.use_stdout = false
1114
-
1115
- with_dummy_pager do
1116
- @driver.page do |io|
1117
- skip "couldn't find a standard pager" if io == $stdout
1118
-
1119
- assert @driver.paging?
1120
- end
1121
- end
1122
-
1123
- refute @driver.paging?
1124
- end
1125
-
1126
- # this test is too fragile. Perhaps using Process.spawn will make this
1127
- # reliable
1128
- def _test_page_in_presence_of_child_status
1129
- skip 'this test hangs on travis-ci.org' if ENV['CI']
1130
- @driver.use_stdout = false
1131
-
1132
- with_dummy_pager do
1133
- @driver.page do |io|
1134
- refute_equal $stdout, io
1135
- assert @driver.paging?
1136
- end
1137
- end
1138
- end
1139
-
1140
- def test_page_stdout
1141
- @driver.use_stdout = true
1142
-
1143
- @driver.page do |io|
1144
- assert_equal $stdout, io
1145
- end
1146
-
1147
- refute @driver.paging?
1148
- end
1149
-
1150
- def test_parse_name_method
1151
- klass, type, meth = @driver.parse_name 'foo'
1152
-
1153
- assert_equal '', klass, 'foo class'
1154
- assert_equal '.', type, 'foo type'
1155
- assert_equal 'foo', meth, 'foo method'
1156
-
1157
- klass, type, meth = @driver.parse_name '#foo'
1158
-
1159
- assert_equal '', klass, '#foo class'
1160
- assert_equal '#', type, '#foo type'
1161
- assert_equal 'foo', meth, '#foo method'
1162
-
1163
- klass, type, meth = @driver.parse_name '::foo'
1164
-
1165
- assert_equal '', klass, '::foo class'
1166
- assert_equal '::', type, '::foo type'
1167
- assert_equal 'foo', meth, '::foo method'
1168
- end
1169
-
1170
- def test_parse_name_page
1171
- klass, type, meth = @driver.parse_name 'ruby:README'
1172
-
1173
- assert_equal 'ruby', klass, 'ruby project'
1174
- assert_equal ':', type, 'ruby type'
1175
- assert_equal 'README', meth, 'ruby page'
1176
-
1177
- klass, type, meth = @driver.parse_name 'ruby:'
1178
-
1179
- assert_equal 'ruby', klass, 'ruby project'
1180
- assert_equal ':', type, 'ruby type'
1181
- assert_equal nil, meth, 'ruby page'
1182
- end
1183
-
1184
- def test_parse_name_page_extenson
1185
- klass, type, meth = @driver.parse_name 'ruby:README.EXT'
1186
-
1187
- assert_equal 'ruby', klass, 'ruby project'
1188
- assert_equal ':', type, 'ruby type'
1189
- assert_equal 'README.EXT', meth, 'ruby page'
1190
- end
1191
-
1192
- def test_parse_name_single_class
1193
- klass, type, meth = @driver.parse_name 'Foo'
1194
-
1195
- assert_equal 'Foo', klass, 'Foo class'
1196
- assert_equal nil, type, 'Foo type'
1197
- assert_equal nil, meth, 'Foo method'
1198
-
1199
- klass, type, meth = @driver.parse_name 'Foo#'
1200
-
1201
- assert_equal 'Foo', klass, 'Foo# class'
1202
- assert_equal '#', type, 'Foo# type'
1203
- assert_equal nil, meth, 'Foo# method'
1204
-
1205
- klass, type, meth = @driver.parse_name 'Foo::'
1206
-
1207
- assert_equal 'Foo', klass, 'Foo:: class'
1208
- assert_equal '::', type, 'Foo:: type'
1209
- assert_equal nil, meth, 'Foo:: method'
1210
-
1211
- klass, type, meth = @driver.parse_name 'Foo.'
1212
-
1213
- assert_equal 'Foo', klass, 'Foo. class'
1214
- assert_equal '.', type, 'Foo. type'
1215
- assert_equal nil, meth, 'Foo. method'
1216
-
1217
- klass, type, meth = @driver.parse_name 'Foo#Bar'
1218
-
1219
- assert_equal 'Foo', klass, 'Foo#Bar class'
1220
- assert_equal '#', type, 'Foo#Bar type'
1221
- assert_equal 'Bar', meth, 'Foo#Bar method'
1222
-
1223
- klass, type, meth = @driver.parse_name 'Foo.Bar'
1224
-
1225
- assert_equal 'Foo', klass, 'Foo.Bar class'
1226
- assert_equal '.', type, 'Foo.Bar type'
1227
- assert_equal 'Bar', meth, 'Foo.Bar method'
1228
-
1229
- klass, type, meth = @driver.parse_name 'Foo::bar'
1230
-
1231
- assert_equal 'Foo', klass, 'Foo::bar class'
1232
- assert_equal '::', type, 'Foo::bar type'
1233
- assert_equal 'bar', meth, 'Foo::bar method'
1234
- end
1235
-
1236
- def test_parse_name_namespace
1237
- klass, type, meth = @driver.parse_name 'Foo::Bar'
1238
-
1239
- assert_equal 'Foo::Bar', klass, 'Foo::Bar class'
1240
- assert_equal nil, type, 'Foo::Bar type'
1241
- assert_equal nil, meth, 'Foo::Bar method'
1242
-
1243
- klass, type, meth = @driver.parse_name 'Foo::Bar#'
1244
-
1245
- assert_equal 'Foo::Bar', klass, 'Foo::Bar# class'
1246
- assert_equal '#', type, 'Foo::Bar# type'
1247
- assert_equal nil, meth, 'Foo::Bar# method'
1248
-
1249
- klass, type, meth = @driver.parse_name 'Foo::Bar#baz'
1250
-
1251
- assert_equal 'Foo::Bar', klass, 'Foo::Bar#baz class'
1252
- assert_equal '#', type, 'Foo::Bar#baz type'
1253
- assert_equal 'baz', meth, 'Foo::Bar#baz method'
1254
- end
1255
-
1256
- def test_parse_name_special
1257
- specials = %w[
1258
- %
1259
- &
1260
- *
1261
- +
1262
- +@
1263
- -
1264
- -@
1265
- /
1266
- <
1267
- <<
1268
- <=
1269
- <=>
1270
- ==
1271
- ===
1272
- =>
1273
- =~
1274
- >
1275
- >>
1276
- []
1277
- []=
1278
- ^
1279
- `
1280
- |
1281
- ~
1282
- ~@
1283
- ]
1284
-
1285
- specials.each do |special|
1286
- parsed = @driver.parse_name special
1287
-
1288
- assert_equal ['', '.', special], parsed
1289
- end
1290
- end
1291
-
1292
- def _test_setup_pager # this test doesn't do anything anymore :(
1293
- @driver.use_stdout = false
1294
-
1295
- pager = with_dummy_pager do @driver.setup_pager end
1296
-
1297
- skip "couldn't find a standard pager" unless pager
1298
-
1299
- assert @driver.paging?
1300
- ensure
1301
- pager.close if pager
1302
- end
1303
-
1304
- def util_ancestors_store
1305
- store1 = RDoc::RI::Store.new @home_ri
1306
- store1.cache[:ancestors] = {
1307
- 'Foo' => %w[Object],
1308
- 'Foo::Bar' => %w[Foo],
1309
- }
1310
- store1.cache[:class_methods] = {
1311
- 'Foo' => %w[c_method new],
1312
- 'Foo::Bar' => %w[new],
1313
- }
1314
- store1.cache[:instance_methods] = {
1315
- 'Foo' => %w[i_method],
1316
- }
1317
- store1.cache[:modules] = %w[
1318
- Foo
1319
- Foo::Bar
1320
- ]
1321
-
1322
- store2 = RDoc::RI::Store.new @home_ri
1323
- store2.cache[:ancestors] = {
1324
- 'Foo' => %w[Mixin Object],
1325
- 'Mixin' => %w[],
1326
- 'Object' => %w[X Object],
1327
- 'X' => %w[Object],
1328
- }
1329
- store2.cache[:class_methods] = {
1330
- 'Foo' => %w[c_method new],
1331
- 'Mixin' => %w[],
1332
- 'X' => %w[],
1333
- 'Object' => %w[],
1334
- }
1335
- store2.cache[:instance_methods] = {
1336
- 'Foo' => %w[i_method],
1337
- 'Mixin' => %w[],
1338
- }
1339
- store2.cache[:modules] = %w[
1340
- Foo
1341
- Mixin
1342
- Object
1343
- X
1344
- ]
1345
-
1346
- @driver.stores = store1, store2
1347
- end
1348
-
1349
- def util_multi_store
1350
- util_store
1351
-
1352
- @home_ri2 = "#{@home_ri}2"
1353
- @store2 = RDoc::RI::Store.new @home_ri2
1354
-
1355
- @top_level = @store2.add_file 'file.rb'
1356
-
1357
- # as if seen in a namespace like class Ambiguous::Other
1358
- @mAmbiguous = @top_level.add_module RDoc::NormalModule, 'Ambiguous'
1359
-
1360
- @cFoo = @top_level.add_class RDoc::NormalClass, 'Foo'
1361
-
1362
- @cBar = @top_level.add_class RDoc::NormalClass, 'Bar', 'Foo'
1363
- @cFoo_Baz = @cFoo.add_class RDoc::NormalClass, 'Baz'
1364
-
1365
- @baz = @cBar.add_method RDoc::AnyMethod.new(nil, 'baz')
1366
- @baz.record_location @top_level
1367
-
1368
- @override = @cBar.add_method RDoc::AnyMethod.new(nil, 'override')
1369
- @override.comment = 'must be displayed'
1370
- @override.record_location @top_level
1371
-
1372
- @store2.save
1373
-
1374
- @driver.stores = [@store1, @store2]
1375
- end
1376
-
1377
- def util_store
1378
- @store1 = RDoc::RI::Store.new @home_ri, :home
1379
-
1380
- @top_level = @store1.add_file 'file.rb'
1381
-
1382
- @readme = @store1.add_file 'README.rdoc'
1383
- @readme.parser = RDoc::Parser::Simple
1384
- @readme.comment =
1385
- doc(
1386
- head(1, 'README'),
1387
- para('This is a README'))
1388
-
1389
- @cFoo = @top_level.add_class RDoc::NormalClass, 'Foo'
1390
- @mExt = @top_level.add_module RDoc::NormalModule, 'Ext'
1391
- @mInc = @top_level.add_module RDoc::NormalModule, 'Inc'
1392
- @cAmbiguous = @top_level.add_class RDoc::NormalClass, 'Ambiguous'
1393
-
1394
- doc = @RM::Document.new @RM::Paragraph.new('Extend thingy')
1395
- @cFooExt = @cFoo.add_extend RDoc::Extend.new('Ext', doc)
1396
- @cFooExt.record_location @top_level
1397
- doc = @RM::Document.new @RM::Paragraph.new('Include thingy')
1398
- @cFooInc = @cFoo.add_include RDoc::Include.new('Inc', doc)
1399
- @cFooInc.record_location @top_level
1400
-
1401
- @cFoo_Bar = @cFoo.add_class RDoc::NormalClass, 'Bar'
1402
-
1403
- @blah = @cFoo_Bar.add_method RDoc::AnyMethod.new(nil, 'blah')
1404
- @blah.call_seq = "blah(5) => 5\nblah(6) => 6\n"
1405
- @blah.record_location @top_level
1406
-
1407
- @bother = @cFoo_Bar.add_method RDoc::AnyMethod.new(nil, 'bother')
1408
- @bother.block_params = "stuff"
1409
- @bother.params = "(things)"
1410
- @bother.record_location @top_level
1411
-
1412
- @new = @cFoo_Bar.add_method RDoc::AnyMethod.new nil, 'new'
1413
- @new.record_location @top_level
1414
- @new.singleton = true
1415
-
1416
- @attr = @cFoo_Bar.add_attribute RDoc::Attr.new nil, 'attr', 'RW', ''
1417
- @attr.record_location @top_level
1418
-
1419
- @cFoo_Baz = @cFoo.add_class RDoc::NormalClass, 'Baz'
1420
- @cFoo_Baz.record_location @top_level
1421
-
1422
- @inherit = @cFoo.add_method RDoc::AnyMethod.new(nil, 'inherit')
1423
- @inherit.record_location @top_level
1424
-
1425
- # overriden by Bar in multi_store
1426
- @overriden = @cFoo.add_method RDoc::AnyMethod.new(nil, 'override')
1427
- @overriden.comment = 'must not be displayed in Bar#override'
1428
- @overriden.record_location @top_level
1429
-
1430
- @store1.save
1431
-
1432
- @driver.stores = [@store1]
1433
- end
1434
-
1435
- end
1436
-