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
@@ -5,41 +5,150 @@ class TestRDocRIPaths < RDoc::TestCase
5
5
  def setup
6
6
  super
7
7
 
8
- RDoc::RI::Paths.instance_variable_set :@gemdirs, %w[/nonexistent/gemdir]
8
+ @orig_gem_path = Gem.path
9
+
10
+ @tempdir = File.join Dir.tmpdir, "test_rdoc_ri_paths_#{$$}"
11
+ Gem.use_paths @tempdir
12
+ Gem.ensure_gem_subdirectories @tempdir
13
+
14
+ specs = [
15
+ @rake_10 = Gem::Specification.new('rake', '10.0.1'),
16
+ @rdoc_4_0 = Gem::Specification.new('rdoc', '4.0'),
17
+ @rdoc_3_12 = Gem::Specification.new('rdoc', '3.12'),
18
+ @nodoc = Gem::Specification.new('nodoc', '1.0'),
19
+ ]
20
+
21
+ specs.each do |spec|
22
+ spec.loaded_from = spec.spec_file
23
+
24
+ open spec.spec_file, 'w' do |file|
25
+ file.write spec.to_ruby_for_cache
26
+ end
27
+
28
+ FileUtils.mkdir_p File.join(spec.doc_dir, 'ri') unless
29
+ spec.name == 'nodoc'
30
+ end
31
+
32
+ Gem::Specification.reset
33
+ Gem::Specification.all = specs
9
34
  end
10
35
 
11
36
  def teardown
12
37
  super
13
38
 
14
- RDoc::RI::Paths.instance_variable_set :@gemdirs, nil
39
+ Gem.use_paths(*@orig_gem_path)
40
+ Gem::Specification.reset
41
+ FileUtils.rm_rf @tempdir
42
+ end
43
+
44
+ def test_class_each
45
+ enum = RDoc::RI::Paths.each true, true, true, :all
46
+
47
+ path = enum.map { |dir,| dir }
48
+
49
+ assert_equal RDoc::RI::Paths.system_dir, path.shift
50
+ assert_equal RDoc::RI::Paths.site_dir, path.shift
51
+ assert_equal RDoc::RI::Paths.home_dir, path.shift
52
+ assert_equal File.join(@nodoc.doc_dir, 'ri'), path.shift
53
+ assert_equal File.join(@rake_10.doc_dir, 'ri'), path.shift
54
+ assert_equal File.join(@rdoc_4_0.doc_dir, 'ri'), path.shift
55
+ assert_equal File.join(@rdoc_3_12.doc_dir, 'ri'), path.shift
56
+ assert_empty path
57
+ end
58
+
59
+ def test_class_gemdirs_latest
60
+ Dir.chdir @tempdir do
61
+ gemdirs = RDoc::RI::Paths.gemdirs :latest
62
+
63
+ expected = [
64
+ File.join(@rake_10.doc_dir, 'ri'),
65
+ File.join(@rdoc_4_0.doc_dir, 'ri'),
66
+ ]
67
+
68
+ assert_equal expected, gemdirs
69
+ end
70
+ end
71
+
72
+ def test_class_gemdirs_legacy
73
+ Dir.chdir @tempdir do
74
+ gemdirs = RDoc::RI::Paths.gemdirs true
75
+
76
+ expected = [
77
+ File.join(@rake_10.doc_dir, 'ri'),
78
+ File.join(@rdoc_4_0.doc_dir, 'ri'),
79
+ ]
80
+
81
+ assert_equal expected, gemdirs
82
+ end
83
+ end
84
+
85
+ def test_class_gemdirs_all
86
+ Dir.chdir @tempdir do
87
+ gemdirs = RDoc::RI::Paths.gemdirs :all
88
+
89
+ expected = [
90
+ File.join(@nodoc.doc_dir, 'ri'),
91
+ File.join(@rake_10.doc_dir, 'ri'),
92
+ File.join(@rdoc_4_0.doc_dir, 'ri'),
93
+ File.join(@rdoc_3_12.doc_dir, 'ri'),
94
+ ]
95
+
96
+ assert_equal expected, gemdirs
97
+ end
98
+ end
99
+
100
+ def test_class_gem_dir
101
+ dir = RDoc::RI::Paths.gem_dir 'rake', '10.0.1'
102
+
103
+ expected = File.join @rake_10.doc_dir, 'ri'
104
+
105
+ assert_equal expected, dir
106
+ end
107
+
108
+ def test_class_home_dir
109
+ dir = RDoc::RI::Paths.home_dir
110
+
111
+ assert_equal RDoc::RI::Paths::HOMEDIR, dir
15
112
  end
16
113
 
17
114
  def test_class_path_nonexistent
18
115
  temp_dir do |dir|
19
116
  nonexistent = File.join dir, 'nonexistent'
20
- path = RDoc::RI::Paths.path true, true, true, true, nonexistent
117
+ dir = RDoc::RI::Paths.path true, true, true, true, nonexistent
21
118
 
22
- refute_includes path, nonexistent
119
+ refute_includes dir, nonexistent
23
120
  end
24
121
  end
25
122
 
26
123
  def test_class_raw_path
27
124
  path = RDoc::RI::Paths.raw_path true, true, true, true
28
125
 
29
- assert_equal RDoc::RI::Paths::SYSDIR, path.shift
30
- assert_equal RDoc::RI::Paths::SITEDIR, path.shift
31
- assert_equal RDoc::RI::Paths::HOMEDIR, path.shift
32
- assert_equal '/nonexistent/gemdir', path.shift
126
+ assert_equal RDoc::RI::Paths.system_dir, path.shift
127
+ assert_equal RDoc::RI::Paths.site_dir, path.shift
128
+ assert_equal RDoc::RI::Paths.home_dir, path.shift
129
+ assert_equal File.join(@rake_10.doc_dir, 'ri'), path.shift
33
130
  end
34
131
 
35
132
  def test_class_raw_path_extra_dirs
36
133
  path = RDoc::RI::Paths.raw_path true, true, true, true, '/nonexistent'
37
134
 
38
- assert_equal '/nonexistent', path.shift
39
- assert_equal RDoc::RI::Paths::SYSDIR, path.shift
40
- assert_equal RDoc::RI::Paths::SITEDIR, path.shift
41
- assert_equal RDoc::RI::Paths::HOMEDIR, path.shift
42
- assert_equal '/nonexistent/gemdir', path.shift
135
+ assert_equal '/nonexistent', path.shift
136
+ assert_equal RDoc::RI::Paths.system_dir, path.shift
137
+ assert_equal RDoc::RI::Paths.site_dir, path.shift
138
+ assert_equal RDoc::RI::Paths.home_dir, path.shift
139
+ assert_equal File.join(@rake_10.doc_dir, 'ri'), path.shift
140
+ end
141
+
142
+ def test_class_site_dir
143
+ dir = RDoc::RI::Paths.site_dir
144
+
145
+ assert_equal File.join(RDoc::RI::Paths::BASE, 'site'), dir
146
+ end
147
+
148
+ def test_class_system_dir
149
+ dir = RDoc::RI::Paths.system_dir
150
+
151
+ assert_equal File.join(RDoc::RI::Paths::BASE, 'system'), dir
43
152
  end
44
153
 
45
154
  end
@@ -1,5 +1,3 @@
1
- # coding: UTF-8
2
-
3
1
  require 'rdoc/test_case'
4
2
 
5
3
  class TestRDocRubyLex < RDoc::TestCase
@@ -70,8 +68,7 @@ end
70
68
  @TK::TkIDENTIFIER.new( 4, 1, 4, 'x'),
71
69
  @TK::TkNL .new( 5, 1, 5, "\n"),
72
70
  @TK::TkSPACE .new( 6, 2, 0, ' '),
73
- @TK::TkHEREDOC .new( 8, 2, 2,
74
- %Q{<<E\nLine 1\nLine 2\nE}),
71
+ @TK::TkSTRING .new( 8, 2, 2, %Q{"Line 1\nLine 2\n"}),
75
72
  @TK::TkNL .new(27, 5, 28, "\n"),
76
73
  @TK::TkEND .new(28, 6, 0, 'end'),
77
74
  @TK::TkNL .new(31, 6, 28, "\n"),
@@ -97,56 +94,12 @@ end
97
94
  assert_equal expected, tokens
98
95
  end
99
96
 
100
- def test_class_tokenize_heredoc_CR_NL
101
- tokens = RDoc::RubyLex.tokenize <<-RUBY, nil
102
- string = <<-STRING\r
103
- Line 1\r
104
- Line 2\r
105
- STRING\r
106
- RUBY
107
-
108
- expected = [
109
- @TK::TkIDENTIFIER.new( 0, 1, 0, 'string'),
110
- @TK::TkSPACE .new( 6, 1, 6, ' '),
111
- @TK::TkASSIGN .new( 7, 1, 7, '='),
112
- @TK::TkSPACE .new( 8, 1, 8, ' '),
113
- @TK::TkHEREDOC .new( 9, 1, 9,
114
- %Q{<<-STRING\nLine 1\nLine 2\n STRING}),
115
- @TK::TkSPACE .new(44, 4, 45, "\r"),
116
- @TK::TkNL .new(45, 4, 46, "\n"),
117
- ]
118
-
119
- assert_equal expected, tokens
120
- end
121
-
122
- def test_class_tokenize_heredoc_call
123
- tokens = RDoc::RubyLex.tokenize <<-'RUBY', nil
124
- string = <<-STRING.chomp
125
- Line 1
126
- Line 2
127
- STRING
128
- RUBY
129
-
130
- expected = [
131
- @TK::TkIDENTIFIER.new( 0, 1, 0, 'string'),
132
- @TK::TkSPACE .new( 6, 1, 6, ' '),
133
- @TK::TkASSIGN .new( 7, 1, 7, '='),
134
- @TK::TkSPACE .new( 8, 1, 8, ' '),
135
- @TK::TkSTRING .new( 9, 1, 9, %Q{"Line 1\nLine 2\n"}),
136
- @TK::TkDOT .new(41, 4, 42, '.'),
137
- @TK::TkIDENTIFIER.new(42, 4, 43, 'chomp'),
138
- @TK::TkNL .new(47, 4, 48, "\n"),
139
- ]
140
-
141
- assert_equal expected, tokens
142
- end
143
-
144
97
  def test_class_tokenize_heredoc_indent
145
98
  tokens = RDoc::RubyLex.tokenize <<-'RUBY', nil
146
99
  string = <<-STRING
147
100
  Line 1
148
101
  Line 2
149
- STRING
102
+ STRING
150
103
  RUBY
151
104
 
152
105
  expected = [
@@ -154,9 +107,8 @@ Line 2
154
107
  @TK::TkSPACE .new( 6, 1, 6, ' '),
155
108
  @TK::TkASSIGN .new( 7, 1, 7, '='),
156
109
  @TK::TkSPACE .new( 8, 1, 8, ' '),
157
- @TK::TkHEREDOC .new( 9, 1, 9,
158
- %Q{<<-STRING\nLine 1\nLine 2\n STRING}),
159
- @TK::TkNL .new(41, 4, 42, "\n"),
110
+ @TK::TkSTRING .new( 9, 1, 9, %Q{"Line 1\nLine 2\n"}),
111
+ @TK::TkNL .new(39, 4, 40, "\n"),
160
112
  ]
161
113
 
162
114
  assert_equal expected, tokens
@@ -174,21 +126,13 @@ U
174
126
  @TK::TkSPACE .new( 1, 1, 1, ' '),
175
127
  @TK::TkIDENTIFIER.new( 2, 1, 2, 'b'),
176
128
  @TK::TkSPACE .new( 3, 1, 3, ' '),
177
- @TK::TkHEREDOC .new( 4, 1, 4, %Q{<<-U\n%N\nU}),
129
+ @TK::TkSTRING .new( 4, 1, 4, %Q{"%N\n"}),
178
130
  @TK::TkNL .new(13, 3, 14, "\n"),
179
131
  ]
180
132
 
181
133
  assert_equal expected, tokens
182
134
  end
183
135
 
184
- def test_class_tokenize_identifier_high_unicode
185
- tokens = RDoc::RubyLex.tokenize '𝖒', nil
186
-
187
- expected = @TK::TkIDENTIFIER.new(0, 1, 0, '𝖒')
188
-
189
- assert_equal expected, tokens.first
190
- end
191
-
192
136
  def test_class_tokenize_percent_1
193
137
  tokens = RDoc::RubyLex.tokenize 'v%10==10', nil
194
138
 
@@ -0,0 +1,19 @@
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
+
@@ -12,7 +12,7 @@ class TestRDocRubygemsHook < Gem::TestCase
12
12
 
13
13
  @a = quick_spec 'a'
14
14
 
15
- @rdoc = RDoc::RubygemsHook.new @a
15
+ @hook = RDoc::RubygemsHook.new @a
16
16
 
17
17
  begin
18
18
  RDoc::RubygemsHook.load_rdoc
@@ -24,8 +24,8 @@ class TestRDocRubygemsHook < Gem::TestCase
24
24
  end
25
25
 
26
26
  def test_initialize
27
- assert @rdoc.generate_rdoc
28
- assert @rdoc.generate_ri
27
+ assert @hook.generate_rdoc
28
+ assert @hook.generate_ri
29
29
 
30
30
  rdoc = RDoc::RubygemsHook.new @a, false, false
31
31
 
@@ -41,7 +41,7 @@ class TestRDocRubygemsHook < Gem::TestCase
41
41
  -p
42
42
  ]
43
43
 
44
- @rdoc.delete_legacy_args args
44
+ @hook.delete_legacy_args args
45
45
 
46
46
  assert_empty args
47
47
  end
@@ -50,24 +50,26 @@ class TestRDocRubygemsHook < Gem::TestCase
50
50
  options = RDoc::Options.new
51
51
  options.files = []
52
52
 
53
- @rdoc.instance_variable_set :@rdoc, @rdoc.new_rdoc
54
- @rdoc.instance_variable_set :@file_info, []
53
+ rdoc = @hook.new_rdoc
54
+ rdoc.store = RDoc::Store.new
55
+ @hook.instance_variable_set :@rdoc, rdoc
56
+ @hook.instance_variable_set :@file_info, []
55
57
 
56
- @rdoc.document 'darkfish', options, @a.doc_dir('rdoc')
58
+ @hook.document 'darkfish', options, @a.doc_dir('rdoc')
57
59
 
58
- assert @rdoc.rdoc_installed?
60
+ assert @hook.rdoc_installed?
59
61
  end
60
62
 
61
63
  def test_generate
62
64
  FileUtils.mkdir_p @a.doc_dir
63
65
  FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
64
66
 
65
- @rdoc.generate
67
+ @hook.generate
66
68
 
67
- assert @rdoc.rdoc_installed?
68
- assert @rdoc.ri_installed?
69
+ assert @hook.rdoc_installed?
70
+ assert @hook.ri_installed?
69
71
 
70
- rdoc = @rdoc.instance_variable_get :@rdoc
72
+ rdoc = @hook.instance_variable_get :@rdoc
71
73
 
72
74
  refute rdoc.options.hyperlink_all
73
75
  end
@@ -78,9 +80,9 @@ class TestRDocRubygemsHook < Gem::TestCase
78
80
  FileUtils.mkdir_p @a.doc_dir
79
81
  FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
80
82
 
81
- @rdoc.generate
83
+ @hook.generate
82
84
 
83
- rdoc = @rdoc.instance_variable_get :@rdoc
85
+ rdoc = @hook.instance_variable_get :@rdoc
84
86
 
85
87
  assert rdoc.options.hyperlink_all
86
88
  end
@@ -91,21 +93,35 @@ class TestRDocRubygemsHook < Gem::TestCase
91
93
  FileUtils.mkdir_p @a.doc_dir
92
94
  FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
93
95
 
94
- @rdoc.generate
96
+ @hook.generate
95
97
 
96
- rdoc = @rdoc.instance_variable_get :@rdoc
98
+ rdoc = @hook.instance_variable_get :@rdoc
97
99
 
98
100
  assert rdoc.options.hyperlink_all
99
101
  end
100
102
 
103
+ def test_generate_default_gem
104
+ skip 'RubyGems 2 required' unless @a.respond_to? :default_gem?
105
+ @a.loaded_from =
106
+ File.join Gem::Specification.default_specifications_dir, 'a.gemspec'
107
+
108
+ FileUtils.mkdir_p @a.doc_dir
109
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
110
+
111
+ @hook.generate
112
+
113
+ refute @hook.rdoc_installed?
114
+ refute @hook.ri_installed?
115
+ end
116
+
101
117
  def test_generate_disabled
102
- @rdoc.generate_rdoc = false
103
- @rdoc.generate_ri = false
118
+ @hook.generate_rdoc = false
119
+ @hook.generate_ri = false
104
120
 
105
- @rdoc.generate
121
+ @hook.generate
106
122
 
107
- refute @rdoc.rdoc_installed?
108
- refute @rdoc.ri_installed?
123
+ refute @hook.rdoc_installed?
124
+ refute @hook.ri_installed?
109
125
  end
110
126
 
111
127
  def test_generate_force
@@ -113,9 +129,9 @@ class TestRDocRubygemsHook < Gem::TestCase
113
129
  FileUtils.mkdir_p @a.doc_dir 'rdoc'
114
130
  FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
115
131
 
116
- @rdoc.force = true
132
+ @hook.force = true
117
133
 
118
- @rdoc.generate
134
+ @hook.generate
119
135
 
120
136
  assert_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
121
137
  assert_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
@@ -126,32 +142,32 @@ class TestRDocRubygemsHook < Gem::TestCase
126
142
  FileUtils.mkdir_p @a.doc_dir 'rdoc'
127
143
  FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
128
144
 
129
- @rdoc.generate
145
+ @hook.generate
130
146
 
131
147
  refute_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
132
148
  refute_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
133
149
  end
134
150
 
135
151
  def test_new_rdoc
136
- assert_kind_of RDoc::RDoc, @rdoc.new_rdoc
152
+ assert_kind_of RDoc::RDoc, @hook.new_rdoc
137
153
  end
138
154
 
139
155
  def test_rdoc_installed?
140
- refute @rdoc.rdoc_installed?
156
+ refute @hook.rdoc_installed?
141
157
 
142
158
  FileUtils.mkdir_p @a.doc_dir 'rdoc'
143
159
 
144
- assert @rdoc.rdoc_installed?
160
+ assert @hook.rdoc_installed?
145
161
  end
146
162
 
147
163
  def test_remove
148
164
  FileUtils.mkdir_p @a.doc_dir 'rdoc'
149
165
  FileUtils.mkdir_p @a.doc_dir 'ri'
150
166
 
151
- @rdoc.remove
167
+ @hook.remove
152
168
 
153
- refute @rdoc.rdoc_installed?
154
- refute @rdoc.ri_installed?
169
+ refute @hook.rdoc_installed?
170
+ refute @hook.ri_installed?
155
171
 
156
172
  assert_path_exists @a.doc_dir
157
173
  end
@@ -162,7 +178,7 @@ class TestRDocRubygemsHook < Gem::TestCase
162
178
  FileUtils.chmod 0, @a.base_dir
163
179
 
164
180
  e = assert_raises Gem::FilePermissionError do
165
- @rdoc.remove
181
+ @hook.remove
166
182
  end
167
183
 
168
184
  assert_equal @a.base_dir, e.directory
@@ -171,31 +187,36 @@ class TestRDocRubygemsHook < Gem::TestCase
171
187
  end
172
188
 
173
189
  def test_ri_installed?
174
- refute @rdoc.ri_installed?
190
+ refute @hook.ri_installed?
175
191
 
176
192
  FileUtils.mkdir_p @a.doc_dir 'ri'
177
193
 
178
- assert @rdoc.ri_installed?
194
+ assert @hook.ri_installed?
179
195
  end
180
196
 
181
197
  def test_setup
182
- @rdoc.setup
198
+ @hook.setup
183
199
 
184
200
  assert_path_exists @a.doc_dir
185
201
  end
186
202
 
187
203
  def test_setup_unwritable
188
204
  skip 'chmod not supported' if Gem.win_platform?
189
- FileUtils.mkdir_p @a.doc_dir
190
- FileUtils.chmod 0, @a.doc_dir
191
-
192
- e = assert_raises Gem::FilePermissionError do
193
- @rdoc.setup
205
+ begin
206
+ FileUtils.mkdir_p @a.doc_dir
207
+ FileUtils.chmod 0, @a.doc_dir
208
+
209
+ e = assert_raises Gem::FilePermissionError do
210
+ @hook.setup
211
+ end
212
+
213
+ assert_equal @a.doc_dir, e.directory
214
+ ensure
215
+ if File.exist? @a.doc_dir
216
+ FileUtils.chmod 0755, @a.doc_dir
217
+ FileUtils.rm_r @a.doc_dir
218
+ end
194
219
  end
195
-
196
- assert_equal @a.doc_dir, e.directory
197
- ensure
198
- FileUtils.chmod 0755, @a.doc_dir
199
220
  end
200
221
 
201
222
  end