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,19 +0,0 @@
1
- require 'rdoc/test_case'
2
-
3
- class TestRDocRubyToken < RDoc::TestCase
4
-
5
- def test_Token_text
6
- token = RDoc::RubyToken::Token.new 0, 0, 0, 'text'
7
-
8
- assert_equal 'text', token.text
9
- end
10
-
11
- def test_TkOp_name
12
- token = RDoc::RubyToken::TkOp.new 0, 0, 0, '&'
13
-
14
- assert_equal '&', token.text
15
- assert_equal '&', token.name
16
- end
17
-
18
- end
19
-
@@ -1,251 +0,0 @@
1
- require 'rubygems'
2
- require 'rubygems/test_case'
3
- require 'rdoc/rubygems_hook'
4
-
5
- class TestRDocRubygemsHook < Gem::TestCase
6
-
7
- def setup
8
- super
9
-
10
- skip 'requires RubyGems 1.9+' unless
11
- Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.9')
12
-
13
- @a = util_spec 'a', 2 do |s|
14
- s.rdoc_options = %w[--main MyTitle]
15
- s.extra_rdoc_files = %w[README]
16
- end
17
-
18
- write_file File.join(@tempdir, 'lib', 'a.rb')
19
- write_file File.join(@tempdir, 'README')
20
-
21
- install_gem @a
22
-
23
- @hook = RDoc::RubygemsHook.new @a
24
-
25
- begin
26
- RDoc::RubygemsHook.load_rdoc
27
- rescue Gem::DocumentError => e
28
- skip e.message
29
- end
30
-
31
- Gem.configuration[:rdoc] = nil
32
- end
33
-
34
- def test_initialize
35
- refute @hook.generate_rdoc
36
- assert @hook.generate_ri
37
-
38
- rdoc = RDoc::RubygemsHook.new @a, false, false
39
-
40
- refute rdoc.generate_rdoc
41
- refute rdoc.generate_ri
42
- end
43
-
44
- def test_delete_legacy_args
45
- args = %w[
46
- --inline-source
47
- --one-file
48
- --promiscuous
49
- -p
50
- ]
51
-
52
- @hook.delete_legacy_args args
53
-
54
- assert_empty args
55
- end
56
-
57
- def test_document
58
- options = RDoc::Options.new
59
- options.files = []
60
-
61
- rdoc = @hook.new_rdoc
62
- rdoc.store = RDoc::Store.new
63
- @hook.instance_variable_set :@rdoc, rdoc
64
- @hook.instance_variable_set :@file_info, []
65
-
66
- @hook.document 'darkfish', options, @a.doc_dir('rdoc')
67
-
68
- assert @hook.rdoc_installed?
69
- end
70
-
71
- def test_generate
72
- FileUtils.mkdir_p @a.doc_dir
73
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
74
-
75
- @hook.generate
76
-
77
- refute @hook.rdoc_installed?
78
- assert @hook.ri_installed?
79
-
80
- rdoc = @hook.instance_variable_get :@rdoc
81
-
82
- refute rdoc.options.hyperlink_all
83
- assert_equal Pathname(@a.full_gem_path), rdoc.options.root
84
- assert_equal %w[README lib], rdoc.options.files.sort
85
-
86
- assert_equal 'MyTitle', rdoc.store.main
87
- end
88
-
89
- def test_generate_all
90
- @hook.generate_rdoc = true
91
- @hook.generate_ri = true
92
-
93
- FileUtils.mkdir_p @a.doc_dir
94
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
95
-
96
- @hook.generate
97
-
98
- assert @hook.rdoc_installed?
99
- assert @hook.ri_installed?
100
-
101
- rdoc = @hook.instance_variable_get :@rdoc
102
-
103
- refute rdoc.options.hyperlink_all
104
- assert_equal Pathname(@a.full_gem_path), rdoc.options.root
105
- assert_equal %w[README lib], rdoc.options.files.sort
106
-
107
- assert_equal 'MyTitle', rdoc.store.main
108
- end
109
-
110
- def test_generate_configuration_rdoc_array
111
- Gem.configuration[:rdoc] = %w[-A]
112
-
113
- FileUtils.mkdir_p @a.doc_dir
114
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
115
-
116
- @hook.generate
117
-
118
- rdoc = @hook.instance_variable_get :@rdoc
119
-
120
- assert rdoc.options.hyperlink_all
121
- end
122
-
123
- def test_generate_configuration_rdoc_string
124
- Gem.configuration[:rdoc] = '-A'
125
-
126
- FileUtils.mkdir_p @a.doc_dir
127
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
128
-
129
- @hook.generate
130
-
131
- rdoc = @hook.instance_variable_get :@rdoc
132
-
133
- assert rdoc.options.hyperlink_all
134
- end
135
-
136
- def test_generate_default_gem
137
- skip 'RubyGems 2 required' unless @a.respond_to? :default_gem?
138
- @a.loaded_from =
139
- File.join Gem::Specification.default_specifications_dir, 'a.gemspec'
140
-
141
- @hook.generate
142
-
143
- refute @hook.rdoc_installed?
144
- refute @hook.ri_installed?
145
- end
146
-
147
- def test_generate_disabled
148
- @hook.generate_rdoc = false
149
- @hook.generate_ri = false
150
-
151
- @hook.generate
152
-
153
- refute @hook.rdoc_installed?
154
- refute @hook.ri_installed?
155
- end
156
-
157
- def test_generate_force
158
- FileUtils.mkdir_p @a.doc_dir 'ri'
159
- FileUtils.mkdir_p @a.doc_dir 'rdoc'
160
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
161
-
162
- @hook.force = true
163
-
164
- @hook.generate
165
-
166
- refute_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
167
- assert_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
168
- end
169
-
170
- def test_generate_no_overwrite
171
- FileUtils.mkdir_p @a.doc_dir 'ri'
172
- FileUtils.mkdir_p @a.doc_dir 'rdoc'
173
- FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
174
-
175
- @hook.generate
176
-
177
- refute_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
178
- refute_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
179
- end
180
-
181
- def test_new_rdoc
182
- assert_kind_of RDoc::RDoc, @hook.new_rdoc
183
- end
184
-
185
- def test_rdoc_installed?
186
- refute @hook.rdoc_installed?
187
-
188
- FileUtils.mkdir_p @a.doc_dir 'rdoc'
189
-
190
- assert @hook.rdoc_installed?
191
- end
192
-
193
- def test_remove
194
- FileUtils.mkdir_p @a.doc_dir 'rdoc'
195
- FileUtils.mkdir_p @a.doc_dir 'ri'
196
-
197
- @hook.remove
198
-
199
- refute @hook.rdoc_installed?
200
- refute @hook.ri_installed?
201
-
202
- assert_path_exists @a.doc_dir
203
- end
204
-
205
- def test_remove_unwritable
206
- skip 'chmod not supported' if Gem.win_platform?
207
- FileUtils.mkdir_p @a.base_dir
208
- FileUtils.chmod 0, @a.base_dir
209
-
210
- e = assert_raises Gem::FilePermissionError do
211
- @hook.remove
212
- end
213
-
214
- assert_equal @a.base_dir, e.directory
215
- ensure
216
- FileUtils.chmod(0755, @a.base_dir) if File.directory?(@a.base_dir)
217
- end
218
-
219
- def test_ri_installed?
220
- refute @hook.ri_installed?
221
-
222
- FileUtils.mkdir_p @a.doc_dir 'ri'
223
-
224
- assert @hook.ri_installed?
225
- end
226
-
227
- def test_setup
228
- @hook.setup
229
-
230
- assert_path_exists @a.doc_dir
231
- end
232
-
233
- def test_setup_unwritable
234
- skip 'chmod not supported' if Gem.win_platform?
235
- FileUtils.mkdir_p @a.doc_dir
236
- FileUtils.chmod 0, @a.doc_dir
237
-
238
- e = assert_raises Gem::FilePermissionError do
239
- @hook.setup
240
- end
241
-
242
- assert_equal @a.doc_dir, e.directory
243
- ensure
244
- if File.exist? @a.doc_dir
245
- FileUtils.chmod 0755, @a.doc_dir
246
- FileUtils.rm_r @a.doc_dir
247
- end
248
- end
249
-
250
- end
251
-
@@ -1,534 +0,0 @@
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 = @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
- @extra_dirs = [File.join(@tempdir, 'extra1'), File.join(@tempdir, 'extra2')]
27
-
28
- @s = RDoc::Servlet.new @server, @stores, @cache, nil, @extra_dirs
29
-
30
- @req = WEBrick::HTTPRequest.new :Logger => nil
31
- @res = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
32
-
33
- def @req.path= path
34
- instance_variable_set :@path, path
35
- end
36
-
37
- @req.instance_variable_set :@header, Hash.new { |h, k| h[k] = [] }
38
-
39
- @base = File.join @tempdir, 'base'
40
- @system_dir = File.join @tempdir, 'base', 'system'
41
- @home_dir = File.join @tempdir, 'home'
42
- @gem_doc_dir = File.join @tempdir, 'doc'
43
-
44
- @orig_base = RDoc::RI::Paths::BASE
45
- RDoc::RI::Paths::BASE.replace @base
46
- @orig_ri_path_homedir = RDoc::RI::Paths::HOMEDIR
47
- RDoc::RI::Paths::HOMEDIR.replace @home_dir
48
-
49
- RDoc::RI::Paths.instance_variable_set \
50
- :@gemdirs, %w[/nonexistent/gems/example-1.0/ri]
51
- end
52
-
53
- def teardown
54
- super
55
-
56
- Gem.use_paths(*@orig_gem_path)
57
- Gem::Specification.reset
58
-
59
- FileUtils.rm_rf @tempdir
60
-
61
- RDoc::RI::Paths::BASE.replace @orig_base
62
- RDoc::RI::Paths::HOMEDIR.replace @orig_ri_path_homedir
63
- RDoc::RI::Paths.instance_variable_set :@gemdirs, nil
64
- end
65
-
66
- def test_asset
67
- temp_dir do
68
- now = Time.now
69
-
70
- open 'rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end
71
- File.utime now, now, 'rdoc.css'
72
-
73
- @s.asset_dirs[:darkfish] = '.'
74
-
75
- @req.path = 'rdoc.css'
76
-
77
- @s.asset :darkfish, @req, @res
78
-
79
- assert_equal 'h1 { color: red }', @res.body
80
- assert_equal 'text/css', @res.content_type
81
- assert_equal now.httpdate, @res['last-modified']
82
- end
83
- end
84
-
85
- def test_do_GET
86
- touch_system_cache_path
87
-
88
- @req.path = '/ruby/Missing.html'
89
-
90
- @s.do_GET @req, @res
91
-
92
- assert_equal 404, @res.status
93
- end
94
-
95
- def test_do_GET_asset_darkfish
96
- temp_dir do
97
- FileUtils.touch 'rdoc.css'
98
-
99
- @s.asset_dirs[:darkfish] = '.'
100
-
101
- @req.path = '/rdoc.css'
102
-
103
- @s.do_GET @req, @res
104
-
105
- assert_equal 'text/css', @res.content_type
106
- end
107
- end
108
-
109
- def test_do_GET_asset_json_index
110
- temp_dir do
111
- FileUtils.mkdir 'js'
112
- FileUtils.touch 'js/navigation.js'
113
-
114
- @s.asset_dirs[:json_index] = '.'
115
-
116
- @req.path = '/js/navigation.js'
117
-
118
- @s.do_GET @req, @res
119
-
120
- assert_equal 'application/javascript', @res.content_type
121
- end
122
- end
123
-
124
- def test_do_GET_error
125
- touch_system_cache_path
126
-
127
- def @req.path() raise 'no' end
128
-
129
- @s.do_GET @req, @res
130
-
131
- assert_equal 500, @res.status
132
- end
133
-
134
- def test_do_GET_mount_path
135
- @s = RDoc::Servlet.new @server, @stores, @cache, '/mount/path'
136
-
137
- temp_dir do
138
- FileUtils.touch 'rdoc.css'
139
-
140
- @s.asset_dirs[:darkfish] = '.'
141
-
142
- @req.path = '/mount/path/rdoc.css'
143
-
144
- @s.do_GET @req, @res
145
-
146
- assert_equal 'text/css', @res.content_type
147
- end
148
- end
149
-
150
- def do_GET_not_found
151
- touch_system_cache_path
152
-
153
- @req.path = "/#{@spec.full_name}"
154
-
155
- @s.do_GET @req, @res
156
-
157
- assert_equal 404, @res.status
158
- end
159
-
160
- def test_do_GET_not_modified
161
- touch_system_cache_path
162
- @req.header['if-modified-since'] = [(Time.now + 10).httpdate]
163
- @req.path = '/ruby/Missing.html'
164
-
165
- assert_raises WEBrick::HTTPStatus::NotModified do
166
- @s.do_GET @req, @res
167
- end
168
- end
169
-
170
- def test_do_GET_root
171
- touch_system_cache_path
172
-
173
- @req.path = '/'
174
-
175
- @s.do_GET @req, @res
176
-
177
- assert_equal 'text/html', @res.content_type
178
- assert_match %r%<title>Local RDoc Documentation</title>%, @res.body
179
- end
180
-
181
- def test_do_GET_root_search
182
- touch_system_cache_path
183
-
184
- @req.path = '/js/search_index.js'
185
-
186
- @s.do_GET @req, @res
187
-
188
- assert_equal 'application/javascript', @res.content_type, @res.body
189
- end
190
-
191
- def test_documentation_page_class
192
- store = RDoc::Store.new
193
-
194
- generator = @s.generator_for store
195
-
196
- file = store.add_file 'file.rb'
197
- klass = file.add_class RDoc::NormalClass, 'Klass'
198
- klass.add_class RDoc::NormalClass, 'Sub'
199
-
200
- @s.documentation_page store, generator, 'Klass::Sub.html', @req, @res
201
-
202
- assert_match %r%<title>class Klass::Sub - </title>%, @res.body
203
- assert_match %r%<body id="top" role="document" class="class">%, @res.body
204
- end
205
-
206
- def test_documentation_page_not_found
207
- store = RDoc::Store.new
208
-
209
- generator = @s.generator_for store
210
-
211
- @req.path = '/ruby/Missing.html'
212
-
213
- @s.documentation_page store, generator, 'Missing.html', @req, @res
214
-
215
- assert_equal 404, @res.status
216
- end
217
-
218
- def test_documentation_page_page
219
- store = RDoc::Store.new
220
-
221
- generator = @s.generator_for store
222
-
223
- readme = store.add_file 'README.rdoc'
224
- readme.parser = RDoc::Parser::Simple
225
-
226
- @s.documentation_page store, generator, 'README_rdoc.html', @req, @res
227
-
228
- assert_match %r%<title>README - </title>%, @res.body
229
- assert_match %r%<body [^>]+ class="file">%, @res.body
230
- end
231
-
232
- def test_documentation_source
233
- store, path = @s.documentation_source '/ruby/Object.html'
234
-
235
- assert_equal @system_dir, store.path
236
-
237
- assert_equal 'Object.html', path
238
- end
239
-
240
- def test_documentation_source_cached
241
- cached_store = RDoc::Store.new
242
-
243
- @stores['ruby'] = cached_store
244
-
245
- store, path = @s.documentation_source '/ruby/Object.html'
246
-
247
- assert_same cached_store, store
248
-
249
- assert_equal 'Object.html', path
250
- end
251
-
252
- def test_error
253
- e = RuntimeError.new 'foo'
254
- e.set_backtrace caller
255
-
256
- @s.error e, @req, @res
257
-
258
- assert_equal 'text/html', @res.content_type
259
- assert_equal 500, @res.status
260
- assert_match %r%<title>Error%, @res.body
261
- end
262
-
263
- def test_generator_for
264
- store = RDoc::Store.new
265
- store.main = 'MAIN_PAGE.rdoc'
266
- store.title = 'Title'
267
-
268
- generator = @s.generator_for store
269
-
270
- refute generator.file_output
271
-
272
- assert_equal '..', generator.asset_rel_path
273
-
274
- assert_equal 'MAIN_PAGE.rdoc', @s.options.main_page
275
- assert_equal 'Title', @s.options.title
276
-
277
- assert_kind_of RDoc::RDoc, store.rdoc
278
- assert_same generator, store.rdoc.generator
279
- end
280
-
281
- def test_if_modified_since
282
- skip 'File.utime on directory not supported' if Gem.win_platform?
283
-
284
- temp_dir do
285
- now = Time.now
286
- File.utime now, now, '.'
287
-
288
- @s.if_modified_since @req, @res, '.'
289
-
290
- assert_equal now.to_i, Time.parse(@res['last-modified']).to_i
291
- end
292
- end
293
-
294
- def test_if_modified_since_not_modified
295
- skip 'File.utime on directory not supported' if Gem.win_platform?
296
-
297
- temp_dir do
298
- now = Time.now
299
- File.utime now, now, '.'
300
-
301
- @req.header['if-modified-since'] = [(now + 10).httpdate]
302
-
303
- assert_raises WEBrick::HTTPStatus::NotModified do
304
- @s.if_modified_since @req, @res, '.'
305
- end
306
-
307
- assert_equal now.to_i, Time.parse(@res['last-modified']).to_i
308
- end
309
- end
310
-
311
- def test_installed_docs
312
- touch_system_cache_path
313
- touch_extra_cache_path
314
-
315
- expected = [
316
- ['My Extra Documentation', 'extra-1/', true, :extra,
317
- @extra_dirs[0]],
318
- ['Extra Documentation', 'extra-2/', false, :extra,
319
- @extra_dirs[1]],
320
- ['Ruby Documentation', 'ruby/', true, :system,
321
- @system_dir],
322
- ['Site Documentation', 'site/', false, :site,
323
- File.join(@base, 'site')],
324
- ['Home Documentation', 'home/', false, :home,
325
- RDoc::RI::Paths::HOMEDIR],
326
- ['spec-1.0', 'spec-1.0/', false, :gem,
327
- File.join(@spec.doc_dir, 'ri')],
328
- ]
329
-
330
- assert_equal expected, @s.installed_docs
331
- end
332
-
333
- def test_not_found
334
- generator = @s.generator_for RDoc::Store.new
335
-
336
- @req.path = '/ruby/Missing.html'
337
-
338
- @s.not_found generator, @req, @res
339
-
340
- assert_equal 404, @res.status
341
- assert_match %r%<title>Not Found</title>%, @res.body
342
- assert_match %r%<kbd>/ruby/Missing\.html</kbd>%, @res.body
343
- end
344
-
345
- def test_not_found_message
346
- generator = @s.generator_for RDoc::Store.new
347
-
348
- @req.path = '/ruby/Missing.html'
349
-
350
- @s.not_found generator, @req, @res, 'woo, this is a message'
351
-
352
- assert_equal 404, @res.status
353
- assert_match %r%<title>Not Found</title>%, @res.body
354
- assert_match %r%woo, this is a message%, @res.body
355
- end
356
-
357
- def test_ri_paths
358
- paths = @s.ri_paths
359
-
360
- expected = [
361
- [@extra_dirs[0], :extra],
362
- [@extra_dirs[1], :extra],
363
- [@system_dir, :system],
364
- [File.join(@base, 'site'), :site],
365
- [RDoc::RI::Paths::HOMEDIR, :home],
366
- [File.join(@spec.doc_dir, 'ri'), :gem],
367
- ]
368
-
369
- assert_equal expected, paths.to_a
370
- end
371
-
372
- def test_root
373
- @s.root @req, @res
374
-
375
- assert_equal 'text/html', @res.content_type
376
- assert_match %r%<title>Local RDoc Documentation</title>%, @res.body
377
- end
378
-
379
- def test_root_search
380
- touch_system_cache_path
381
- touch_extra_cache_path
382
-
383
- @s.root_search @req, @res
384
-
385
- assert_equal 'application/javascript', @res.content_type
386
-
387
- @res.body =~ /\{.*\}/
388
-
389
- index = JSON.parse $&
390
-
391
- expected = {
392
- 'index' => {
393
- 'searchIndex' => %w[
394
- My\ Extra\ Documentation
395
- Ruby\ Documentation
396
- ],
397
- 'longSearchIndex' => %w[
398
- My\ Extra\ Documentation
399
- Ruby\ Documentation
400
- ],
401
- 'info' => [
402
- ['My Extra Documentation', '', @extra_dirs[0], '',
403
- 'My Extra Documentation'],
404
- ['Ruby Documentation', '', 'ruby', '',
405
- 'Documentation for the Ruby standard library'],
406
- ],
407
- }
408
- }
409
-
410
- assert_equal expected, index
411
- end
412
-
413
- def test_show_documentation_index
414
- touch_system_cache_path
415
-
416
- @req.path = '/ruby'
417
-
418
- @s.show_documentation @req, @res
419
-
420
- assert_equal 'text/html', @res.content_type
421
- assert_match %r%<title>Standard Library Documentation%, @res.body
422
- end
423
-
424
- def test_show_documentation_table_of_contents
425
- touch_system_cache_path
426
-
427
- @req.path = '/ruby/table_of_contents.html'
428
-
429
- @s.show_documentation @req, @res
430
-
431
- assert_equal 'text/html', @res.content_type
432
- assert_match %r%<title>Table of Contents - Standard Library Documentation%,
433
- @res.body
434
- end
435
-
436
- def test_show_documentation_page
437
- touch_system_cache_path
438
-
439
- @req.path = '/ruby/Missing.html'
440
-
441
- @s.show_documentation @req, @res
442
-
443
- assert_equal 404, @res.status
444
- end
445
-
446
- def test_show_documentation_search_index
447
- touch_system_cache_path
448
-
449
- @req.path = '/ruby/js/search_index.js'
450
-
451
- @s.show_documentation @req, @res
452
-
453
- assert_equal 'application/javascript', @res.content_type
454
- assert_match %r%\Avar search_data =%, @res.body
455
- end
456
-
457
- def test_store_for_gem
458
- ri_dir = File.join @gem_doc_dir, 'spec-1.0', 'ri'
459
- FileUtils.mkdir_p ri_dir
460
- FileUtils.touch File.join ri_dir, 'cache.ri'
461
-
462
- store = @s.store_for 'spec-1.0'
463
-
464
- assert_equal File.join(@gem_doc_dir, 'spec-1.0', 'ri'), store.path
465
- assert_equal :gem, store.type
466
- end
467
-
468
- def test_store_for_home
469
- store = @s.store_for 'home'
470
-
471
- assert_equal @home_dir, store.path
472
- assert_equal :home, store.type
473
- end
474
-
475
- def test_store_for_missing_documentation
476
- FileUtils.mkdir_p(File.join @gem_doc_dir, 'spec-1.0', 'ri')
477
-
478
- e = assert_raises WEBrick::HTTPStatus::NotFound do
479
- @s.store_for 'spec-1.0'
480
- end
481
-
482
- assert_equal 'Could not find documentation for "spec-1.0". Please run `gem rdoc --ri gem_name`',
483
- e.message
484
- end
485
-
486
- def test_store_for_missing_gem
487
- e = assert_raises WEBrick::HTTPStatus::NotFound do
488
- @s.store_for 'missing'
489
- end
490
-
491
- assert_equal 'Could not find gem "missing". Are you sure you installed it?',
492
- e.message
493
- end
494
-
495
- def test_store_for_ruby
496
- store = @s.store_for 'ruby'
497
-
498
- assert_equal @system_dir, store.path
499
- assert_equal :system, store.type
500
- end
501
-
502
- def test_store_for_site
503
- store = @s.store_for 'site'
504
-
505
- assert_equal File.join(@base, 'site'), store.path
506
- assert_equal :site, store.type
507
- end
508
-
509
- def test_store_for_extra
510
- store = @s.store_for 'extra-1'
511
-
512
- assert_equal @extra_dirs.first, store.path
513
- assert_equal :extra, store.type
514
- end
515
-
516
- def touch_system_cache_path
517
- store = RDoc::Store.new @system_dir
518
- store.title = 'Standard Library Documentation'
519
-
520
- FileUtils.mkdir_p File.dirname store.cache_path
521
-
522
- store.save
523
- end
524
-
525
- def touch_extra_cache_path
526
- store = RDoc::Store.new @extra_dirs.first
527
- store.title = 'My Extra Documentation'
528
-
529
- FileUtils.mkdir_p File.dirname store.cache_path
530
-
531
- store.save
532
- end
533
-
534
- end