rdoc 4.2.1 → 6.3.1

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 (277) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.rdoc +8 -7
  3. data/Gemfile +12 -0
  4. data/History.rdoc +48 -4
  5. data/LEGAL.rdoc +2 -2
  6. data/README.rdoc +5 -5
  7. data/Rakefile +73 -155
  8. data/bin/console +7 -0
  9. data/bin/setup +6 -0
  10. data/{bin → exe}/rdoc +0 -0
  11. data/{bin → exe}/ri +0 -0
  12. data/lib/rdoc/alias.rb +1 -0
  13. data/lib/rdoc/anon_class.rb +1 -0
  14. data/lib/rdoc/any_method.rb +59 -14
  15. data/lib/rdoc/attr.rb +1 -0
  16. data/lib/rdoc/class_module.rb +5 -2
  17. data/lib/rdoc/code_object.rb +3 -11
  18. data/lib/rdoc/code_objects.rb +1 -0
  19. data/lib/rdoc/comment.rb +32 -11
  20. data/lib/rdoc/constant.rb +3 -2
  21. data/lib/rdoc/context/section.rb +7 -13
  22. data/lib/rdoc/context.rb +78 -23
  23. data/lib/rdoc/cross_reference.rb +33 -14
  24. data/lib/rdoc/encoding.rb +92 -55
  25. data/lib/rdoc/erb_partial.rb +2 -1
  26. data/lib/rdoc/erbio.rb +8 -3
  27. data/lib/rdoc/extend.rb +1 -0
  28. data/lib/rdoc/generator/darkfish.rb +62 -32
  29. data/lib/rdoc/generator/json_index.rb +8 -5
  30. data/lib/rdoc/generator/markup.rb +3 -12
  31. data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  32. data/lib/rdoc/generator/pot/po.rb +84 -0
  33. data/lib/rdoc/generator/pot/po_entry.rb +141 -0
  34. data/lib/rdoc/generator/pot.rb +4 -3
  35. data/lib/rdoc/generator/ri.rb +1 -0
  36. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
  37. data/lib/rdoc/generator/template/darkfish/_head.rhtml +11 -8
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
  41. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
  42. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
  43. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
  44. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +5 -5
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
  49. data/lib/rdoc/generator/template/darkfish/class.rhtml +45 -47
  50. data/lib/rdoc/generator/template/darkfish/css/fonts.css +6 -6
  51. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +55 -6
  52. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
  53. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +23 -100
  54. data/lib/rdoc/generator/template/darkfish/js/search.js +32 -31
  55. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
  56. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
  57. data/lib/rdoc/generator/template/json_index/js/navigation.js +4 -41
  58. data/lib/rdoc/generator/template/json_index/js/searcher.js +7 -6
  59. data/lib/rdoc/generator.rb +1 -1
  60. data/lib/rdoc/ghost_method.rb +1 -0
  61. data/lib/rdoc/i18n/locale.rb +2 -1
  62. data/lib/rdoc/i18n/text.rb +5 -4
  63. data/lib/rdoc/i18n.rb +3 -2
  64. data/lib/rdoc/include.rb +1 -0
  65. data/lib/rdoc/known_classes.rb +1 -0
  66. data/lib/rdoc/markdown/entities.rb +1 -0
  67. data/lib/rdoc/markdown/{literals_1_9.kpeg → literals.kpeg} +1 -0
  68. data/lib/rdoc/markdown/{literals_1_9.rb → literals.rb} +1 -4
  69. data/lib/rdoc/markdown.kpeg +94 -51
  70. data/lib/rdoc/markdown.rb +1171 -619
  71. data/lib/rdoc/markup/attr_changer.rb +1 -0
  72. data/lib/rdoc/markup/attr_span.rb +9 -2
  73. data/lib/rdoc/markup/attribute_manager.rb +115 -49
  74. data/lib/rdoc/markup/attributes.rb +7 -6
  75. data/lib/rdoc/markup/blank_line.rb +1 -0
  76. data/lib/rdoc/markup/block_quote.rb +1 -0
  77. data/lib/rdoc/markup/document.rb +1 -0
  78. data/lib/rdoc/markup/formatter.rb +25 -23
  79. data/lib/rdoc/markup/hard_break.rb +1 -0
  80. data/lib/rdoc/markup/heading.rb +4 -3
  81. data/lib/rdoc/markup/include.rb +1 -0
  82. data/lib/rdoc/markup/indented_paragraph.rb +1 -0
  83. data/lib/rdoc/markup/list.rb +1 -0
  84. data/lib/rdoc/markup/list_item.rb +1 -0
  85. data/lib/rdoc/markup/paragraph.rb +1 -0
  86. data/lib/rdoc/markup/parser.rb +78 -61
  87. data/lib/rdoc/markup/pre_process.rb +12 -9
  88. data/lib/rdoc/markup/raw.rb +1 -0
  89. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  90. data/lib/rdoc/markup/rule.rb +1 -0
  91. data/lib/rdoc/markup/to_ansi.rb +1 -0
  92. data/lib/rdoc/markup/to_bs.rb +4 -5
  93. data/lib/rdoc/markup/to_html.rb +71 -25
  94. data/lib/rdoc/markup/to_html_crossref.rb +41 -25
  95. data/lib/rdoc/markup/to_html_snippet.rb +10 -9
  96. data/lib/rdoc/markup/to_joined_paragraph.rb +7 -31
  97. data/lib/rdoc/markup/to_label.rb +10 -9
  98. data/lib/rdoc/markup/to_markdown.rb +9 -8
  99. data/lib/rdoc/markup/to_rdoc.rb +35 -6
  100. data/lib/rdoc/markup/to_table_of_contents.rb +2 -0
  101. data/lib/rdoc/markup/to_test.rb +1 -0
  102. data/lib/rdoc/markup/to_tt_only.rb +3 -2
  103. data/lib/rdoc/markup/verbatim.rb +1 -0
  104. data/lib/rdoc/markup.rb +14 -16
  105. data/lib/rdoc/meta_method.rb +1 -0
  106. data/lib/rdoc/method_attr.rb +2 -1
  107. data/lib/rdoc/mixin.rb +1 -0
  108. data/lib/rdoc/normal_class.rb +3 -2
  109. data/lib/rdoc/normal_module.rb +1 -0
  110. data/lib/rdoc/options.rb +92 -58
  111. data/lib/rdoc/parser/c.rb +219 -223
  112. data/lib/rdoc/parser/changelog.rb +155 -18
  113. data/lib/rdoc/parser/markdown.rb +1 -0
  114. data/lib/rdoc/parser/rd.rb +1 -0
  115. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  116. data/lib/rdoc/parser/ruby.rb +635 -468
  117. data/lib/rdoc/parser/ruby_tools.rb +33 -33
  118. data/lib/rdoc/parser/simple.rb +3 -3
  119. data/lib/rdoc/parser/text.rb +1 -0
  120. data/lib/rdoc/parser.rb +17 -50
  121. data/lib/rdoc/rd/block_parser.rb +66 -65
  122. data/lib/rdoc/rd/block_parser.ry +3 -3
  123. data/lib/rdoc/rd/inline.rb +5 -4
  124. data/lib/rdoc/rd/inline_parser.rb +52 -51
  125. data/lib/rdoc/rd/inline_parser.ry +1 -1
  126. data/lib/rdoc/rd.rb +1 -0
  127. data/lib/rdoc/rdoc.rb +68 -63
  128. data/lib/rdoc/require.rb +1 -0
  129. data/lib/rdoc/ri/driver.rb +133 -58
  130. data/lib/rdoc/ri/formatter.rb +1 -0
  131. data/lib/rdoc/ri/paths.rb +4 -20
  132. data/lib/rdoc/ri/store.rb +1 -0
  133. data/lib/rdoc/ri/task.rb +71 -0
  134. data/lib/rdoc/ri.rb +1 -0
  135. data/lib/rdoc/rubygems_hook.rb +5 -12
  136. data/lib/rdoc/servlet.rb +24 -14
  137. data/lib/rdoc/single_class.rb +1 -0
  138. data/lib/rdoc/stats/normal.rb +20 -21
  139. data/lib/rdoc/stats/quiet.rb +1 -0
  140. data/lib/rdoc/stats/verbose.rb +1 -0
  141. data/lib/rdoc/stats.rb +1 -0
  142. data/lib/rdoc/store.rb +41 -41
  143. data/lib/rdoc/task.rb +2 -3
  144. data/lib/rdoc/text.rb +19 -38
  145. data/lib/rdoc/token_stream.rb +56 -32
  146. data/lib/rdoc/tom_doc.rb +17 -11
  147. data/lib/rdoc/top_level.rb +9 -2
  148. data/lib/rdoc/version.rb +8 -0
  149. data/lib/rdoc.rb +24 -10
  150. data/man/ri.1 +247 -0
  151. data/rdoc.gemspec +248 -0
  152. metadata +43 -236
  153. data/.autotest +0 -24
  154. data/.document +0 -5
  155. data/Manifest.txt +0 -306
  156. data/lib/gauntlet_rdoc.rb +0 -84
  157. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
  158. data/lib/rdoc/markdown/literals_1_8.kpeg +0 -18
  159. data/lib/rdoc/markdown/literals_1_8.rb +0 -416
  160. data/lib/rdoc/markup/formatter_test_case.rb +0 -767
  161. data/lib/rdoc/markup/inline.rb +0 -1
  162. data/lib/rdoc/markup/special.rb +0 -40
  163. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -114
  164. data/lib/rdoc/ruby_lex.rb +0 -1377
  165. data/lib/rdoc/ruby_token.rb +0 -460
  166. data/lib/rdoc/test_case.rb +0 -217
  167. data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +0 -21
  168. data/test/MarkdownTest_1.0.3/Auto links.text +0 -13
  169. data/test/MarkdownTest_1.0.3/Backslash escapes.text +0 -120
  170. data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +0 -11
  171. data/test/MarkdownTest_1.0.3/Code Blocks.text +0 -14
  172. data/test/MarkdownTest_1.0.3/Code Spans.text +0 -6
  173. data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +0 -8
  174. data/test/MarkdownTest_1.0.3/Horizontal rules.text +0 -67
  175. data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +0 -15
  176. data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +0 -69
  177. data/test/MarkdownTest_1.0.3/Inline HTML comments.text +0 -13
  178. data/test/MarkdownTest_1.0.3/Links, inline style.text +0 -12
  179. data/test/MarkdownTest_1.0.3/Links, reference style.text +0 -71
  180. data/test/MarkdownTest_1.0.3/Links, shortcut references.text +0 -20
  181. data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +0 -7
  182. data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +0 -306
  183. data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +0 -888
  184. data/test/MarkdownTest_1.0.3/Nested blockquotes.text +0 -5
  185. data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +0 -131
  186. data/test/MarkdownTest_1.0.3/Strong and em together.text +0 -7
  187. data/test/MarkdownTest_1.0.3/Tabs.text +0 -21
  188. data/test/MarkdownTest_1.0.3/Tidyness.text +0 -5
  189. data/test/README +0 -1
  190. data/test/binary.dat +0 -0
  191. data/test/hidden.zip.txt +0 -1
  192. data/test/test.ja.largedoc +0 -3
  193. data/test/test.ja.rdoc +0 -10
  194. data/test/test.ja.txt +0 -8
  195. data/test/test.txt +0 -1
  196. data/test/test_rdoc_alias.rb +0 -13
  197. data/test/test_rdoc_any_method.rb +0 -460
  198. data/test/test_rdoc_attr.rb +0 -190
  199. data/test/test_rdoc_class_module.rb +0 -1492
  200. data/test/test_rdoc_code_object.rb +0 -450
  201. data/test/test_rdoc_comment.rb +0 -504
  202. data/test/test_rdoc_constant.rb +0 -181
  203. data/test/test_rdoc_context.rb +0 -901
  204. data/test/test_rdoc_context_section.rb +0 -130
  205. data/test/test_rdoc_cross_reference.rb +0 -192
  206. data/test/test_rdoc_encoding.rb +0 -227
  207. data/test/test_rdoc_extend.rb +0 -94
  208. data/test/test_rdoc_generator_darkfish.rb +0 -229
  209. data/test/test_rdoc_generator_json_index.rb +0 -324
  210. data/test/test_rdoc_generator_markup.rb +0 -59
  211. data/test/test_rdoc_generator_pot.rb +0 -91
  212. data/test/test_rdoc_generator_pot_po.rb +0 -51
  213. data/test/test_rdoc_generator_pot_po_entry.rb +0 -139
  214. data/test/test_rdoc_generator_ri.rb +0 -78
  215. data/test/test_rdoc_i18n_locale.rb +0 -73
  216. data/test/test_rdoc_i18n_text.rb +0 -123
  217. data/test/test_rdoc_include.rb +0 -108
  218. data/test/test_rdoc_markdown.rb +0 -980
  219. data/test/test_rdoc_markdown_test.rb +0 -1884
  220. data/test/test_rdoc_markup.rb +0 -95
  221. data/test/test_rdoc_markup_attribute_manager.rb +0 -364
  222. data/test/test_rdoc_markup_attributes.rb +0 -39
  223. data/test/test_rdoc_markup_document.rb +0 -207
  224. data/test/test_rdoc_markup_formatter.rb +0 -175
  225. data/test/test_rdoc_markup_hard_break.rb +0 -31
  226. data/test/test_rdoc_markup_heading.rb +0 -29
  227. data/test/test_rdoc_markup_include.rb +0 -19
  228. data/test/test_rdoc_markup_indented_paragraph.rb +0 -53
  229. data/test/test_rdoc_markup_paragraph.rb +0 -32
  230. data/test/test_rdoc_markup_parser.rb +0 -1680
  231. data/test/test_rdoc_markup_pre_process.rb +0 -473
  232. data/test/test_rdoc_markup_raw.rb +0 -22
  233. data/test/test_rdoc_markup_to_ansi.rb +0 -369
  234. data/test/test_rdoc_markup_to_bs.rb +0 -366
  235. data/test/test_rdoc_markup_to_html.rb +0 -662
  236. data/test/test_rdoc_markup_to_html_crossref.rb +0 -225
  237. data/test/test_rdoc_markup_to_html_snippet.rb +0 -711
  238. data/test/test_rdoc_markup_to_joined_paragraph.rb +0 -32
  239. data/test/test_rdoc_markup_to_label.rb +0 -112
  240. data/test/test_rdoc_markup_to_markdown.rb +0 -389
  241. data/test/test_rdoc_markup_to_rdoc.rb +0 -377
  242. data/test/test_rdoc_markup_to_table_of_contents.rb +0 -126
  243. data/test/test_rdoc_markup_to_tt_only.rb +0 -246
  244. data/test/test_rdoc_markup_verbatim.rb +0 -29
  245. data/test/test_rdoc_method_attr.rb +0 -193
  246. data/test/test_rdoc_normal_class.rb +0 -47
  247. data/test/test_rdoc_normal_module.rb +0 -42
  248. data/test/test_rdoc_options.rb +0 -766
  249. data/test/test_rdoc_parser.rb +0 -327
  250. data/test/test_rdoc_parser_c.rb +0 -1896
  251. data/test/test_rdoc_parser_changelog.rb +0 -315
  252. data/test/test_rdoc_parser_markdown.rb +0 -61
  253. data/test/test_rdoc_parser_rd.rb +0 -55
  254. data/test/test_rdoc_parser_ruby.rb +0 -3322
  255. data/test/test_rdoc_parser_simple.rb +0 -115
  256. data/test/test_rdoc_rd.rb +0 -30
  257. data/test/test_rdoc_rd_block_parser.rb +0 -535
  258. data/test/test_rdoc_rd_inline.rb +0 -63
  259. data/test/test_rdoc_rd_inline_parser.rb +0 -177
  260. data/test/test_rdoc_rdoc.rb +0 -455
  261. data/test/test_rdoc_require.rb +0 -25
  262. data/test/test_rdoc_ri_driver.rb +0 -1436
  263. data/test/test_rdoc_ri_paths.rb +0 -155
  264. data/test/test_rdoc_ruby_lex.rb +0 -421
  265. data/test/test_rdoc_ruby_token.rb +0 -19
  266. data/test/test_rdoc_rubygems_hook.rb +0 -251
  267. data/test/test_rdoc_servlet.rb +0 -534
  268. data/test/test_rdoc_single_class.rb +0 -20
  269. data/test/test_rdoc_stats.rb +0 -722
  270. data/test/test_rdoc_store.rb +0 -993
  271. data/test/test_rdoc_task.rb +0 -173
  272. data/test/test_rdoc_text.rb +0 -557
  273. data/test/test_rdoc_token_stream.rb +0 -42
  274. data/test/test_rdoc_tom_doc.rb +0 -520
  275. data/test/test_rdoc_top_level.rb +0 -287
  276. data/test/xref_data.rb +0 -76
  277. data/test/xref_test_case.rb +0 -67
data/lib/rdoc/require.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # A file loaded by \#require
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'abbrev'
2
3
  require 'optparse'
3
4
 
@@ -16,7 +17,7 @@ require 'rdoc'
16
17
  ##
17
18
  # For RubyGems backwards compatibility
18
19
 
19
- require 'rdoc/ri/formatter'
20
+ require_relative 'formatter'
20
21
 
21
22
  ##
22
23
  # The RI driver implements the command-line ri tool.
@@ -46,13 +47,24 @@ class RDoc::RI::Driver
46
47
 
47
48
  class NotFoundError < Error
48
49
 
50
+ def initialize(klass, suggestions = nil) # :nodoc:
51
+ @klass = klass
52
+ @suggestions = suggestions
53
+ end
54
+
49
55
  ##
50
56
  # Name that wasn't found
51
57
 
52
- alias name message
58
+ def name
59
+ @klass
60
+ end
53
61
 
54
62
  def message # :nodoc:
55
- "Nothing known about #{super}"
63
+ str = "Nothing known about #{@klass}"
64
+ if @suggestions and !@suggestions.empty?
65
+ str += "\nDid you mean? #{@suggestions.join("\n ")}"
66
+ end
67
+ str
56
68
  end
57
69
  end
58
70
 
@@ -79,7 +91,6 @@ class RDoc::RI::Driver
79
91
  options[:interactive] = false
80
92
  options[:profile] = false
81
93
  options[:show_all] = false
82
- options[:use_cache] = true
83
94
  options[:use_stdout] = !$stdout.tty?
84
95
  options[:width] = 72
85
96
 
@@ -99,7 +110,7 @@ class RDoc::RI::Driver
99
110
  def self.dump data_path
100
111
  require 'pp'
101
112
 
102
- open data_path, 'rb' do |io|
113
+ File.open data_path, 'rb' do |io|
103
114
  pp Marshal.load(io.read)
104
115
  end
105
116
  end
@@ -121,7 +132,7 @@ class RDoc::RI::Driver
121
132
  opt.summary_indent = ' ' * 4
122
133
 
123
134
  opt.banner = <<-EOT
124
- Usage: #{opt.program_name} [options] [names...]
135
+ Usage: #{opt.program_name} [options] [name ...]
125
136
 
126
137
  Where name can be:
127
138
 
@@ -131,8 +142,8 @@ Where name can be:
131
142
 
132
143
  gem_name: | gem_name:README | gem_name:History
133
144
 
134
- All class names may be abbreviated to their minimum unambiguous form. If a name
135
- is ambiguous, all valid options will be listed.
145
+ All class names may be abbreviated to their minimum unambiguous form.
146
+ If a name is ambiguous, all valid options will be listed.
136
147
 
137
148
  A '.' matches either class or instance methods, while #method
138
149
  matches only instance and ::method matches only class methods.
@@ -150,23 +161,23 @@ For example:
150
161
  #{opt.program_name} zip
151
162
  #{opt.program_name} rdoc:README
152
163
 
153
- Note that shell quoting or escaping may be required for method names containing
154
- punctuation:
164
+ Note that shell quoting or escaping may be required for method names
165
+ containing punctuation:
155
166
 
156
167
  #{opt.program_name} 'Array.[]'
157
168
  #{opt.program_name} compact\\!
158
169
 
159
- To see the default directories ri will search, run:
170
+ To see the default directories #{opt.program_name} will search, run:
160
171
 
161
172
  #{opt.program_name} --list-doc-dirs
162
173
 
163
- Specifying the --system, --site, --home, --gems or --doc-dir options will
164
- limit ri to searching only the specified directories.
174
+ Specifying the --system, --site, --home, --gems, or --doc-dir options
175
+ will limit ri to searching only the specified directories.
165
176
 
166
- ri options may be set in the 'RI' environment variable.
177
+ ri options may be set in the RI environment variable.
167
178
 
168
- The ri pager can be set with the 'RI_PAGER' environment variable or the
169
- 'PAGER' environment variable.
179
+ The ri pager can be set with the RI_PAGER environment variable
180
+ or the PAGER environment variable.
170
181
  EOT
171
182
 
172
183
  opt.separator nil
@@ -198,15 +209,15 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
198
209
  opt.separator nil
199
210
 
200
211
  opt.on("--[no-]pager",
201
- "Send output directly to stdout,",
202
- "rather than to a pager.") do |use_pager|
212
+ "Send output to a pager,",
213
+ "rather than directly to stdout.") do |use_pager|
203
214
  options[:use_stdout] = !use_pager
204
215
  end
205
216
 
206
217
  opt.separator nil
207
218
 
208
219
  opt.on("-T",
209
- "Synonym for --no-pager") do
220
+ "Synonym for --no-pager.") do
210
221
  options[:use_stdout] = true
211
222
  end
212
223
 
@@ -219,7 +230,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
219
230
 
220
231
  opt.separator nil
221
232
 
222
- opt.on("--server [PORT]", Integer,
233
+ opt.on("--server[=PORT]", Integer,
223
234
  "Run RDoc server on the given port.",
224
235
  "The default port is 8214.") do |port|
225
236
  options[:server] = port || 8214
@@ -234,13 +245,29 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
234
245
  formatters -= %w[html label test] # remove useless output formats
235
246
 
236
247
  opt.on("--format=NAME", "-f",
237
- "Uses the selected formatter. The default",
248
+ "Use the selected formatter. The default",
238
249
  "formatter is bs for paged output and ansi",
239
- "otherwise. Valid formatters are:",
240
- formatters.join(' '), formatters) do |value|
250
+ "otherwise. Valid formatters are:",
251
+ "#{formatters.join(', ')}.", formatters) do |value|
241
252
  options[:formatter] = RDoc::Markup.const_get "To#{value.capitalize}"
242
253
  end
243
254
 
255
+ opt.separator nil
256
+
257
+ opt.on("--help", "-h",
258
+ "Show help and exit.") do
259
+ puts opts
260
+ exit
261
+ end
262
+
263
+ opt.separator nil
264
+
265
+ opt.on("--version", "-v",
266
+ "Output version information and exit.") do
267
+ puts "#{opts.program_name} #{opts.version}"
268
+ exit
269
+ end
270
+
244
271
  opt.separator nil
245
272
  opt.separator "Data source options:"
246
273
  opt.separator nil
@@ -272,7 +299,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
272
299
  "Do not include documentation from",
273
300
  "the Ruby standard library, site_lib,",
274
301
  "installed gems, or ~/.rdoc.",
275
- "Use with --doc-dir") do
302
+ "Use with --doc-dir.") do
276
303
  options[:use_system] = false
277
304
  options[:use_site] = false
278
305
  options[:use_gems] = false
@@ -282,8 +309,8 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
282
309
  opt.separator nil
283
310
 
284
311
  opt.on("--[no-]system",
285
- "Include documentation from Ruby's standard",
286
- "library. Defaults to true.") do |value|
312
+ "Include documentation from Ruby's",
313
+ "standard library. Defaults to true.") do |value|
287
314
  options[:use_system] = value
288
315
  end
289
316
 
@@ -317,19 +344,19 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
317
344
  opt.separator nil
318
345
 
319
346
  opt.on("--[no-]profile",
320
- "Run with the ruby profiler") do |value|
347
+ "Run with the ruby profiler.") do |value|
321
348
  options[:profile] = value
322
349
  end
323
350
 
324
351
  opt.separator nil
325
352
 
326
353
  opt.on("--dump=CACHE", File,
327
- "Dumps data from an ri cache or data file") do |value|
354
+ "Dump data from an ri cache or data file.") do |value|
328
355
  options[:dump_path] = value
329
356
  end
330
357
  end
331
358
 
332
- argv = ENV['RI'].to_s.split.concat argv
359
+ argv = ENV['RI'].to_s.split(' ').concat argv
333
360
 
334
361
  opts.parse! argv
335
362
 
@@ -398,6 +425,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
398
425
  @server = options[:server]
399
426
  @use_stdout = options[:use_stdout]
400
427
  @show_all = options[:show_all]
428
+ @width = options[:width]
401
429
 
402
430
  # pager process for jruby
403
431
  @jruby_pager_process = nil
@@ -768,7 +796,9 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
768
796
 
769
797
  def display document
770
798
  page do |io|
771
- text = document.accept formatter(io)
799
+ f = formatter(io)
800
+ f.width = @width if @width and f.respond_to?(:width)
801
+ text = document.accept f
772
802
 
773
803
  io.write text
774
804
  end
@@ -901,27 +931,39 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
901
931
  display out
902
932
  end
903
933
 
934
+ def check_did_you_mean # :nodoc:
935
+ if defined? DidYouMean::SpellChecker
936
+ true
937
+ else
938
+ begin
939
+ require 'did_you_mean'
940
+ if defined? DidYouMean::SpellChecker
941
+ true
942
+ else
943
+ false
944
+ end
945
+ rescue LoadError
946
+ false
947
+ end
948
+ end
949
+ end
950
+
904
951
  ##
905
952
  # Expands abbreviated klass +klass+ into a fully-qualified class. "Zl::Da"
906
953
  # will be expanded to Zlib::DataError.
907
954
 
908
955
  def expand_class klass
909
- klass.split('::').inject '' do |expanded, klass_part|
910
- expanded << '::' unless expanded.empty?
911
- short = expanded << klass_part
912
-
913
- subset = classes.keys.select do |klass_name|
914
- klass_name =~ /^#{expanded}[^:]*$/
956
+ class_names = classes.keys
957
+ ary = class_names.grep(Regexp.new("\\A#{klass.gsub(/(?=::|\z)/, '[^:]*')}\\z"))
958
+ if ary.length != 1 && ary.first != klass
959
+ if check_did_you_mean
960
+ suggestions = DidYouMean::SpellChecker.new(dictionary: class_names).correct(klass)
961
+ raise NotFoundError.new(klass, suggestions)
962
+ else
963
+ raise NotFoundError, klass
915
964
  end
916
-
917
- abbrevs = Abbrev.abbrev subset
918
-
919
- expanded = abbrevs[short]
920
-
921
- raise NotFoundError, short unless expanded
922
-
923
- expanded.dup
924
965
  end
966
+ ary.first
925
967
  end
926
968
 
927
969
  ##
@@ -1088,10 +1130,8 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
1088
1130
 
1089
1131
  return if name.nil? or name.empty?
1090
1132
 
1091
- name = expand_name name.strip
1092
-
1093
1133
  begin
1094
- display_name name
1134
+ display_name expand_name(name.strip)
1095
1135
  rescue NotFoundError => e
1096
1136
  puts e.message
1097
1137
  end
@@ -1188,7 +1228,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
1188
1228
  # +cache+ indicate if it is a class or instance method.
1189
1229
 
1190
1230
  def load_method store, cache, klass, type, name
1191
- methods = store.send(cache)[klass]
1231
+ methods = store.public_send(cache)[klass]
1192
1232
 
1193
1233
  return unless methods
1194
1234
 
@@ -1234,7 +1274,21 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
1234
1274
  def lookup_method name
1235
1275
  found = load_methods_matching name
1236
1276
 
1237
- raise NotFoundError, name if found.empty?
1277
+ if found.empty?
1278
+ if check_did_you_mean
1279
+ methods = []
1280
+ _, _, method_name = parse_name name
1281
+ find_methods name do |store, klass, ancestor, types, method|
1282
+ methods.push(*store.class_methods[klass]) if [:class, :both].include? types
1283
+ methods.push(*store.instance_methods[klass]) if [:instance, :both].include? types
1284
+ end
1285
+ methods = methods.uniq
1286
+ suggestions = DidYouMean::SpellChecker.new(dictionary: methods).correct(method_name)
1287
+ raise NotFoundError.new(name, suggestions)
1288
+ else
1289
+ raise NotFoundError, name
1290
+ end
1291
+ end
1238
1292
 
1239
1293
  filter_methods found, name
1240
1294
  end
@@ -1389,7 +1443,13 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
1389
1443
 
1390
1444
  render_method_arguments out, method.arglists
1391
1445
  render_method_superclass out, method
1392
- render_method_comment out, method
1446
+ if method.is_alias_for
1447
+ al = method.is_alias_for
1448
+ alias_for = store.load_method al.parent_name, "#{al.name_prefix}#{al.name}"
1449
+ render_method_comment out, method, alias_for
1450
+ else
1451
+ render_method_comment out, method
1452
+ end
1393
1453
  end
1394
1454
 
1395
1455
  def render_method_arguments out, arglists # :nodoc:
@@ -1401,10 +1461,22 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
1401
1461
  out << RDoc::Markup::Rule.new(1)
1402
1462
  end
1403
1463
 
1404
- def render_method_comment out, method # :nodoc:
1405
- out << RDoc::Markup::BlankLine.new
1406
- out << method.comment
1407
- out << RDoc::Markup::BlankLine.new
1464
+ def render_method_comment out, method, alias_for = nil# :nodoc:
1465
+ if alias_for
1466
+ unless method.comment.nil? or method.comment.empty?
1467
+ out << RDoc::Markup::BlankLine.new
1468
+ out << method.comment
1469
+ end
1470
+ out << RDoc::Markup::BlankLine.new
1471
+ out << RDoc::Markup::Paragraph.new("(This method is an alias for #{alias_for.full_name}.)")
1472
+ out << RDoc::Markup::BlankLine.new
1473
+ out << alias_for.comment
1474
+ out << RDoc::Markup::BlankLine.new
1475
+ else
1476
+ out << RDoc::Markup::BlankLine.new
1477
+ out << method.comment
1478
+ out << RDoc::Markup::BlankLine.new
1479
+ end
1408
1480
  end
1409
1481
 
1410
1482
  def render_method_superclass out, method # :nodoc:
@@ -1442,14 +1514,14 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
1442
1514
  def setup_pager
1443
1515
  return if @use_stdout
1444
1516
 
1445
- jruby = Object.const_defined?(:RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
1517
+ jruby = RUBY_ENGINE == 'jruby'
1446
1518
 
1447
1519
  pagers = [ENV['RI_PAGER'], ENV['PAGER'], 'pager', 'less', 'more']
1448
1520
 
1449
1521
  pagers.compact.uniq.each do |pager|
1450
1522
  next unless pager
1451
1523
 
1452
- pager_cmd = pager.split.first
1524
+ pager_cmd = pager.split(' ').first
1453
1525
 
1454
1526
  next unless in_path? pager_cmd
1455
1527
 
@@ -1479,7 +1551,11 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
1479
1551
  # Starts a WEBrick server for ri.
1480
1552
 
1481
1553
  def start_server
1482
- require 'webrick'
1554
+ begin
1555
+ require 'webrick'
1556
+ rescue LoadError
1557
+ abort "webrick is not found. You may need to `gem install webrick` to install webrick."
1558
+ end
1483
1559
 
1484
1560
  server = WEBrick::HTTPServer.new :Port => @server
1485
1561
 
@@ -1494,4 +1570,3 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
1494
1570
  end
1495
1571
 
1496
1572
  end
1497
-
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # For RubyGems backwards compatibility
3
4
 
data/lib/rdoc/ri/paths.rb CHANGED
@@ -1,4 +1,5 @@
1
- require 'rdoc/ri'
1
+ # frozen_string_literal: true
2
+ require_relative '../rdoc'
2
3
 
3
4
  ##
4
5
  # The directories where ri data lives. Paths can be enumerated via ::each, or
@@ -11,23 +12,9 @@ module RDoc::RI::Paths
11
12
 
12
13
  version = RbConfig::CONFIG['ruby_version']
13
14
 
14
- BASE = if RbConfig::CONFIG.key? 'ridir' then
15
- File.join RbConfig::CONFIG['ridir'], version
16
- else
17
- File.join RbConfig::CONFIG['datadir'], 'ri', version
18
- end
15
+ BASE = File.join RbConfig::CONFIG['ridir'], version
19
16
 
20
- homedir = begin
21
- File.expand_path('~')
22
- rescue ArgumentError
23
- end
24
-
25
- homedir ||= ENV['HOME'] ||
26
- ENV['USERPROFILE'] || ENV['HOMEPATH'] # for 1.8 compatibility
27
-
28
- HOMEDIR = if homedir then
29
- File.join homedir, ".rdoc"
30
- end
17
+ HOMEDIR = RDoc.home
31
18
  #:startdoc:
32
19
 
33
20
  ##
@@ -81,8 +68,6 @@ module RDoc::RI::Paths
81
68
  # ri documentation.
82
69
 
83
70
  def self.gemdirs filter = :latest
84
- require 'rubygems' unless defined?(Gem)
85
-
86
71
  ri_paths = {}
87
72
 
88
73
  all = Gem::Specification.map do |spec|
@@ -184,4 +169,3 @@ module RDoc::RI::Paths
184
169
  end
185
170
 
186
171
  end
187
-
data/lib/rdoc/ri/store.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module RDoc::RI
2
3
 
3
4
  Store = RDoc::Store # :nodoc:
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+ begin
3
+ gem 'rdoc'
4
+ rescue Gem::LoadError
5
+ end unless defined?(RDoc)
6
+
7
+ require_relative '../task'
8
+
9
+ ##
10
+ # RDoc::RI::Task creates ri data in <code>./.rdoc</code> for your project.
11
+ #
12
+ # It contains the following tasks:
13
+ #
14
+ # [ri]
15
+ # Build ri data
16
+ #
17
+ # [clobber_ri]
18
+ # Delete ri data files. This target is automatically added to the main
19
+ # clobber target.
20
+ #
21
+ # [reri]
22
+ # Rebuild the ri data from scratch even if they are not out of date.
23
+ #
24
+ # Simple example:
25
+ #
26
+ # require 'rdoc/ri/task'
27
+ #
28
+ # RDoc::RI::Task.new do |ri|
29
+ # ri.main = 'README.rdoc'
30
+ # ri.rdoc_files.include 'README.rdoc', 'lib/**/*.rb'
31
+ # end
32
+ #
33
+ # For further configuration details see RDoc::Task.
34
+
35
+ class RDoc::RI::Task < RDoc::Task
36
+
37
+ DEFAULT_NAMES = { # :nodoc:
38
+ :clobber_rdoc => :clobber_ri,
39
+ :rdoc => :ri,
40
+ :rerdoc => :reri,
41
+ }
42
+
43
+ ##
44
+ # Create an ri task with the given name. See RDoc::Task for documentation on
45
+ # setting names.
46
+
47
+ def initialize name = DEFAULT_NAMES # :yield: self
48
+ super
49
+ end
50
+
51
+ def clobber_task_description # :nodoc:
52
+ "Remove RI data files"
53
+ end
54
+
55
+ ##
56
+ # Sets default task values
57
+
58
+ def defaults
59
+ super
60
+
61
+ @rdoc_dir = '.rdoc'
62
+ end
63
+
64
+ def rdoc_task_description # :nodoc:
65
+ 'Build RI data files'
66
+ end
67
+
68
+ def rerdoc_task_description # :nodoc:
69
+ 'Rebuild RI data files'
70
+ end
71
+ end
data/lib/rdoc/ri.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rdoc'
2
3
 
3
4
  ##
@@ -1,4 +1,4 @@
1
- require 'rubygems'
1
+ # frozen_string_literal: true
2
2
  require 'rubygems/user_interaction'
3
3
  require 'fileutils'
4
4
  require 'rdoc'
@@ -70,7 +70,7 @@ class RDoc::RubygemsHook
70
70
  def self.load_rdoc
71
71
  return if @rdoc_version
72
72
 
73
- require 'rdoc/rdoc'
73
+ require_relative 'rdoc'
74
74
 
75
75
  @rdoc_version = Gem::Version.new ::RDoc::VERSION
76
76
  end
@@ -153,18 +153,12 @@ class RDoc::RubygemsHook
153
153
  options = nil
154
154
 
155
155
  args = @spec.rdoc_options
156
-
157
- if @spec.respond_to? :source_paths then
158
- args.concat @spec.source_paths
159
- else
160
- args.concat @spec.require_paths
161
- end
162
-
156
+ args.concat @spec.source_paths
163
157
  args.concat @spec.extra_rdoc_files
164
158
 
165
159
  case config_args = Gem.configuration[:rdoc]
166
160
  when String then
167
- args = args.concat config_args.split
161
+ args = args.concat config_args.split(' ')
168
162
  when Array then
169
163
  args = args.concat config_args
170
164
  end
@@ -183,7 +177,7 @@ class RDoc::RubygemsHook
183
177
  @rdoc.options = options
184
178
 
185
179
  store = RDoc::Store.new
186
- store.encoding = options.encoding if options.respond_to? :encoding
180
+ store.encoding = options.encoding
187
181
  store.dry_run = options.dry_run
188
182
  store.main = options.main_page
189
183
  store.title = options.title
@@ -250,4 +244,3 @@ class RDoc::RubygemsHook
250
244
  end
251
245
 
252
246
  end
253
-