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
@@ -0,0 +1,429 @@
1
+ require 'rdoc/test_case'
2
+
3
+ class TestRDocServlet < RDoc::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ @orig_gem_path = Gem.path
9
+
10
+ @tempdir = File.join Dir.tmpdir, "test_rdoc_servlet_#{$$}"
11
+ Gem.use_paths @tempdir
12
+ Gem.ensure_gem_subdirectories @tempdir
13
+
14
+ @spec = Gem::Specification.new 'spec', '1.0'
15
+ @spec.loaded_from = File.join @tempdir, @spec.spec_file
16
+
17
+ Gem::Specification.reset
18
+ Gem::Specification.all = [@spec]
19
+
20
+ @server = {}
21
+ def @server.mount(*) end
22
+
23
+ @stores = {}
24
+ @cache = Hash.new { |hash, store| hash[store] = {} }
25
+
26
+ @s = RDoc::Servlet.new @server, @stores, @cache
27
+
28
+ @req = WEBrick::HTTPRequest.new :Logger => nil
29
+ @res = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
30
+
31
+ def @req.path= path
32
+ instance_variable_set :@path, path
33
+ end
34
+
35
+ @req.instance_variable_set :@header, Hash.new { |h, k| h[k] = [] }
36
+
37
+ @base = File.join @tempdir, 'base'
38
+ @system_dir = File.join @tempdir, 'base', 'system'
39
+
40
+ @orig_base = RDoc::RI::Paths::BASE
41
+ RDoc::RI::Paths::BASE.replace @base
42
+ @orig_ri_path_homedir = RDoc::RI::Paths::HOMEDIR
43
+ RDoc::RI::Paths::HOMEDIR.replace File.join @tempdir, 'home'
44
+
45
+ RDoc::RI::Paths.instance_variable_set \
46
+ :@gemdirs, %w[/nonexistent/gems/example-1.0/ri]
47
+ end
48
+
49
+ def teardown
50
+ super
51
+
52
+ Gem.use_paths(*@orig_gem_path)
53
+ Gem::Specification.reset
54
+
55
+ FileUtils.rm_rf @tempdir
56
+
57
+ RDoc::RI::Paths::BASE.replace @orig_base
58
+ RDoc::RI::Paths::HOMEDIR.replace @orig_ri_path_homedir
59
+ RDoc::RI::Paths.instance_variable_set :@gemdirs, nil
60
+ end
61
+
62
+ def test_asset
63
+ temp_dir do
64
+ now = Time.now
65
+
66
+ open 'rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end
67
+ File.utime now, now, 'rdoc.css'
68
+
69
+ @s.asset_dirs[:darkfish] = '.'
70
+
71
+ @req.path = 'rdoc.css'
72
+
73
+ @s.asset :darkfish, @req, @res
74
+
75
+ assert_equal 'h1 { color: red }', @res.body
76
+ assert_equal 'text/css', @res.content_type
77
+ assert_equal now.httpdate, @res['last-modified']
78
+ end
79
+ end
80
+
81
+ def test_do_GET
82
+ touch_system_cache_path
83
+
84
+ @req.path = '/ruby/Missing.html'
85
+
86
+ @s.do_GET @req, @res
87
+
88
+ assert_equal 404, @res.status
89
+ end
90
+
91
+ def test_do_GET_asset_darkfish
92
+ temp_dir do
93
+ FileUtils.touch 'rdoc.css'
94
+
95
+ @s.asset_dirs[:darkfish] = '.'
96
+
97
+ @req.path = '/rdoc.css'
98
+
99
+ @s.do_GET @req, @res
100
+
101
+ assert_equal 'text/css', @res.content_type
102
+ end
103
+ end
104
+
105
+ def test_do_GET_asset_json_index
106
+ temp_dir do
107
+ FileUtils.mkdir 'js'
108
+ FileUtils.touch 'js/navigation.js'
109
+
110
+ @s.asset_dirs[:json_index] = '.'
111
+
112
+ @req.path = '/js/navigation.js'
113
+
114
+ @s.do_GET @req, @res
115
+
116
+ assert_equal 'application/javascript', @res.content_type
117
+ end
118
+ end
119
+
120
+ def test_do_GET_error
121
+ touch_system_cache_path
122
+
123
+ def @req.path() raise 'no' end
124
+
125
+ @s.do_GET @req, @res
126
+
127
+ assert_equal 500, @res.status
128
+ end
129
+
130
+ def test_do_GET_mount_path
131
+ @s = RDoc::Servlet.new @server, @stores, @cache, '/mount/path'
132
+
133
+ temp_dir do
134
+ FileUtils.touch 'rdoc.css'
135
+
136
+ @s.asset_dirs[:darkfish] = '.'
137
+
138
+ @req.path = '/mount/path/rdoc.css'
139
+
140
+ @s.do_GET @req, @res
141
+
142
+ assert_equal 'text/css', @res.content_type
143
+ end
144
+ end
145
+
146
+ def test_do_GET_not_modified
147
+ touch_system_cache_path
148
+ @req.header['if-modified-since'] = [(Time.now + 10).httpdate]
149
+ @req.path = '/ruby/Missing.html'
150
+
151
+ assert_raises WEBrick::HTTPStatus::NotModified do
152
+ @s.do_GET @req, @res
153
+ end
154
+ end
155
+
156
+ def test_do_GET_root
157
+ touch_system_cache_path
158
+
159
+ @req.path = '/'
160
+
161
+ @s.do_GET @req, @res
162
+
163
+ assert_equal 'text/html', @res.content_type
164
+ assert_match %r%<title>Local RDoc Documentation</title>%, @res.body
165
+ end
166
+
167
+ def test_do_GET_root_search
168
+ touch_system_cache_path
169
+
170
+ @req.path = '/js/search_index.js'
171
+
172
+ @s.do_GET @req, @res
173
+
174
+ assert_equal 'application/javascript', @res.content_type
175
+ end
176
+
177
+ def test_documentation_page_class
178
+ store = RDoc::Store.new
179
+
180
+ generator = @s.generator_for store
181
+
182
+ file = store.add_file 'file.rb'
183
+ klass = file.add_class RDoc::NormalClass, 'Klass'
184
+ klass.add_class RDoc::NormalClass, 'Sub'
185
+
186
+ @s.documentation_page store, generator, 'Klass::Sub.html', @req, @res
187
+
188
+ assert_match %r%<title>class Klass::Sub - </title>%, @res.body
189
+ assert_match %r%<body id="top" class="class">%, @res.body
190
+ end
191
+
192
+ def test_documentation_page_not_found
193
+ store = RDoc::Store.new
194
+
195
+ generator = @s.generator_for store
196
+
197
+ @req.path = '/ruby/Missing.html'
198
+
199
+ @s.documentation_page store, generator, 'Missing.html', @req, @res
200
+
201
+ assert_equal 404, @res.status
202
+ end
203
+
204
+ def test_documentation_page_page
205
+ store = RDoc::Store.new
206
+
207
+ generator = @s.generator_for store
208
+
209
+ readme = store.add_file 'README.rdoc'
210
+ readme.parser = RDoc::Parser::Simple
211
+
212
+ @s.documentation_page store, generator, 'README_rdoc.html', @req, @res
213
+
214
+ assert_match %r%<title>README - </title>%, @res.body
215
+ assert_match %r%<body class="file">%, @res.body
216
+ end
217
+
218
+ def test_documentation_source
219
+ store, path = @s.documentation_source '/ruby/Object.html'
220
+
221
+ assert_equal @system_dir, store.path
222
+
223
+ assert_equal 'Object.html', path
224
+ end
225
+
226
+ def test_documentation_source_cached
227
+ cached_store = RDoc::Store.new
228
+
229
+ @stores['ruby'] = cached_store
230
+
231
+ store, path = @s.documentation_source '/ruby/Object.html'
232
+
233
+ assert_same cached_store, store
234
+
235
+ assert_equal 'Object.html', path
236
+ end
237
+
238
+ def test_error
239
+ e = RuntimeError.new 'foo'
240
+ e.set_backtrace caller
241
+
242
+ @s.error e, @req, @res
243
+
244
+ assert_equal 'text/html', @res.content_type
245
+ assert_equal 500, @res.status
246
+ assert_match %r%<title>Error%, @res.body
247
+ end
248
+
249
+ def test_generator_for
250
+ store = RDoc::Store.new
251
+ store.main = 'MAIN_PAGE.rdoc'
252
+ store.title = 'Title'
253
+
254
+ generator = @s.generator_for store
255
+
256
+ refute generator.file_output
257
+
258
+ assert_equal '..', generator.asset_rel_path
259
+
260
+ assert_equal 'MAIN_PAGE.rdoc', @s.options.main_page
261
+ assert_equal 'Title', @s.options.title
262
+
263
+ assert_kind_of RDoc::RDoc, store.rdoc
264
+ assert_same generator, store.rdoc.generator
265
+ end
266
+
267
+ def test_if_modified_since
268
+ skip 'File.utime on directory not supported' if Gem.win_platform?
269
+
270
+ temp_dir do
271
+ now = Time.now
272
+ File.utime now, now, '.'
273
+
274
+ @s.if_modified_since @req, @res, '.'
275
+
276
+ assert_equal now.to_i, Time.parse(@res['last-modified']).to_i
277
+ end
278
+ end
279
+
280
+ def test_if_modified_since_not_modified
281
+ skip 'File.utime on directory not supported' if Gem.win_platform?
282
+
283
+ temp_dir do
284
+ now = Time.now
285
+ File.utime now, now, '.'
286
+
287
+ @req.header['if-modified-since'] = [(now + 10).httpdate]
288
+
289
+ assert_raises WEBrick::HTTPStatus::NotModified do
290
+ @s.if_modified_since @req, @res, '.'
291
+ end
292
+
293
+ assert_equal now.to_i, Time.parse(@res['last-modified']).to_i
294
+ end
295
+ end
296
+
297
+ def test_installed_docs
298
+ touch_system_cache_path
299
+
300
+ expected = [
301
+ ['Ruby Documentation', 'ruby/', true, :system,
302
+ @system_dir],
303
+ ['Site Documentation', 'site/', false, :site,
304
+ File.join(@base, 'site')],
305
+ ['Home Documentation', 'home/', false, :home,
306
+ RDoc::RI::Paths::HOMEDIR],
307
+ ['spec-1.0', 'spec-1.0/', false, :gem,
308
+ File.join(@spec.doc_dir, 'ri')],
309
+ ]
310
+
311
+ assert_equal expected, @s.installed_docs
312
+ end
313
+
314
+ def test_not_found
315
+ generator = @s.generator_for RDoc::Store.new
316
+
317
+ @req.path = '/ruby/Missing.html'
318
+
319
+ @s.not_found generator, @req, @res
320
+
321
+ assert_equal 404, @res.status
322
+ assert_match %r%<title>Not Found</title>%, @res.body
323
+ assert_match %r%<kbd>/ruby/Missing\.html</kbd>%, @res.body
324
+ end
325
+
326
+ def test_ri_paths
327
+ paths = @s.ri_paths
328
+
329
+ expected = [
330
+ [@system_dir, :system],
331
+ [File.join(@base, 'site'), :site],
332
+ [RDoc::RI::Paths::HOMEDIR, :home],
333
+ [File.join(@spec.doc_dir, 'ri'), :gem],
334
+ ]
335
+
336
+ assert_equal expected, paths.to_a
337
+ end
338
+
339
+ def test_root
340
+ @s.root @req, @res
341
+
342
+ assert_equal 'text/html', @res.content_type
343
+ assert_match %r%<title>Local RDoc Documentation</title>%, @res.body
344
+ end
345
+
346
+ def test_root_search
347
+ touch_system_cache_path
348
+
349
+ @s.root_search @req, @res
350
+
351
+ assert_equal 'application/javascript', @res.content_type
352
+
353
+ @res.body =~ /\{.*\}/
354
+
355
+ index = JSON.parse $&
356
+
357
+ expected = {
358
+ 'index' => {
359
+ 'searchIndex' => %w[
360
+ Ruby\ Documentation
361
+ ],
362
+ 'longSearchIndex' => %w[
363
+ Ruby\ Documentation
364
+ ],
365
+ 'info' => [
366
+ ['Ruby Documentation', '', @system_dir, '',
367
+ 'Documentation for the Ruby standard library'],
368
+ ],
369
+ }
370
+ }
371
+
372
+ assert_equal expected, index
373
+ end
374
+
375
+ def test_show_documentation_index
376
+ touch_system_cache_path
377
+
378
+ @req.path = '/ruby'
379
+
380
+ @s.show_documentation @req, @res
381
+
382
+ assert_equal 'text/html', @res.content_type
383
+ assert_match %r%<title>Standard Library Documentation%, @res.body
384
+ end
385
+
386
+ def test_show_documentation_table_of_contents
387
+ touch_system_cache_path
388
+
389
+ @req.path = '/ruby/table_of_contents.html'
390
+
391
+ @s.show_documentation @req, @res
392
+
393
+ assert_equal 'text/html', @res.content_type
394
+ assert_match %r%<title>Table of Contents - Standard Library Documentation%,
395
+ @res.body
396
+ end
397
+
398
+ def test_show_documentation_page
399
+ touch_system_cache_path
400
+
401
+ @req.path = '/ruby/Missing.html'
402
+
403
+ @s.show_documentation @req, @res
404
+
405
+ assert_equal 404, @res.status
406
+ end
407
+
408
+ def test_show_documentation_search_index
409
+ touch_system_cache_path
410
+
411
+ @req.path = '/ruby/js/search_index.js'
412
+
413
+ @s.show_documentation @req, @res
414
+
415
+ assert_equal 'application/javascript', @res.content_type
416
+ assert_match %r%\Avar search_data =%, @res.body
417
+ end
418
+
419
+ def touch_system_cache_path
420
+ store = RDoc::Store.new @system_dir
421
+ store.title = 'Standard Library Documentation'
422
+
423
+ FileUtils.mkdir_p File.dirname store.cache_path
424
+
425
+ store.save
426
+ end
427
+
428
+ end
429
+
@@ -5,9 +5,9 @@ class TestRDocStats < RDoc::TestCase
5
5
  def setup
6
6
  super
7
7
 
8
- @s = RDoc::Stats.new 0
8
+ @s = RDoc::Stats.new @store, 0
9
9
 
10
- @tl = RDoc::TopLevel.new 'file.rb'
10
+ @tl = @store.add_file 'file.rb'
11
11
  @tl.parser = RDoc::Parser::Ruby
12
12
  end
13
13
 
@@ -40,7 +40,7 @@ class TestRDocStats < RDoc::TestCase
40
40
  a.record_location @tl
41
41
  c.add_attribute a
42
42
 
43
- RDoc::TopLevel.complete :public
43
+ @store.complete :public
44
44
 
45
45
  report = @s.report
46
46
 
@@ -65,13 +65,28 @@ end
65
65
  a.record_location @tl
66
66
  c.add_attribute a
67
67
 
68
- RDoc::TopLevel.complete :public
68
+ @store.complete :public
69
69
 
70
70
  report = @s.report
71
71
 
72
72
  assert_equal @s.great_job, report
73
73
  end
74
74
 
75
+ def test_report_attr_line
76
+ c = @tl.add_class RDoc::NormalClass, 'C'
77
+ c.record_location @tl
78
+ c.add_comment 'C', @tl
79
+
80
+ a = RDoc::Attr.new nil, 'a', 'RW', nil
81
+ a.record_location @tl
82
+ a.line = 3
83
+ c.add_attribute a
84
+
85
+ @store.complete :public
86
+
87
+ assert_match '# in file file.rb:3', @s.report
88
+ end
89
+
75
90
  def test_report_constant
76
91
  m = @tl.add_module RDoc::NormalModule, 'M'
77
92
  m.record_location @tl
@@ -81,7 +96,7 @@ end
81
96
  c.record_location @tl
82
97
  m.add_constant c
83
98
 
84
- RDoc::TopLevel.complete :public
99
+ @store.complete :public
85
100
 
86
101
  report = @s.report
87
102
 
@@ -109,7 +124,7 @@ end
109
124
 
110
125
  @tl.add_constant ca
111
126
 
112
- RDoc::TopLevel.complete :public
127
+ @store.complete :public
113
128
 
114
129
  report = @s.report
115
130
 
@@ -127,13 +142,28 @@ end
127
142
  c.record_location @tl
128
143
  m.add_constant c
129
144
 
130
- RDoc::TopLevel.complete :public
145
+ @store.complete :public
131
146
 
132
147
  report = @s.report
133
148
 
134
149
  assert_equal @s.great_job, report
135
150
  end
136
151
 
152
+ def test_report_constant_line
153
+ m = @tl.add_module RDoc::NormalModule, 'M'
154
+ m.record_location @tl
155
+ m.add_comment 'M', @tl
156
+
157
+ c = RDoc::Constant.new 'C', nil, nil
158
+ c.record_location @tl
159
+ c.line = 5
160
+ m.add_constant c
161
+
162
+ @store.complete :public
163
+
164
+ assert_match '# in file file.rb:5', @s.report
165
+ end
166
+
137
167
  def test_report_class
138
168
  c = @tl.add_class RDoc::NormalClass, 'C'
139
169
  c.record_location @tl
@@ -143,7 +173,7 @@ end
143
173
  c.add_method m
144
174
  m.comment = 'm'
145
175
 
146
- RDoc::TopLevel.complete :public
176
+ @store.complete :public
147
177
 
148
178
  report = @s.report
149
179
 
@@ -160,6 +190,20 @@ end
160
190
  assert_equal expected, report
161
191
  end
162
192
 
193
+ def test_report_skip_object
194
+ c = @tl.add_class RDoc::NormalClass, 'Object'
195
+ c.record_location @tl
196
+
197
+ m = RDoc::AnyMethod.new nil, 'm'
198
+ m.record_location @tl
199
+ c.add_method m
200
+ m.comment = 'm'
201
+
202
+ @store.complete :public
203
+
204
+ refute_match %r%^class Object$%, @s.report
205
+ end
206
+
163
207
  def test_report_class_documented
164
208
  c = @tl.add_class RDoc::NormalClass, 'C'
165
209
  c.record_location @tl
@@ -170,7 +214,7 @@ end
170
214
  c.add_method m
171
215
  m.comment = 'm'
172
216
 
173
- RDoc::TopLevel.complete :public
217
+ @store.complete :public
174
218
 
175
219
  report = @s.report
176
220
 
@@ -195,7 +239,7 @@ end
195
239
  c2.add_method m2
196
240
  m2.comment = 'm2'
197
241
 
198
- RDoc::TopLevel.complete :public
242
+ @store.complete :public
199
243
 
200
244
  @s.coverage_level = 1
201
245
 
@@ -218,7 +262,7 @@ end
218
262
  def test_report_class_empty
219
263
  @tl.add_class RDoc::NormalClass, 'C'
220
264
 
221
- RDoc::TopLevel.complete :public
265
+ @store.complete :public
222
266
 
223
267
  report = @s.report
224
268
 
@@ -241,7 +285,7 @@ The following items are not documented:
241
285
  c2.record_location @tl
242
286
  c2.add_comment 'C2', @tl
243
287
 
244
- RDoc::TopLevel.complete :public
288
+ @store.complete :public
245
289
 
246
290
  @s.coverage_level = 1
247
291
  report = @s.report
@@ -269,7 +313,7 @@ end
269
313
  c.add_method m
270
314
  m.comment = 'm'
271
315
 
272
- RDoc::TopLevel.complete :public
316
+ @store.complete :public
273
317
 
274
318
  report = @s.report
275
319
 
@@ -290,7 +334,7 @@ end
290
334
  c = @tl.add_class RDoc::NormalClass, 'C'
291
335
  c.ignore
292
336
 
293
- RDoc::TopLevel.complete :public
337
+ @store.complete :public
294
338
 
295
339
  report = @s.report_class_module c
296
340
 
@@ -298,7 +342,7 @@ end
298
342
  end
299
343
 
300
344
  def test_report_empty
301
- RDoc::TopLevel.complete :public
345
+ @store.complete :public
302
346
 
303
347
  report = @s.report
304
348
 
@@ -319,7 +363,7 @@ end
319
363
  c.add_method m2
320
364
  m2.comment = 'm2'
321
365
 
322
- RDoc::TopLevel.complete :public
366
+ @store.complete :public
323
367
 
324
368
  report = @s.report
325
369
 
@@ -353,7 +397,7 @@ end
353
397
  c.add_method m2
354
398
  m2.comment = 'm2'
355
399
 
356
- RDoc::TopLevel.complete :public
400
+ @store.complete :public
357
401
 
358
402
  report = @s.report
359
403
 
@@ -381,13 +425,28 @@ end
381
425
  c.add_method m
382
426
  m.comment = 'm'
383
427
 
384
- RDoc::TopLevel.complete :public
428
+ @store.complete :public
385
429
 
386
430
  report = @s.report
387
431
 
388
432
  assert_equal @s.great_job, report
389
433
  end
390
434
 
435
+ def test_report_method_line
436
+ c = @tl.add_class RDoc::NormalClass, 'C'
437
+ c.record_location @tl
438
+ c.add_comment 'C', @tl
439
+
440
+ m1 = RDoc::AnyMethod.new nil, 'm1'
441
+ m1.record_location @tl
442
+ m1.line = 4
443
+ c.add_method m1
444
+
445
+ @store.complete :public
446
+
447
+ assert_match '# in file file.rb:4', @s.report
448
+ end
449
+
391
450
  def test_report_method_parameters
392
451
  c = @tl.add_class RDoc::NormalClass, 'C'
393
452
  c.record_location @tl
@@ -404,7 +463,7 @@ end
404
463
  c.add_method m2
405
464
  m2.comment = 'm2'
406
465
 
407
- RDoc::TopLevel.complete :public
466
+ @store.complete :public
408
467
 
409
468
  @s.coverage_level = 1
410
469
  report = @s.report
@@ -436,7 +495,7 @@ end
436
495
  m.comment = 'Stuff with +p1+'
437
496
  c.add_method m
438
497
 
439
- RDoc::TopLevel.complete :public
498
+ @store.complete :public
440
499
 
441
500
  @s.coverage_level = 1
442
501
  report = @s.report
@@ -458,7 +517,7 @@ m(a, b) { |c, d| ... }
458
517
  m.comment = 'Stuff with +a+, yields +c+ for you to do stuff with'
459
518
  c.add_method m
460
519
 
461
- RDoc::TopLevel.complete :public
520
+ @store.complete :public
462
521
 
463
522
  @s.coverage_level = 1
464
523
  report = @s.report
@@ -497,7 +556,7 @@ end
497
556
  m.record_location @tl
498
557
  c.add_method m
499
558
 
500
- RDoc::TopLevel.complete :public
559
+ @store.complete :public
501
560
 
502
561
  summary = @s.summary
503
562
  summary.sub!(/Elapsed:.*/, '')
@@ -523,7 +582,7 @@ Total: 5 (5 undocumented)
523
582
  c = @tl.add_class RDoc::NormalClass, 'C'
524
583
  c.record_location @tl
525
584
 
526
- RDoc::TopLevel.complete :public
585
+ @store.complete :public
527
586
 
528
587
  @s.coverage_level = false
529
588
 
@@ -558,7 +617,7 @@ Total: 1 (1 undocumented)
558
617
  m.comment = 'Stuff with +p1+'
559
618
  c.add_method m
560
619
 
561
- RDoc::TopLevel.complete :public
620
+ @store.complete :public
562
621
 
563
622
  @s.coverage_level = 1
564
623
  @s.report