super-quick-rb 0.0.1

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 (218) hide show
  1. checksums.yaml +7 -0
  2. data/rdoc-8.0.0/CONTRIBUTING.md +195 -0
  3. data/rdoc-8.0.0/CVE-2013-0256.rdoc +49 -0
  4. data/rdoc-8.0.0/History.rdoc +1668 -0
  5. data/rdoc-8.0.0/LEGAL.rdoc +56 -0
  6. data/rdoc-8.0.0/LICENSE.rdoc +63 -0
  7. data/rdoc-8.0.0/README.md +236 -0
  8. data/rdoc-8.0.0/RI.md +842 -0
  9. data/rdoc-8.0.0/TODO.rdoc +60 -0
  10. data/rdoc-8.0.0/doc/markup_reference/markdown.md +659 -0
  11. data/rdoc-8.0.0/doc/markup_reference/rdoc.rdoc +1169 -0
  12. data/rdoc-8.0.0/exe/rdoc +43 -0
  13. data/rdoc-8.0.0/exe/ri +12 -0
  14. data/rdoc-8.0.0/lib/rdoc/code_object/alias.rb +98 -0
  15. data/rdoc-8.0.0/lib/rdoc/code_object/any_method.rb +387 -0
  16. data/rdoc-8.0.0/lib/rdoc/code_object/attr.rb +178 -0
  17. data/rdoc-8.0.0/lib/rdoc/code_object/class_module.rb +969 -0
  18. data/rdoc-8.0.0/lib/rdoc/code_object/constant.rb +221 -0
  19. data/rdoc-8.0.0/lib/rdoc/code_object/context/section.rb +182 -0
  20. data/rdoc-8.0.0/lib/rdoc/code_object/context.rb +1238 -0
  21. data/rdoc-8.0.0/lib/rdoc/code_object/extend.rb +9 -0
  22. data/rdoc-8.0.0/lib/rdoc/code_object/include.rb +9 -0
  23. data/rdoc-8.0.0/lib/rdoc/code_object/method_attr.rb +417 -0
  24. data/rdoc-8.0.0/lib/rdoc/code_object/mixin.rb +123 -0
  25. data/rdoc-8.0.0/lib/rdoc/code_object/normal_class.rb +92 -0
  26. data/rdoc-8.0.0/lib/rdoc/code_object/normal_module.rb +73 -0
  27. data/rdoc-8.0.0/lib/rdoc/code_object/require.rb +51 -0
  28. data/rdoc-8.0.0/lib/rdoc/code_object/single_class.rb +30 -0
  29. data/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb +286 -0
  30. data/rdoc-8.0.0/lib/rdoc/code_object.rb +393 -0
  31. data/rdoc-8.0.0/lib/rdoc/code_objects.rb +5 -0
  32. data/rdoc-8.0.0/lib/rdoc/comment.rb +353 -0
  33. data/rdoc-8.0.0/lib/rdoc/cross_reference.rb +215 -0
  34. data/rdoc-8.0.0/lib/rdoc/encoding.rb +120 -0
  35. data/rdoc-8.0.0/lib/rdoc/erb_partial.rb +18 -0
  36. data/rdoc-8.0.0/lib/rdoc/erbio.rb +37 -0
  37. data/rdoc-8.0.0/lib/rdoc/generator/aliki.rb +200 -0
  38. data/rdoc-8.0.0/lib/rdoc/generator/darkfish.rb +824 -0
  39. data/rdoc-8.0.0/lib/rdoc/generator/json_index.rb +284 -0
  40. data/rdoc-8.0.0/lib/rdoc/generator/markup.rb +196 -0
  41. data/rdoc-8.0.0/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  42. data/rdoc-8.0.0/lib/rdoc/generator/pot/po.rb +84 -0
  43. data/rdoc-8.0.0/lib/rdoc/generator/pot/po_entry.rb +141 -0
  44. data/rdoc-8.0.0/lib/rdoc/generator/pot.rb +94 -0
  45. data/rdoc-8.0.0/lib/rdoc/generator/ri.rb +30 -0
  46. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
  47. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  48. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  49. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
  50. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  51. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  52. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  53. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  54. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
  55. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
  56. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  57. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  58. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  59. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  60. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  61. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  62. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
  63. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
  64. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  65. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
  66. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
  67. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  68. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
  69. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  70. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  71. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  72. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  73. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  74. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  75. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  76. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_head.rhtml +43 -0
  77. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +5 -0
  78. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +17 -0
  79. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +17 -0
  80. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +16 -0
  81. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +21 -0
  82. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  83. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +32 -0
  84. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +6 -0
  85. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +15 -0
  86. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  87. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +39 -0
  88. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  89. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/class.rhtml +220 -0
  90. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  91. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/rdoc.css +701 -0
  92. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  93. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  94. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  95. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  96. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  97. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  98. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  99. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  100. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  101. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  102. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  103. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  104. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  105. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  106. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  107. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  108. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  109. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  110. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  111. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  112. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  113. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  114. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  115. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  116. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  117. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  118. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  119. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  120. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  121. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  122. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  123. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/index.rhtml +24 -0
  124. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/darkfish.js +140 -0
  125. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/search.js +120 -0
  126. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/page.rhtml +19 -0
  127. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +21 -0
  128. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +65 -0
  129. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +72 -0
  130. data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  131. data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/searcher.js +271 -0
  132. data/rdoc-8.0.0/lib/rdoc/generator.rb +52 -0
  133. data/rdoc-8.0.0/lib/rdoc/i18n/locale.rb +102 -0
  134. data/rdoc-8.0.0/lib/rdoc/i18n/text.rb +126 -0
  135. data/rdoc-8.0.0/lib/rdoc/i18n.rb +10 -0
  136. data/rdoc-8.0.0/lib/rdoc/known_classes.rb +74 -0
  137. data/rdoc-8.0.0/lib/rdoc/markdown/entities.rb +2131 -0
  138. data/rdoc-8.0.0/lib/rdoc/markdown/literals.kpeg +21 -0
  139. data/rdoc-8.0.0/lib/rdoc/markdown/literals.rb +454 -0
  140. data/rdoc-8.0.0/lib/rdoc/markdown.kpeg +1315 -0
  141. data/rdoc-8.0.0/lib/rdoc/markdown.rb +16865 -0
  142. data/rdoc-8.0.0/lib/rdoc/markup/blank_line.rb +29 -0
  143. data/rdoc-8.0.0/lib/rdoc/markup/block_quote.rb +14 -0
  144. data/rdoc-8.0.0/lib/rdoc/markup/document.rb +164 -0
  145. data/rdoc-8.0.0/lib/rdoc/markup/element.rb +21 -0
  146. data/rdoc-8.0.0/lib/rdoc/markup/formatter.rb +285 -0
  147. data/rdoc-8.0.0/lib/rdoc/markup/hard_break.rb +34 -0
  148. data/rdoc-8.0.0/lib/rdoc/markup/heading.rb +170 -0
  149. data/rdoc-8.0.0/lib/rdoc/markup/include.rb +42 -0
  150. data/rdoc-8.0.0/lib/rdoc/markup/indented_paragraph.rb +47 -0
  151. data/rdoc-8.0.0/lib/rdoc/markup/inline_parser.rb +312 -0
  152. data/rdoc-8.0.0/lib/rdoc/markup/list.rb +101 -0
  153. data/rdoc-8.0.0/lib/rdoc/markup/list_item.rb +99 -0
  154. data/rdoc-8.0.0/lib/rdoc/markup/paragraph.rb +28 -0
  155. data/rdoc-8.0.0/lib/rdoc/markup/parser.rb +585 -0
  156. data/rdoc-8.0.0/lib/rdoc/markup/pre_process.rb +317 -0
  157. data/rdoc-8.0.0/lib/rdoc/markup/raw.rb +66 -0
  158. data/rdoc-8.0.0/lib/rdoc/markup/rule.rb +20 -0
  159. data/rdoc-8.0.0/lib/rdoc/markup/table.rb +64 -0
  160. data/rdoc-8.0.0/lib/rdoc/markup/to_ansi.rb +144 -0
  161. data/rdoc-8.0.0/lib/rdoc/markup/to_bs.rb +86 -0
  162. data/rdoc-8.0.0/lib/rdoc/markup/to_html.rb +682 -0
  163. data/rdoc-8.0.0/lib/rdoc/markup/to_html_crossref.rb +261 -0
  164. data/rdoc-8.0.0/lib/rdoc/markup/to_html_snippet.rb +287 -0
  165. data/rdoc-8.0.0/lib/rdoc/markup/to_joined_paragraph.rb +41 -0
  166. data/rdoc-8.0.0/lib/rdoc/markup/to_label.rb +84 -0
  167. data/rdoc-8.0.0/lib/rdoc/markup/to_markdown.rb +215 -0
  168. data/rdoc-8.0.0/lib/rdoc/markup/to_rdoc.rb +421 -0
  169. data/rdoc-8.0.0/lib/rdoc/markup/to_table_of_contents.rb +88 -0
  170. data/rdoc-8.0.0/lib/rdoc/markup/to_test.rb +77 -0
  171. data/rdoc-8.0.0/lib/rdoc/markup/to_tt_only.rb +107 -0
  172. data/rdoc-8.0.0/lib/rdoc/markup/verbatim.rb +83 -0
  173. data/rdoc-8.0.0/lib/rdoc/markup.rb +219 -0
  174. data/rdoc-8.0.0/lib/rdoc/options.rb +1412 -0
  175. data/rdoc-8.0.0/lib/rdoc/parser/c.rb +1227 -0
  176. data/rdoc-8.0.0/lib/rdoc/parser/changelog.rb +379 -0
  177. data/rdoc-8.0.0/lib/rdoc/parser/markdown.rb +22 -0
  178. data/rdoc-8.0.0/lib/rdoc/parser/rbs.rb +275 -0
  179. data/rdoc-8.0.0/lib/rdoc/parser/rd.rb +22 -0
  180. data/rdoc-8.0.0/lib/rdoc/parser/ruby.rb +1266 -0
  181. data/rdoc-8.0.0/lib/rdoc/parser/ruby_colorizer.rb +253 -0
  182. data/rdoc-8.0.0/lib/rdoc/parser/simple.rb +44 -0
  183. data/rdoc-8.0.0/lib/rdoc/parser/text.rb +11 -0
  184. data/rdoc-8.0.0/lib/rdoc/parser.rb +298 -0
  185. data/rdoc-8.0.0/lib/rdoc/rbs_helper.rb +186 -0
  186. data/rdoc-8.0.0/lib/rdoc/rd/block_parser.rb +1706 -0
  187. data/rdoc-8.0.0/lib/rdoc/rd/block_parser.ry +643 -0
  188. data/rdoc-8.0.0/lib/rdoc/rd/inline.rb +71 -0
  189. data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.rb +1854 -0
  190. data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.ry +593 -0
  191. data/rdoc-8.0.0/lib/rdoc/rd.rb +99 -0
  192. data/rdoc-8.0.0/lib/rdoc/rdoc.rb +724 -0
  193. data/rdoc-8.0.0/lib/rdoc/ri/driver.rb +1572 -0
  194. data/rdoc-8.0.0/lib/rdoc/ri/formatter.rb +6 -0
  195. data/rdoc-8.0.0/lib/rdoc/ri/paths.rb +171 -0
  196. data/rdoc-8.0.0/lib/rdoc/ri/servlet.rb +452 -0
  197. data/rdoc-8.0.0/lib/rdoc/ri/store.rb +6 -0
  198. data/rdoc-8.0.0/lib/rdoc/ri/task.rb +71 -0
  199. data/rdoc-8.0.0/lib/rdoc/ri.rb +21 -0
  200. data/rdoc-8.0.0/lib/rdoc/rubygems_hook.rb +327 -0
  201. data/rdoc-8.0.0/lib/rdoc/server.rb +460 -0
  202. data/rdoc-8.0.0/lib/rdoc/stats/normal.rb +58 -0
  203. data/rdoc-8.0.0/lib/rdoc/stats/quiet.rb +59 -0
  204. data/rdoc-8.0.0/lib/rdoc/stats/verbose.rb +44 -0
  205. data/rdoc-8.0.0/lib/rdoc/stats.rb +484 -0
  206. data/rdoc-8.0.0/lib/rdoc/store.rb +1205 -0
  207. data/rdoc-8.0.0/lib/rdoc/task.rb +355 -0
  208. data/rdoc-8.0.0/lib/rdoc/text.rb +244 -0
  209. data/rdoc-8.0.0/lib/rdoc/token_stream.rb +104 -0
  210. data/rdoc-8.0.0/lib/rdoc/tom_doc.rb +257 -0
  211. data/rdoc-8.0.0/lib/rdoc/version.rb +10 -0
  212. data/rdoc-8.0.0/lib/rdoc.rb +239 -0
  213. data/rdoc-8.0.0/lib/rubygems_plugin.rb +14 -0
  214. data/rdoc-8.0.0/man/ri.1 +249 -0
  215. data/rdoc-8.0.0/rdoc-logo.svg +43 -0
  216. data/rdoc-8.0.0/rdoc.gemspec +74 -0
  217. data/super-quick-rb.gemspec +12 -0
  218. metadata +257 -0
@@ -0,0 +1,724 @@
1
+ # frozen_string_literal: true
2
+ require_relative '../rdoc'
3
+
4
+ require 'find'
5
+ require 'fileutils'
6
+ require 'pathname'
7
+ require 'time'
8
+ require_relative 'rbs_helper'
9
+
10
+ ##
11
+ # This is the driver for generating RDoc output. It handles file parsing and
12
+ # generation of output.
13
+ #
14
+ # To use this class to generate RDoc output via the API, the recommended way
15
+ # is:
16
+ #
17
+ # rdoc = RDoc::RDoc.new
18
+ # options = RDoc::Options.load_options # returns an RDoc::Options instance
19
+ # # set extra options
20
+ # rdoc.document options
21
+ #
22
+ # You can also generate output like the +rdoc+ executable:
23
+ #
24
+ # rdoc = RDoc::RDoc.new
25
+ # rdoc.document argv
26
+ #
27
+ # Where +argv+ is an array of strings, each corresponding to an argument you'd
28
+ # give rdoc on the command line. See <tt>rdoc --help</tt> for details.
29
+
30
+ class RDoc::RDoc
31
+
32
+ @current = nil
33
+
34
+ ##
35
+ # This is the list of supported output generators
36
+
37
+ GENERATORS = {}
38
+
39
+ ##
40
+ # List of directory names always skipped
41
+
42
+ UNCONDITIONALLY_SKIPPED_DIRECTORIES = %w[CVS .svn .git].freeze
43
+
44
+ ##
45
+ # List of directory names skipped if test suites should be skipped
46
+
47
+ TEST_SUITE_DIRECTORY_NAMES = %w[spec test].freeze
48
+
49
+
50
+ ##
51
+ # Generator instance used for creating output
52
+
53
+ attr_accessor :generator
54
+
55
+ ##
56
+ # Hash of files and their last modified times.
57
+
58
+ attr_reader :last_modified
59
+
60
+ ##
61
+ # RDoc options
62
+
63
+ attr_accessor :options
64
+
65
+ ##
66
+ # Accessor for statistics. Available after each call to parse_files
67
+
68
+ attr_reader :stats
69
+
70
+ ##
71
+ # The current documentation store
72
+
73
+ attr_accessor :store
74
+
75
+ ##
76
+ # Add +klass+ that can generate output after parsing
77
+
78
+ def self.add_generator(klass)
79
+ name = klass.name.sub(/^RDoc::Generator::/, '').downcase
80
+ GENERATORS[name] = klass
81
+ end
82
+
83
+ ##
84
+ # Active RDoc::RDoc instance
85
+
86
+ def self.current
87
+ @current
88
+ end
89
+
90
+ ##
91
+ # Sets the active RDoc::RDoc instance
92
+
93
+ def self.current=(rdoc)
94
+ @current = rdoc
95
+ end
96
+
97
+ ##
98
+ # Creates a new RDoc::RDoc instance. Call #document to parse files and
99
+ # generate documentation.
100
+
101
+ def initialize
102
+ @current = nil
103
+ @generator = nil
104
+ @last_modified = {}
105
+ @old_siginfo = nil
106
+ @options = nil
107
+ @stats = nil
108
+ @store = nil
109
+ end
110
+
111
+ ##
112
+ # Report an error message and exit
113
+
114
+ def error(msg)
115
+ raise RDoc::Error, msg
116
+ end
117
+
118
+ ##
119
+ # Gathers a set of parseable files from the files and directories listed in
120
+ # +files+.
121
+
122
+ def gather_files(files)
123
+ files = [@options.root.to_s] if files.empty?
124
+
125
+ file_list = normalized_file_list files, true, @options.exclude
126
+
127
+ file_list = remove_unparseable(file_list)
128
+
129
+ if file_list.count {|name, mtime|
130
+ file_list[name] = @last_modified[name] unless mtime
131
+ mtime
132
+ } > 0
133
+ @last_modified.replace file_list
134
+ file_list.keys.sort
135
+ else
136
+ []
137
+ end
138
+ end
139
+
140
+ ##
141
+ # Turns RDoc from stdin into HTML
142
+
143
+ def handle_pipe
144
+ @html = RDoc::Markup::ToHtml.new(pipe: @options.pipe, output_decoration: @options.output_decoration)
145
+
146
+ parser = RDoc::Text::MARKUP_FORMAT[@options.markup]
147
+
148
+ document = parser.parse $stdin.read
149
+
150
+ out = @html.convert document
151
+
152
+ $stdout.write out
153
+ end
154
+
155
+ ##
156
+ # Installs a siginfo handler that prints the current filename.
157
+
158
+ def install_siginfo_handler
159
+ return unless Signal.list.include? 'INFO'
160
+
161
+ @old_siginfo = trap 'INFO' do
162
+ puts @current if @current
163
+ end
164
+ end
165
+
166
+ ##
167
+ # Create an output dir if it doesn't exist. If it does exist, but doesn't
168
+ # contain the flag file <tt>created.rid</tt> then we refuse to use it, as
169
+ # we may clobber some manually generated documentation
170
+
171
+ def setup_output_dir(dir, force)
172
+ flag_file = output_flag_file dir
173
+
174
+ last = {}
175
+
176
+ if @options.dry_run then
177
+ # do nothing
178
+ elsif File.exist? dir then
179
+ error "#{dir} exists and is not a directory" unless File.directory? dir
180
+
181
+ begin
182
+ File.open flag_file do |io|
183
+ unless force then
184
+ Time.parse io.gets
185
+
186
+ io.each do |line|
187
+ file, time = line.split "\t", 2
188
+ time = Time.parse(time) rescue next
189
+ last[file] = time
190
+ end
191
+ end
192
+ end
193
+ rescue SystemCallError, TypeError
194
+ error <<-ERROR
195
+
196
+ Directory #{dir} already exists, but it looks like it isn't an RDoc directory.
197
+
198
+ Because RDoc doesn't want to risk destroying any of your existing files,
199
+ you'll need to specify a different output directory name (using the --op <dir>
200
+ option)
201
+
202
+ ERROR
203
+ end unless @options.force_output
204
+ else
205
+ FileUtils.mkdir_p dir
206
+ FileUtils.touch flag_file
207
+ end
208
+
209
+ last
210
+ end
211
+
212
+ ##
213
+ # Update the flag file in an output directory.
214
+
215
+ def update_output_dir(op_dir, time, last = {})
216
+ return if @options.dry_run or not @options.update_output_dir
217
+ unless ENV['SOURCE_DATE_EPOCH'].nil?
218
+ time = Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
219
+ end
220
+
221
+ File.open output_flag_file(op_dir), "w" do |f|
222
+ f.puts time.rfc2822
223
+ last.each do |n, t|
224
+ f.puts "#{n}\t#{t.rfc2822}"
225
+ end
226
+ end
227
+ end
228
+
229
+ ##
230
+ # Return the path name of the flag file in an output directory.
231
+
232
+ def output_flag_file(op_dir)
233
+ File.join op_dir, "created.rid"
234
+ end
235
+
236
+ ##
237
+ # The .document file contains a list of file and directory name patterns,
238
+ # representing candidates for documentation. It may also contain comments
239
+ # (starting with '#')
240
+
241
+ def parse_dot_doc_file(in_dir, filename)
242
+ # read and strip comments
243
+ patterns = File.read(filename).gsub(/#.*/, '')
244
+
245
+ result = {}
246
+
247
+ patterns.split(' ').each do |patt|
248
+ candidates = Dir.glob(File.join(in_dir, patt))
249
+ result.update normalized_file_list(candidates, false, @options.exclude)
250
+ end
251
+
252
+ result
253
+ end
254
+
255
+ ##
256
+ # Given a list of files and directories, create a list of all the Ruby
257
+ # files they contain.
258
+ #
259
+ # If +force_doc+ is true we always add the given files, if false, only
260
+ # add files that we guarantee we can parse. It is true when looking at
261
+ # files given on the command line, false when recursing through
262
+ # subdirectories.
263
+ #
264
+ # The effect of this is that if you want a file with a non-standard
265
+ # extension parsed, you must name it explicitly.
266
+
267
+ def normalized_file_list(relative_files, force_doc = false,
268
+ exclude_pattern = nil)
269
+ file_list = {}
270
+
271
+ relative_files.each do |rel_file_name|
272
+ rel_file_name = rel_file_name.sub(/^\.\//, '')
273
+ next if rel_file_name.end_with? 'created.rid'
274
+ next if exclude_pattern && exclude_pattern =~ rel_file_name
275
+ stat = File.stat rel_file_name rescue next
276
+
277
+ case type = stat.ftype
278
+ when "file" then
279
+ mtime = (stat.mtime unless (last_modified = @last_modified[rel_file_name] and
280
+ stat.mtime.to_i <= last_modified.to_i))
281
+
282
+ if force_doc or RDoc::Parser.can_parse(rel_file_name) then
283
+ file_list[rel_file_name] = mtime
284
+ end
285
+ when "directory" then
286
+ next if UNCONDITIONALLY_SKIPPED_DIRECTORIES.include?(rel_file_name)
287
+
288
+ basename = File.basename(rel_file_name)
289
+ next if options.skip_tests && TEST_SUITE_DIRECTORY_NAMES.include?(basename)
290
+
291
+ created_rid = File.join rel_file_name, "created.rid"
292
+ next if File.file? created_rid
293
+
294
+ dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME
295
+
296
+ if File.file? dot_doc then
297
+ file_list.update(parse_dot_doc_file(rel_file_name, dot_doc))
298
+ else
299
+ file_list.update(list_files_in_directory(rel_file_name))
300
+ end
301
+ else
302
+ warn "rdoc can't parse the #{type} #{rel_file_name}"
303
+ end
304
+ end
305
+
306
+ file_list
307
+ end
308
+
309
+ ##
310
+ # Return a list of the files to be processed in a directory. We know that
311
+ # this directory doesn't have a .document file, so we're looking for real
312
+ # files. However we may well contain subdirectories which must be tested
313
+ # for .document files.
314
+
315
+ def list_files_in_directory(dir)
316
+ files = Dir.glob File.join(dir, "*")
317
+
318
+ normalized_file_list files, false, @options.exclude
319
+ end
320
+
321
+ ##
322
+ # Parses +filename+ and returns an RDoc::TopLevel
323
+
324
+ def parse_file(filename)
325
+ encoding = @options.encoding
326
+ filename = filename.encode encoding
327
+
328
+ @stats.add_file filename
329
+
330
+ return if RDoc::Parser.binary? filename
331
+
332
+ content = RDoc::Encoding.read_file filename, encoding
333
+
334
+ return unless content
335
+
336
+ top_level = @store.add_file filename, relative_name: relative_path_for(filename)
337
+
338
+ parser = RDoc::Parser.for top_level, content, @options, @stats
339
+
340
+ return unless parser
341
+
342
+ parser.scan
343
+
344
+ # restart documentation for the classes & modules found
345
+ top_level.classes_or_modules.each do |cm|
346
+ cm.done_documenting = false
347
+ end
348
+
349
+ top_level
350
+
351
+ rescue Errno::EACCES => e
352
+ $stderr.puts <<-EOF
353
+ Unable to read #{filename}, #{e.message}
354
+
355
+ Please check the permissions for this file. Perhaps you do not have access to
356
+ it or perhaps the original author's permissions are to restrictive. If the
357
+ this is not your library please report a bug to the author.
358
+ EOF
359
+ rescue => e
360
+ syntax_check_command = syntax_check_command_for filename, parser&.class
361
+ syntax_check_message = if syntax_check_command
362
+ <<~MESSAGE
363
+ Before reporting this, could you check that the file you're documenting
364
+ has proper syntax:
365
+
366
+ #{syntax_check_command}
367
+ MESSAGE
368
+ else
369
+ <<~MESSAGE
370
+ Before reporting this, could you check that the file you're documenting
371
+ has proper syntax for its language?
372
+ MESSAGE
373
+ end
374
+
375
+ $stderr.puts <<-EOF
376
+ #{syntax_check_message}
377
+ RDoc's parsers are not full language parsers and may fail when fed invalid
378
+ source files.
379
+
380
+ The internal error was:
381
+
382
+ \t(#{e.class}) #{e.message}
383
+
384
+ EOF
385
+
386
+ $stderr.puts e.backtrace.join("\n\t") if $DEBUG_RDOC
387
+
388
+ raise e
389
+ end
390
+
391
+ def syntax_check_command_for(filename, parser_class = RDoc::Parser.can_parse_by_name(filename))
392
+ if parser_class == RDoc::Parser::Ruby
393
+ "#{Gem.ruby} -c #{filename}"
394
+ elsif parser_class == RDoc::Parser::C
395
+ cc = ENV['CC']
396
+ cc = 'cc' if cc.nil? || cc.empty?
397
+ "#{cc} -fsyntax-only #{filename}"
398
+ end
399
+ end
400
+
401
+ ##
402
+ # Returns the relative path for +filename+ against +options.root+ (and
403
+ # +options.page_dir+ when set). This is the key used by RDoc::Store to
404
+ # identify files.
405
+
406
+ def relative_path_for(filename)
407
+ filename_path = Pathname(filename).expand_path
408
+ begin
409
+ relative_path = filename_path.relative_path_from @options.root
410
+ rescue ArgumentError
411
+ relative_path = filename_path
412
+ end
413
+
414
+ if @options.page_dir &&
415
+ relative_path.to_s.start_with?(@options.page_dir.to_s)
416
+ relative_path =
417
+ relative_path.relative_path_from @options.page_dir
418
+ end
419
+
420
+ relative_path.to_s
421
+ end
422
+
423
+ ##
424
+ # Parse each file on the command line, recursively entering directories.
425
+
426
+ def parse_files(files)
427
+ file_list = gather_files files
428
+ @stats = RDoc::Stats.new @store, file_list.length, @options.verbosity
429
+
430
+ return [] if file_list.empty?
431
+
432
+ # This workaround can be removed after the :main: directive is removed
433
+ original_options = @options.dup
434
+ @stats.begin_adding
435
+
436
+ file_info = file_list.map do |filename|
437
+ @current = filename
438
+ parse_file filename
439
+ end.compact
440
+
441
+ @store.resolve_c_superclasses
442
+
443
+ @stats.done_adding
444
+ @options = original_options
445
+
446
+ file_info
447
+ end
448
+
449
+ ##
450
+ # Removes file extensions known to be unparseable from +files+ and TAGS
451
+ # files for emacs and vim.
452
+
453
+ def remove_unparseable(files)
454
+ files.reject do |file, *|
455
+ file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)\z/i or
456
+ (file =~ /tags\z/i and
457
+ /\A(\f\n[^,]+,\d+$|!_TAG_)/.match?(File.binread(file, 100)))
458
+ end
459
+ end
460
+
461
+ ##
462
+ # Generates documentation or a coverage report depending upon the settings
463
+ # in +options+.
464
+ #
465
+ # +options+ can be either an RDoc::Options instance or an array of strings
466
+ # equivalent to the strings that would be passed on the command line like
467
+ # <tt>%w[-q -o doc -t My\ Doc\ Title]</tt>. #document will automatically
468
+ # call RDoc::Options#finish if an options instance was given.
469
+ #
470
+ # For a list of options, see either RDoc::Options or <tt>rdoc --help</tt>.
471
+ #
472
+ # By default, output will be stored in a directory called "doc" below the
473
+ # current directory, so make sure you're somewhere writable before invoking.
474
+
475
+ def document(options)
476
+ if RDoc::Options === options then
477
+ @options = options
478
+ else
479
+ @options = RDoc::Options.load_options
480
+ @options.parse options
481
+ end
482
+ @options.finish
483
+
484
+ @store = RDoc::Store.new(@options)
485
+
486
+ if @options.pipe then
487
+ handle_pipe
488
+ exit
489
+ end
490
+
491
+ if @options.server_port
492
+ @store.load_cache
493
+
494
+ parse_files @options.files
495
+ record_auto_discovered_rbs_signature_mtimes
496
+
497
+ @options.default_title = "RDoc Documentation"
498
+
499
+ load_auto_discovered_rbs_signatures
500
+ @store.complete @options.visibility
501
+
502
+ start_server
503
+ exit
504
+ end
505
+
506
+ unless @options.coverage_report then
507
+ @last_modified = setup_output_dir @options.op_dir, @options.force_update
508
+ end
509
+
510
+ @start_time = Time.now
511
+
512
+ @store.load_cache
513
+
514
+ auto_discovered_rbs_signatures_changed = auto_discovered_rbs_signatures_changed?
515
+ # When only auto-discovered RBS signatures changed, no Ruby file would be
516
+ # reparsed under normal mtime checks. The store cache holds class metadata
517
+ # but not live RDoc::Context objects, so the generator would have nothing
518
+ # to iterate. Force a full reparse so updated signatures show up in the
519
+ # rendered output.
520
+ @last_modified.clear if auto_discovered_rbs_signatures_changed
521
+
522
+ file_info = parse_files @options.files
523
+ record_auto_discovered_rbs_signature_mtimes
524
+
525
+ @options.default_title = "RDoc Documentation"
526
+
527
+ load_auto_discovered_rbs_signatures
528
+
529
+ @store.complete @options.visibility
530
+
531
+ @stats.coverage_level = @options.coverage_report
532
+
533
+ if @options.coverage_report then
534
+ puts
535
+
536
+ puts @stats.report
537
+ elsif file_info.empty? && !auto_discovered_rbs_signatures_changed then
538
+ $stderr.puts "\nNo newer files." unless @options.quiet
539
+ else
540
+ gen_klass = @options.generator
541
+
542
+ @generator = gen_klass.new @store, @options
543
+
544
+ generate
545
+ end
546
+
547
+ if @stats and (@options.coverage_report or not @options.quiet) then
548
+ puts
549
+ puts @stats.summary
550
+ end
551
+
552
+ exit @stats.fully_documented? if @options.coverage_report
553
+ end
554
+
555
+ ##
556
+ # Generates documentation for +file_info+ (from #parse_files) into the
557
+ # output dir using the generator selected
558
+ # by the RDoc options
559
+
560
+ def generate
561
+ if @options.dry_run then
562
+ # do nothing
563
+ @generator.generate
564
+ else
565
+ Dir.chdir @options.op_dir do
566
+ unless @options.quiet then
567
+ $stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..."
568
+ uri = "file://#{Dir.pwd}/index.html"
569
+ ref = $stderr.tty? ? "\e]8;;#{uri}\e\\#{uri}\e]8;;\e\\" : uri
570
+ $stderr.puts "\nYou can visit the home page at: #{ref}"
571
+ end
572
+
573
+ @generator.generate
574
+ update_output_dir '.', @start_time, @last_modified
575
+ end
576
+ end
577
+ end
578
+
579
+ ##
580
+ # Loads RBS type signatures from the project's +sig+ directory and RBS
581
+ # stdlib, then merges them into the store's code objects.
582
+
583
+ def load_auto_discovered_rbs_signatures
584
+ sig_dirs = []
585
+ sig_dir = File.join(@options.root.to_s, 'sig')
586
+ sig_dirs << sig_dir if File.directory?(sig_dir)
587
+ signatures = RDoc::RbsHelper.load_signatures(*sig_dirs)
588
+ @store.merge_rbs_signatures(signatures)
589
+ rescue RBS::BaseError, Errno::ENOENT, LoadError => e
590
+ # In server mode, a previous successful load may have populated the store;
591
+ # drop those signatures so a now-broken sig file doesn't keep showing
592
+ # stale types alongside the warning.
593
+ @store.clear_rbs_signatures
594
+ @options.warn "Failed to load RBS type signatures: #{e.message}"
595
+ end
596
+
597
+ ##
598
+ # Returns RBS files that RDoc auto-discovers for signature loading.
599
+
600
+ def auto_discovered_rbs_signature_files
601
+ Dir[File.join(@options.root.to_s, 'sig', '**', '*.rbs')].sort
602
+ end
603
+
604
+ ##
605
+ # Returns true if any auto-discovered RBS signature file has changed since
606
+ # the last run.
607
+
608
+ def auto_discovered_rbs_signatures_changed?
609
+ current = auto_discovered_rbs_signature_mtimes
610
+ previous = @last_modified.select { |file, _| auto_discovered_rbs_signature_file?(file) }
611
+
612
+ return true unless (previous.keys - current.keys).empty?
613
+
614
+ current.any? do |file, mtime|
615
+ last_modified = @last_modified[file]
616
+ last_modified.nil? || mtime.to_i > last_modified.to_i
617
+ end
618
+ end
619
+
620
+ ##
621
+ # Records auto-discovered RBS signature file mtimes so normal generation
622
+ # freshness checks and the live server watcher can see signature-only edits.
623
+
624
+ def record_auto_discovered_rbs_signature_mtimes
625
+ @last_modified.reject! { |file, _| auto_discovered_rbs_signature_file?(file) }
626
+ @last_modified.merge! auto_discovered_rbs_signature_mtimes
627
+ end
628
+
629
+ ##
630
+ # Files watched by the live preview server.
631
+
632
+ def watch_files
633
+ (@last_modified.keys + auto_discovered_rbs_signature_files).uniq
634
+ end
635
+
636
+ ##
637
+ # Returns true for project RBS files that are auto-discovered for signature
638
+ # loading. RDoc parses any selected .rbs file as documentation input, but
639
+ # only +sig/**/*.rbs+ files are loaded through RBS::EnvironmentLoader for
640
+ # type signature merging and live-reload bookkeeping.
641
+
642
+ def auto_discovered_rbs_signature_file?(file) # :nodoc:
643
+ return false unless File.extname(file) == '.rbs'
644
+
645
+ root = Pathname(@options.root.to_s).expand_path
646
+ relative_path = Pathname(file).expand_path.relative_path_from root
647
+ relative_path.each_filename.first == 'sig'
648
+ rescue ArgumentError
649
+ # file and root may be on different drives on Windows
650
+ false
651
+ end
652
+
653
+ ##
654
+ # Returns mtimes for auto-discovered RBS signature files.
655
+
656
+ def auto_discovered_rbs_signature_mtimes # :nodoc:
657
+ auto_discovered_rbs_signature_files.each_with_object({}) do |file, mtimes|
658
+ mtime = RDoc.safe_mtime(file)
659
+ mtimes[file] = mtime if mtime
660
+ end
661
+ end
662
+
663
+ ##
664
+ # Starts a live-reloading HTTP server for previewing documentation.
665
+ # Called from #document when <tt>--server</tt> is given.
666
+
667
+ def start_server
668
+ server = RDoc::Server.new(self, @options.server_port)
669
+ server.start
670
+ end
671
+
672
+ ##
673
+ # Removes a siginfo handler and replaces the previous
674
+
675
+ def remove_siginfo_handler
676
+ return unless Signal.list.key? 'INFO'
677
+
678
+ handler = @old_siginfo || 'DEFAULT'
679
+
680
+ trap 'INFO', handler
681
+ end
682
+
683
+ ##
684
+ # Returns true when +extension+ is the RBS gem's RDoc discovery hook.
685
+ # Released RBS gems install their plugin through this hook, so skip it to
686
+ # avoid replacing the built-in parser during discovery.
687
+
688
+ def self.rbs_discovery_extension?(extension) # :nodoc:
689
+ extension = File.expand_path(extension)
690
+
691
+ Gem::Specification.find_all_by_name('rbs').any? do |spec|
692
+ File.expand_path('lib/rdoc/discover.rb', spec.full_gem_path) == extension
693
+ end
694
+ end
695
+
696
+ end
697
+
698
+ # Load built-in parser registrations before RubyGems discovery, then skip the
699
+ # RBS gem's plugin hook so it cannot replace RDoc::Parser::RBS.
700
+ require_relative 'parser'
701
+
702
+ begin
703
+ require 'rubygems'
704
+
705
+ rdoc_extensions = Gem.find_latest_files 'rdoc/discover'
706
+
707
+ rdoc_extensions.each do |extension|
708
+ next if RDoc::RDoc.rbs_discovery_extension?(extension)
709
+
710
+ begin
711
+ load extension
712
+ rescue => e
713
+ warn "error loading #{extension.inspect}: #{e.message} (#{e.class})"
714
+ warn "\t#{e.backtrace.join "\n\t"}" if $DEBUG
715
+ end
716
+ end
717
+ rescue LoadError
718
+ end
719
+
720
+ # require built-in generators after discovery in case they've been replaced
721
+ require_relative 'generator/darkfish'
722
+ require_relative 'generator/aliki'
723
+ require_relative 'generator/ri'
724
+ require_relative 'generator/pot'