rdoc 6.3.4.1 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +195 -0
  3. data/History.rdoc +65 -63
  4. data/LEGAL.rdoc +7 -1
  5. data/LICENSE.rdoc +6 -0
  6. data/README.md +236 -0
  7. data/RI.md +842 -0
  8. data/TODO.rdoc +8 -7
  9. data/doc/markup_reference/markdown.md +659 -0
  10. data/doc/markup_reference/rdoc.rdoc +1169 -0
  11. data/exe/rdoc +0 -1
  12. data/lib/rdoc/{alias.rb → code_object/alias.rb} +4 -18
  13. data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +50 -24
  14. data/lib/rdoc/{attr.rb → code_object/attr.rb} +16 -14
  15. data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +225 -58
  16. data/lib/rdoc/{constant.rb → code_object/constant.rb} +44 -10
  17. data/lib/rdoc/code_object/context/section.rb +182 -0
  18. data/lib/rdoc/{context.rb → code_object/context.rb} +78 -106
  19. data/lib/rdoc/{extend.rb → code_object/extend.rb} +0 -1
  20. data/lib/rdoc/{include.rb → code_object/include.rb} +0 -1
  21. data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +46 -48
  22. data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +6 -4
  23. data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +2 -3
  24. data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +2 -3
  25. data/lib/rdoc/{require.rb → code_object/require.rb} +1 -2
  26. data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +5 -1
  27. data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +60 -63
  28. data/lib/rdoc/code_object.rb +11 -39
  29. data/lib/rdoc/code_objects.rb +1 -2
  30. data/lib/rdoc/comment.rb +202 -99
  31. data/lib/rdoc/cross_reference.rb +75 -62
  32. data/lib/rdoc/encoding.rb +8 -24
  33. data/lib/rdoc/erb_partial.rb +1 -2
  34. data/lib/rdoc/erbio.rb +3 -8
  35. data/lib/rdoc/generator/aliki.rb +200 -0
  36. data/lib/rdoc/generator/darkfish.rb +156 -122
  37. data/lib/rdoc/generator/json_index.rb +8 -24
  38. data/lib/rdoc/generator/markup.rb +70 -34
  39. data/lib/rdoc/generator/pot/message_extractor.rb +7 -7
  40. data/lib/rdoc/generator/pot/po.rb +1 -1
  41. data/lib/rdoc/generator/pot/po_entry.rb +8 -8
  42. data/lib/rdoc/generator/pot.rb +1 -5
  43. data/lib/rdoc/generator/ri.rb +1 -2
  44. data/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
  45. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  46. data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  47. data/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
  48. data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  49. data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  50. data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  51. data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  52. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
  53. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
  54. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  55. data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  56. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  57. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  58. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  59. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  60. data/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
  61. data/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
  62. data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  63. data/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
  64. data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
  65. data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  66. data/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
  67. data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  68. data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  69. data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  70. data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  71. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  72. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  73. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
  74. data/lib/rdoc/generator/template/darkfish/_head.rhtml +35 -14
  75. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -5
  76. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +11 -9
  77. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +11 -9
  78. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
  79. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +20 -11
  80. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +25 -5
  81. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -9
  82. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +2 -1
  83. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  84. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +28 -7
  85. data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  86. data/lib/rdoc/generator/template/darkfish/class.rhtml +138 -90
  87. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +420 -358
  88. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  89. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  90. data/lib/rdoc/generator/template/darkfish/index.rhtml +14 -12
  91. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +59 -3
  92. data/lib/rdoc/generator/template/darkfish/js/search.js +15 -5
  93. data/lib/rdoc/generator/template/darkfish/page.rhtml +7 -6
  94. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +12 -9
  95. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +24 -21
  96. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +35 -21
  97. data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
  98. data/lib/rdoc/generator/template/json_index/js/searcher.js +48 -6
  99. data/lib/rdoc/generator.rb +6 -5
  100. data/lib/rdoc/i18n/text.rb +3 -3
  101. data/lib/rdoc/i18n.rb +1 -1
  102. data/lib/rdoc/known_classes.rb +5 -4
  103. data/lib/rdoc/markdown/entities.rb +0 -1
  104. data/lib/rdoc/markdown/literals.kpeg +0 -2
  105. data/lib/rdoc/markdown/literals.rb +0 -1
  106. data/lib/rdoc/markdown.kpeg +140 -62
  107. data/lib/rdoc/markdown.rb +1015 -873
  108. data/lib/rdoc/markup/blank_line.rb +25 -24
  109. data/lib/rdoc/markup/block_quote.rb +1 -2
  110. data/lib/rdoc/markup/document.rb +10 -11
  111. data/lib/rdoc/markup/element.rb +21 -0
  112. data/lib/rdoc/markup/formatter.rb +134 -115
  113. data/lib/rdoc/markup/hard_break.rb +30 -28
  114. data/lib/rdoc/markup/heading.rb +163 -72
  115. data/lib/rdoc/markup/include.rb +3 -4
  116. data/lib/rdoc/markup/indented_paragraph.rb +4 -5
  117. data/lib/rdoc/markup/inline_parser.rb +312 -0
  118. data/lib/rdoc/markup/list.rb +6 -7
  119. data/lib/rdoc/markup/list_item.rb +6 -7
  120. data/lib/rdoc/markup/paragraph.rb +2 -3
  121. data/lib/rdoc/markup/parser.rb +29 -19
  122. data/lib/rdoc/markup/pre_process.rb +39 -18
  123. data/lib/rdoc/markup/raw.rb +52 -56
  124. data/lib/rdoc/markup/rule.rb +2 -3
  125. data/lib/rdoc/markup/table.rb +49 -32
  126. data/lib/rdoc/markup/to_ansi.rb +58 -8
  127. data/lib/rdoc/markup/to_bs.rb +47 -38
  128. data/lib/rdoc/markup/to_html.rb +343 -105
  129. data/lib/rdoc/markup/to_html_crossref.rb +143 -58
  130. data/lib/rdoc/markup/to_html_snippet.rb +78 -76
  131. data/lib/rdoc/markup/to_joined_paragraph.rb +3 -9
  132. data/lib/rdoc/markup/to_label.rb +34 -25
  133. data/lib/rdoc/markup/to_markdown.rb +74 -51
  134. data/lib/rdoc/markup/to_rdoc.rb +141 -82
  135. data/lib/rdoc/markup/to_table_of_contents.rb +4 -5
  136. data/lib/rdoc/markup/to_test.rb +10 -3
  137. data/lib/rdoc/markup/to_tt_only.rb +17 -31
  138. data/lib/rdoc/markup/verbatim.rb +5 -6
  139. data/lib/rdoc/markup.rb +59 -707
  140. data/lib/rdoc/options.rb +228 -101
  141. data/lib/rdoc/parser/c.rb +186 -184
  142. data/lib/rdoc/parser/changelog.rb +57 -13
  143. data/lib/rdoc/parser/markdown.rb +0 -2
  144. data/lib/rdoc/parser/rbs.rb +275 -0
  145. data/lib/rdoc/parser/rd.rb +0 -1
  146. data/lib/rdoc/parser/ruby.rb +963 -2024
  147. data/lib/rdoc/parser/ruby_colorizer.rb +253 -0
  148. data/lib/rdoc/parser/simple.rb +6 -23
  149. data/lib/rdoc/parser/text.rb +0 -1
  150. data/lib/rdoc/parser.rb +35 -14
  151. data/lib/rdoc/rbs_helper.rb +186 -0
  152. data/lib/rdoc/rd/block_parser.rb +659 -11
  153. data/lib/rdoc/rd/block_parser.ry +13 -9
  154. data/lib/rdoc/rd/inline.rb +4 -5
  155. data/lib/rdoc/rd/inline_parser.rb +646 -2
  156. data/lib/rdoc/rd.rb +4 -5
  157. data/lib/rdoc/rdoc.rb +234 -90
  158. data/lib/rdoc/ri/driver.rb +172 -172
  159. data/lib/rdoc/ri/paths.rb +3 -3
  160. data/lib/rdoc/{servlet.rb → ri/servlet.rb} +28 -27
  161. data/lib/rdoc/ri/store.rb +0 -1
  162. data/lib/rdoc/ri/task.rb +3 -3
  163. data/lib/rdoc/ri.rb +5 -5
  164. data/lib/rdoc/rubygems_hook.rb +106 -25
  165. data/lib/rdoc/server.rb +460 -0
  166. data/lib/rdoc/stats/normal.rb +1 -1
  167. data/lib/rdoc/stats/quiet.rb +1 -2
  168. data/lib/rdoc/stats/verbose.rb +3 -5
  169. data/lib/rdoc/stats.rb +158 -136
  170. data/lib/rdoc/store.rb +267 -48
  171. data/lib/rdoc/task.rb +54 -28
  172. data/lib/rdoc/text.rb +60 -120
  173. data/lib/rdoc/token_stream.rb +30 -45
  174. data/lib/rdoc/tom_doc.rb +9 -15
  175. data/lib/rdoc/version.rb +3 -1
  176. data/lib/rdoc.rb +90 -52
  177. data/lib/rubygems_plugin.rb +14 -0
  178. data/man/ri.1 +2 -0
  179. data/rdoc-logo.svg +43 -0
  180. data/rdoc.gemspec +25 -200
  181. metadata +120 -53
  182. data/CONTRIBUTING.rdoc +0 -220
  183. data/ExampleMarkdown.md +0 -37
  184. data/ExampleRDoc.rdoc +0 -208
  185. data/Gemfile +0 -12
  186. data/README.rdoc +0 -129
  187. data/RI.rdoc +0 -57
  188. data/Rakefile +0 -101
  189. data/bin/console +0 -7
  190. data/bin/setup +0 -6
  191. data/lib/rdoc/anon_class.rb +0 -11
  192. data/lib/rdoc/context/section.rb +0 -232
  193. data/lib/rdoc/generator/template/darkfish/.document +0 -0
  194. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
  195. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
  196. data/lib/rdoc/generator/template/json_index/.document +0 -1
  197. data/lib/rdoc/ghost_method.rb +0 -7
  198. data/lib/rdoc/markup/attr_changer.rb +0 -23
  199. data/lib/rdoc/markup/attr_span.rb +0 -36
  200. data/lib/rdoc/markup/attribute_manager.rb +0 -409
  201. data/lib/rdoc/markup/attributes.rb +0 -71
  202. data/lib/rdoc/markup/regexp_handling.rb +0 -41
  203. data/lib/rdoc/meta_method.rb +0 -7
  204. data/lib/rdoc/parser/ripper_state_lex.rb +0 -590
  205. data/lib/rdoc/parser/ruby_tools.rb +0 -167
data/lib/rdoc/ri/paths.rb CHANGED
@@ -30,7 +30,7 @@ module RDoc::RI::Paths
30
30
  # :extra:: ri data directory from the command line. Yielded for each
31
31
  # entry in +extra_dirs+
32
32
 
33
- def self.each system = true, site = true, home = true, gems = :latest, *extra_dirs # :yields: directory, type
33
+ def self.each(system = true, site = true, home = true, gems = :latest, *extra_dirs) # :yields: directory, type
34
34
  return enum_for __method__, system, site, home, gems, *extra_dirs unless
35
35
  block_given?
36
36
 
@@ -52,7 +52,7 @@ module RDoc::RI::Paths
52
52
  ##
53
53
  # The ri directory for the gem with +gem_name+.
54
54
 
55
- def self.gem_dir name, version
55
+ def self.gem_dir(name, version)
56
56
  req = Gem::Requirement.new "= #{version}"
57
57
 
58
58
  spec = Gem::Specification.find_by_name name, req
@@ -67,7 +67,7 @@ module RDoc::RI::Paths
67
67
  # A +filter+ :all includes all versions of gems and includes gems without
68
68
  # ri documentation.
69
69
 
70
- def self.gemdirs filter = :latest
70
+ def self.gemdirs(filter = :latest)
71
71
  ri_paths = {}
72
72
 
73
73
  all = Gem::Specification.map do |spec|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'rdoc'
2
+ require_relative '../../rdoc'
3
3
  require 'erb'
4
4
  require 'time'
5
5
  require 'json'
@@ -24,14 +24,14 @@ end
24
24
  #
25
25
  # server = WEBrick::HTTPServer.new Port: 8000
26
26
  #
27
- # server.mount '/', RDoc::Servlet
27
+ # server.mount '/', RDoc::RI::Servlet
28
28
  #
29
29
  # If you want to mount the servlet some other place than the root, provide the
30
30
  # base path when mounting:
31
31
  #
32
- # server.mount '/rdoc', RDoc::Servlet, '/rdoc'
32
+ # server.mount '/rdoc', RDoc::RI::Servlet, '/rdoc'
33
33
 
34
- class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
34
+ class RDoc::RI::Servlet < WEBrick::HTTPServlet::AbstractServlet
35
35
 
36
36
  @server_stores = Hash.new { |hash, server| hash[server] = {} }
37
37
  @cache = Hash.new { |hash, store| hash[store] = {} }
@@ -50,7 +50,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
50
50
  # Creates an instance of this servlet that shares cached data between
51
51
  # requests.
52
52
 
53
- def self.get_instance server, *options # :nodoc:
53
+ def self.get_instance(server, *options) # :nodoc:
54
54
  stores = @server_stores[server]
55
55
 
56
56
  new server, stores, @cache, *options
@@ -66,7 +66,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
66
66
  # +server+ is provided automatically by WEBrick when mounting. +stores+ and
67
67
  # +cache+ are provided automatically by the servlet.
68
68
 
69
- def initialize server, stores, cache, mount_path = nil, extra_doc_dirs = []
69
+ def initialize(server, stores, cache, mount_path = nil, extra_doc_dirs = [])
70
70
  super server
71
71
 
72
72
  @cache = cache
@@ -97,7 +97,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
97
97
  ##
98
98
  # Serves the asset at the path in +req+ for +generator_name+ via +res+.
99
99
 
100
- def asset generator_name, req, res
100
+ def asset(generator_name, req, res)
101
101
  asset_dir = @asset_dirs[generator_name]
102
102
 
103
103
  asset_path = File.join asset_dir, req.path
@@ -116,7 +116,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
116
116
  ##
117
117
  # GET request entry point. Fills in +res+ for the path, etc. in +req+.
118
118
 
119
- def do_GET req, res
119
+ def do_GET(req, res)
120
120
  req.path.sub!(/\A#{Regexp.escape @mount_path}/, '') if @mount_path
121
121
 
122
122
  case req.path
@@ -133,7 +133,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
133
133
  show_documentation req, res
134
134
  end
135
135
  rescue WEBrick::HTTPStatus::NotFound => e
136
- generator = generator_for RDoc::Store.new
136
+ generator = generator_for RDoc::Store.new(@options)
137
137
 
138
138
  not_found generator, req, res, e.message
139
139
  rescue WEBrick::HTTPStatus::Status
@@ -149,7 +149,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
149
149
  # module or page name (/RDoc/Servlet.html becomes RDoc::Servlet).
150
150
  # +generator+ is used to create the page.
151
151
 
152
- def documentation_page store, generator, path, req, res
152
+ def documentation_page(store, generator, path, req, res)
153
153
  text_name = path.chomp '.html'
154
154
  name = text_name.gsub '/', '::'
155
155
 
@@ -168,7 +168,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
168
168
  # Creates the JSON search index on +res+ for the given +store+. +generator+
169
169
  # must respond to \#json_index to build. +req+ is ignored.
170
170
 
171
- def documentation_search store, generator, req, res
171
+ def documentation_search(store, generator, req, res)
172
172
  json_index = @cache[store].fetch :json_index do
173
173
  @cache[store][:json_index] =
174
174
  JSON.dump generator.json_index.build_index
@@ -182,7 +182,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
182
182
  # Returns the RDoc::Store and path relative to +mount_path+ for
183
183
  # documentation at +path+.
184
184
 
185
- def documentation_source path
185
+ def documentation_source(path)
186
186
  _, source_name, path = path.split '/', 3
187
187
 
188
188
  store = @stores[source_name]
@@ -200,7 +200,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
200
200
  ##
201
201
  # Generates an error page for the +exception+ while handling +req+ on +res+.
202
202
 
203
- def error exception, req, res
203
+ def error(exception, req, res)
204
204
  backtrace = exception.backtrace.join "\n"
205
205
 
206
206
  res.content_type = 'text/html'
@@ -243,10 +243,11 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
243
243
  ##
244
244
  # Instantiates a Darkfish generator for +store+
245
245
 
246
- def generator_for store
246
+ def generator_for(store)
247
247
  generator = RDoc::Generator::Darkfish.new store, @options
248
248
  generator.file_output = false
249
249
  generator.asset_rel_path = '..'
250
+ generator.setup
250
251
 
251
252
  rdoc = RDoc::RDoc.new
252
253
  rdoc.store = store
@@ -264,7 +265,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
264
265
  # file has not been modified a Not Modified response is returned. If the
265
266
  # file has been modified a Last-Modified header is added to +res+.
266
267
 
267
- def if_modified_since req, res, path = nil
268
+ def if_modified_since(req, res, path = nil)
268
269
  last_modified = File.stat(path).mtime if path
269
270
 
270
271
  res['last-modified'] = last_modified.httpdate
@@ -290,7 +291,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
290
291
  def installed_docs
291
292
  extra_counter = 0
292
293
  ri_paths.map do |path, type|
293
- store = RDoc::Store.new path, type
294
+ store = RDoc::Store.new(@options, path: path, type: type)
294
295
  exists = File.exist? store.cache_path
295
296
 
296
297
  case type
@@ -315,7 +316,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
315
316
  ##
316
317
  # Returns a 404 page built by +generator+ for +req+ on +res+.
317
318
 
318
- def not_found generator, req, res, message = nil
319
+ def not_found(generator, req, res, message = nil)
319
320
  message ||= "The page <kbd>#{ERB::Util.h req.path}</kbd> was not found"
320
321
  res.body = generator.generate_servlet_not_found message
321
322
  res.status = 404
@@ -324,14 +325,14 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
324
325
  ##
325
326
  # Enumerates the ri paths. See RDoc::RI::Paths#each
326
327
 
327
- def ri_paths &block
328
+ def ri_paths(&block)
328
329
  RDoc::RI::Paths.each true, true, true, :all, *@extra_doc_dirs, &block #TODO: pass extra_dirs
329
330
  end
330
331
 
331
332
  ##
332
333
  # Generates the root page on +res+. +req+ is ignored.
333
334
 
334
- def root req, res
335
+ def root(req, res)
335
336
  generator = RDoc::Generator::Darkfish.new nil, @options
336
337
 
337
338
  res.body = generator.generate_servlet_root installed_docs
@@ -342,7 +343,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
342
343
  ##
343
344
  # Generates a search index for the root page on +res+. +req+ is ignored.
344
345
 
345
- def root_search req, res
346
+ def root_search(req, res)
346
347
  search_index = []
347
348
  info = []
348
349
 
@@ -392,7 +393,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
392
393
  # Displays documentation for +req+ on +res+, whether that be HTML or some
393
394
  # asset.
394
395
 
395
- def show_documentation req, res
396
+ def show_documentation(req, res)
396
397
  store, path = documentation_source req.path
397
398
 
398
399
  if_modified_since req, res, store.cache_path
@@ -416,18 +417,18 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
416
417
  ##
417
418
  # Returns an RDoc::Store for the given +source_name+ ('ruby' or a gem name).
418
419
 
419
- def store_for source_name
420
+ def store_for(source_name)
420
421
  case source_name
421
422
  when 'home' then
422
- RDoc::Store.new RDoc::RI::Paths.home_dir, :home
423
+ RDoc::Store.new(@options, path: RDoc::RI::Paths.home_dir, type: :home)
423
424
  when 'ruby' then
424
- RDoc::Store.new RDoc::RI::Paths.system_dir, :system
425
+ RDoc::Store.new(@options, path: RDoc::RI::Paths.system_dir, type: :system)
425
426
  when 'site' then
426
- RDoc::Store.new RDoc::RI::Paths.site_dir, :site
427
+ RDoc::Store.new(@options, path: RDoc::RI::Paths.site_dir, type: :site)
427
428
  when /\Aextra-(\d+)\z/ then
428
429
  index = $1.to_i - 1
429
430
  ri_dir = installed_docs[index][4]
430
- RDoc::Store.new ri_dir, :extra
431
+ RDoc::Store.new(@options, path: ri_dir, type: :extra)
431
432
  else
432
433
  ri_dir, type = ri_paths.find do |dir, dir_type|
433
434
  next unless dir_type == :gem
@@ -438,7 +439,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
438
439
  raise WEBrick::HTTPStatus::NotFound,
439
440
  "Could not find gem \"#{ERB::Util.html_escape(source_name)}\". Are you sure you installed it?" unless ri_dir
440
441
 
441
- store = RDoc::Store.new ri_dir, type
442
+ store = RDoc::Store.new(@options, path: ri_dir, type: type)
442
443
 
443
444
  return store if File.exist? store.cache_path
444
445
 
data/lib/rdoc/ri/store.rb CHANGED
@@ -4,4 +4,3 @@ module RDoc::RI
4
4
  Store = RDoc::Store # :nodoc:
5
5
 
6
6
  end
7
-
data/lib/rdoc/ri/task.rb CHANGED
@@ -26,8 +26,8 @@ require_relative '../task'
26
26
  # require 'rdoc/ri/task'
27
27
  #
28
28
  # RDoc::RI::Task.new do |ri|
29
- # ri.main = 'README.rdoc'
30
- # ri.rdoc_files.include 'README.rdoc', 'lib/**/*.rb'
29
+ # ri.main = 'README.md'
30
+ # ri.rdoc_files.include 'README.md', 'lib/**/*.rb'
31
31
  # end
32
32
  #
33
33
  # For further configuration details see RDoc::Task.
@@ -44,7 +44,7 @@ class RDoc::RI::Task < RDoc::Task
44
44
  # Create an ri task with the given name. See RDoc::Task for documentation on
45
45
  # setting names.
46
46
 
47
- def initialize name = DEFAULT_NAMES # :yield: self
47
+ def initialize(name = DEFAULT_NAMES) # :yield: self
48
48
  super
49
49
  end
50
50
 
data/lib/rdoc/ri.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'rdoc'
2
+ require_relative '../rdoc'
3
3
 
4
4
  ##
5
5
  # Namespace for the ri command line tool's implementation.
@@ -13,9 +13,9 @@ module RDoc::RI
13
13
 
14
14
  class Error < RDoc::Error; end
15
15
 
16
- autoload :Driver, 'rdoc/ri/driver'
17
- autoload :Paths, 'rdoc/ri/paths'
18
- autoload :Store, 'rdoc/ri/store'
16
+ autoload :Driver, "#{__dir__}/ri/driver"
17
+ autoload :Paths, "#{__dir__}/ri/paths"
18
+ autoload :Servlet, "#{__dir__}/ri/servlet"
19
+ autoload :Store, "#{__dir__}/ri/store"
19
20
 
20
21
  end
21
-
@@ -1,15 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
  require 'rubygems/user_interaction'
3
3
  require 'fileutils'
4
- require 'rdoc'
4
+ require_relative '../rdoc'
5
5
 
6
- ##
7
- # Gem::RDoc provides methods to generate RDoc and ri data for installed gems
8
- # upon gem installation.
6
+ # We define the following two similar name classes in this file:
9
7
  #
10
- # This file is automatically required by RubyGems 1.9 and newer.
8
+ # - RDoc::RubyGemsHook
9
+ # - RDoc::RubygemsHook
10
+ #
11
+ # RDoc::RubyGemsHook is the main class that has real logic.
12
+ #
13
+ # RDoc::RubygemsHook is a class that is only for
14
+ # compatibility. RDoc::RubygemsHook is used by RubyGems directly. We
15
+ # can remove this when all maintained RubyGems remove
16
+ # `rubygems/rdoc.rb`.
11
17
 
12
- class RDoc::RubygemsHook
18
+ class RDoc::RubyGemsHook
13
19
 
14
20
  include Gem::UserInteraction
15
21
  extend Gem::UserInteraction
@@ -45,7 +51,7 @@ class RDoc::RubygemsHook
45
51
  # Post installs hook that generates documentation for each specification in
46
52
  # +specs+
47
53
 
48
- def self.generation_hook installer, specs
54
+ def self.generate(installer, specs)
49
55
  start = Time.now
50
56
  types = installer.document
51
57
 
@@ -64,6 +70,10 @@ class RDoc::RubygemsHook
64
70
  say "Done installing documentation for #{names} after #{duration} seconds"
65
71
  end
66
72
 
73
+ def self.remove(uninstaller)
74
+ new(uninstaller.spec).remove
75
+ end
76
+
67
77
  ##
68
78
  # Loads the RDoc generator
69
79
 
@@ -82,7 +92,7 @@ class RDoc::RubygemsHook
82
92
  #
83
93
  # Only +generate_ri+ is enabled by default.
84
94
 
85
- def initialize spec, generate_rdoc = false, generate_ri = true
95
+ def initialize(spec, generate_rdoc = false, generate_ri = true)
86
96
  @doc_dir = spec.doc_dir
87
97
  @force = false
88
98
  @rdoc = nil
@@ -100,7 +110,7 @@ class RDoc::RubygemsHook
100
110
  #--
101
111
  # TODO move to RDoc::Options
102
112
 
103
- def delete_legacy_args args
113
+ def delete_legacy_args(args)
104
114
  args.delete '--inline-source'
105
115
  args.delete '--promiscuous'
106
116
  args.delete '-p'
@@ -108,19 +118,21 @@ class RDoc::RubygemsHook
108
118
  end
109
119
 
110
120
  ##
111
- # Generates documentation using the named +generator+ ("darkfish" or "ri")
121
+ # Generates documentation using the named +generator+ ("aliki" or "ri")
112
122
  # and following the given +options+.
113
123
  #
114
124
  # Documentation will be generated into +destination+
115
125
 
116
- def document generator, options, destination
126
+ def document(generator, options, destination)
117
127
  generator_name = generator
118
128
 
119
129
  options = options.dup
120
130
  options.exclude ||= [] # TODO maybe move to RDoc::Options#finish
121
131
  options.setup_generator generator
122
132
  options.op_dir = destination
123
- options.finish
133
+ Dir.chdir @spec.full_gem_path do
134
+ options.finish
135
+ end
124
136
 
125
137
  generator = options.generator.new @rdoc.store, options
126
138
 
@@ -169,31 +181,28 @@ class RDoc::RubygemsHook
169
181
  options = ::RDoc::Options.new
170
182
  options.default_title = "#{@spec.full_name} Documentation"
171
183
  options.parse args
184
+ options.quiet = !Gem.configuration.really_verbose
172
185
  end
173
186
 
174
- options.quiet = !Gem.configuration.really_verbose
175
-
176
187
  @rdoc = new_rdoc
177
- @rdoc.options = options
178
-
179
- store = RDoc::Store.new
180
- store.encoding = options.encoding
181
- store.dry_run = options.dry_run
182
- store.main = options.main_page
183
- store.title = options.title
184
-
185
- @rdoc.store = store
186
188
 
187
189
  say "Parsing documentation for #{@spec.full_name}"
188
190
 
189
191
  Dir.chdir @spec.full_gem_path do
190
- @rdoc.parse_files options.files
192
+ # RDoc::Options#finish must be called before parse_files.
193
+ # RDoc::Options#finish is also called after ri/aliki generator setup.
194
+ # We need to dup the options to avoid modifying it after finish is called.
195
+ parse_options = options.dup
196
+ parse_options.finish
197
+ @rdoc.options = parse_options
198
+ @rdoc.store = RDoc::Store.new(parse_options)
199
+ @rdoc.parse_files parse_options.files
191
200
  end
192
201
 
193
202
  document 'ri', options, @ri_dir if
194
203
  @generate_ri and (@force or not File.exist? @ri_dir)
195
204
 
196
- document 'darkfish', options, @rdoc_dir if
205
+ document 'aliki', options, @rdoc_dir if
197
206
  @generate_rdoc and (@force or not File.exist? @rdoc_dir)
198
207
  end
199
208
 
@@ -244,3 +253,75 @@ class RDoc::RubygemsHook
244
253
  end
245
254
 
246
255
  end
256
+
257
+ module RDoc
258
+ # This class is referenced by RubyGems to create documents.
259
+ # All implementations are moved to the above RubyGemsHook.
260
+ #
261
+ # This class does nothing when this RDoc is installed as a normal gem
262
+ # or a bundled gem.
263
+ #
264
+ # This class does generate/remove documents for compatibility when
265
+ # this RDoc is installed as a default gem.
266
+ #
267
+ # We can remove this when all maintained RubyGems remove
268
+ # `rubygems/rdoc.rb`.
269
+ class RubygemsHook
270
+
271
+ attr_accessor :generate_rdoc, :generate_ri, :force
272
+
273
+ def self.default_gem?
274
+ !File.exist?(File.join(__dir__, "..", "rubygems_plugin.rb"))
275
+ end
276
+
277
+ def initialize(spec, generate_rdoc = false, generate_ri = true)
278
+ @spec = spec
279
+ @generate_rdoc = generate_rdoc
280
+ @generate_ri = generate_ri
281
+ @force = false
282
+ end
283
+
284
+ def generate
285
+ # Do nothing if this is NOT a default gem.
286
+ return unless self.class.default_gem?
287
+
288
+ # Generate document for compatibility if this is a default gem.
289
+ hook = RubyGemsHook.new(@spec, @generate_rdoc, @generate_ri)
290
+ hook.force = @force
291
+ hook.generate
292
+ end
293
+
294
+ def remove
295
+ # Do nothing if this is NOT a default gem.
296
+ return unless self.class.default_gem?
297
+
298
+ # Remove generated document for compatibility if this is a
299
+ # default gem.
300
+ RubyGemsHook.new(@spec).remove
301
+ end
302
+
303
+ def self.generation_hook(installer, specs)
304
+ # Do nothing if this is NOT a default gem.
305
+ return unless default_gem?
306
+
307
+ # Generate document for compatibility if this is a default gem.
308
+ RubyGemsHook.generate(installer, specs)
309
+ end
310
+
311
+ def self.load_rdoc
312
+ RubyGemsHook.load_rdoc
313
+ end
314
+
315
+ def self.rdoc_version
316
+ RubyGemsHook.rdoc_version
317
+ end
318
+
319
+ def rdoc_installed?
320
+ RubyGemsHook.new(@spec).rdoc_installed?
321
+ end
322
+
323
+ def ri_installed?
324
+ RubyGemsHook.new(@spec).ri_installed?
325
+ end
326
+ end
327
+ end