mega-max-hub 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/mega-max-hub.gemspec +11 -0
  3. data/rdoc-8.0.0/CONTRIBUTING.md +195 -0
  4. data/rdoc-8.0.0/CVE-2013-0256.rdoc +49 -0
  5. data/rdoc-8.0.0/History.rdoc +1668 -0
  6. data/rdoc-8.0.0/LEGAL.rdoc +56 -0
  7. data/rdoc-8.0.0/LICENSE.rdoc +63 -0
  8. data/rdoc-8.0.0/README.md +236 -0
  9. data/rdoc-8.0.0/RI.md +842 -0
  10. data/rdoc-8.0.0/TODO.rdoc +60 -0
  11. data/rdoc-8.0.0/doc/markup_reference/markdown.md +659 -0
  12. data/rdoc-8.0.0/doc/markup_reference/rdoc.rdoc +1169 -0
  13. data/rdoc-8.0.0/exe/rdoc +43 -0
  14. data/rdoc-8.0.0/exe/ri +12 -0
  15. data/rdoc-8.0.0/lib/rdoc/code_object/alias.rb +98 -0
  16. data/rdoc-8.0.0/lib/rdoc/code_object/any_method.rb +387 -0
  17. data/rdoc-8.0.0/lib/rdoc/code_object/attr.rb +178 -0
  18. data/rdoc-8.0.0/lib/rdoc/code_object/class_module.rb +969 -0
  19. data/rdoc-8.0.0/lib/rdoc/code_object/constant.rb +221 -0
  20. data/rdoc-8.0.0/lib/rdoc/code_object/context/section.rb +182 -0
  21. data/rdoc-8.0.0/lib/rdoc/code_object/context.rb +1238 -0
  22. data/rdoc-8.0.0/lib/rdoc/code_object/extend.rb +9 -0
  23. data/rdoc-8.0.0/lib/rdoc/code_object/include.rb +9 -0
  24. data/rdoc-8.0.0/lib/rdoc/code_object/method_attr.rb +417 -0
  25. data/rdoc-8.0.0/lib/rdoc/code_object/mixin.rb +123 -0
  26. data/rdoc-8.0.0/lib/rdoc/code_object/normal_class.rb +92 -0
  27. data/rdoc-8.0.0/lib/rdoc/code_object/normal_module.rb +73 -0
  28. data/rdoc-8.0.0/lib/rdoc/code_object/require.rb +51 -0
  29. data/rdoc-8.0.0/lib/rdoc/code_object/single_class.rb +30 -0
  30. data/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb +286 -0
  31. data/rdoc-8.0.0/lib/rdoc/code_object.rb +393 -0
  32. data/rdoc-8.0.0/lib/rdoc/code_objects.rb +5 -0
  33. data/rdoc-8.0.0/lib/rdoc/comment.rb +353 -0
  34. data/rdoc-8.0.0/lib/rdoc/cross_reference.rb +215 -0
  35. data/rdoc-8.0.0/lib/rdoc/encoding.rb +120 -0
  36. data/rdoc-8.0.0/lib/rdoc/erb_partial.rb +18 -0
  37. data/rdoc-8.0.0/lib/rdoc/erbio.rb +37 -0
  38. data/rdoc-8.0.0/lib/rdoc/generator/aliki.rb +200 -0
  39. data/rdoc-8.0.0/lib/rdoc/generator/darkfish.rb +824 -0
  40. data/rdoc-8.0.0/lib/rdoc/generator/json_index.rb +284 -0
  41. data/rdoc-8.0.0/lib/rdoc/generator/markup.rb +196 -0
  42. data/rdoc-8.0.0/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  43. data/rdoc-8.0.0/lib/rdoc/generator/pot/po.rb +84 -0
  44. data/rdoc-8.0.0/lib/rdoc/generator/pot/po_entry.rb +141 -0
  45. data/rdoc-8.0.0/lib/rdoc/generator/pot.rb +94 -0
  46. data/rdoc-8.0.0/lib/rdoc/generator/ri.rb +30 -0
  47. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
  48. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  49. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  50. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
  51. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  52. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  53. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  54. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  55. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
  56. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
  57. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  58. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  59. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  60. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  61. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  62. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  63. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
  64. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
  65. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  66. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
  67. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
  68. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  69. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
  70. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  71. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  72. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  73. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  74. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  75. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  76. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  77. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_head.rhtml +43 -0
  78. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +5 -0
  79. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +17 -0
  80. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +17 -0
  81. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +16 -0
  82. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +21 -0
  83. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  84. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +32 -0
  85. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +6 -0
  86. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +15 -0
  87. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  88. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +39 -0
  89. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  90. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/class.rhtml +220 -0
  91. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  92. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/rdoc.css +701 -0
  93. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  94. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  95. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  96. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  97. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  98. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  99. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  100. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  101. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  102. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  103. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  104. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  105. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  106. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  107. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  108. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  109. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  110. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  111. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  112. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  113. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  114. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  115. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  116. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  117. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  118. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  119. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  120. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  121. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  122. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  123. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  124. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/index.rhtml +24 -0
  125. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/darkfish.js +140 -0
  126. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/search.js +120 -0
  127. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/page.rhtml +19 -0
  128. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +21 -0
  129. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +65 -0
  130. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +72 -0
  131. data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  132. data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/searcher.js +271 -0
  133. data/rdoc-8.0.0/lib/rdoc/generator.rb +52 -0
  134. data/rdoc-8.0.0/lib/rdoc/i18n/locale.rb +102 -0
  135. data/rdoc-8.0.0/lib/rdoc/i18n/text.rb +126 -0
  136. data/rdoc-8.0.0/lib/rdoc/i18n.rb +10 -0
  137. data/rdoc-8.0.0/lib/rdoc/known_classes.rb +74 -0
  138. data/rdoc-8.0.0/lib/rdoc/markdown/entities.rb +2131 -0
  139. data/rdoc-8.0.0/lib/rdoc/markdown/literals.kpeg +21 -0
  140. data/rdoc-8.0.0/lib/rdoc/markdown/literals.rb +454 -0
  141. data/rdoc-8.0.0/lib/rdoc/markdown.kpeg +1315 -0
  142. data/rdoc-8.0.0/lib/rdoc/markdown.rb +16865 -0
  143. data/rdoc-8.0.0/lib/rdoc/markup/blank_line.rb +29 -0
  144. data/rdoc-8.0.0/lib/rdoc/markup/block_quote.rb +14 -0
  145. data/rdoc-8.0.0/lib/rdoc/markup/document.rb +164 -0
  146. data/rdoc-8.0.0/lib/rdoc/markup/element.rb +21 -0
  147. data/rdoc-8.0.0/lib/rdoc/markup/formatter.rb +285 -0
  148. data/rdoc-8.0.0/lib/rdoc/markup/hard_break.rb +34 -0
  149. data/rdoc-8.0.0/lib/rdoc/markup/heading.rb +170 -0
  150. data/rdoc-8.0.0/lib/rdoc/markup/include.rb +42 -0
  151. data/rdoc-8.0.0/lib/rdoc/markup/indented_paragraph.rb +47 -0
  152. data/rdoc-8.0.0/lib/rdoc/markup/inline_parser.rb +312 -0
  153. data/rdoc-8.0.0/lib/rdoc/markup/list.rb +101 -0
  154. data/rdoc-8.0.0/lib/rdoc/markup/list_item.rb +99 -0
  155. data/rdoc-8.0.0/lib/rdoc/markup/paragraph.rb +28 -0
  156. data/rdoc-8.0.0/lib/rdoc/markup/parser.rb +585 -0
  157. data/rdoc-8.0.0/lib/rdoc/markup/pre_process.rb +317 -0
  158. data/rdoc-8.0.0/lib/rdoc/markup/raw.rb +66 -0
  159. data/rdoc-8.0.0/lib/rdoc/markup/rule.rb +20 -0
  160. data/rdoc-8.0.0/lib/rdoc/markup/table.rb +64 -0
  161. data/rdoc-8.0.0/lib/rdoc/markup/to_ansi.rb +144 -0
  162. data/rdoc-8.0.0/lib/rdoc/markup/to_bs.rb +86 -0
  163. data/rdoc-8.0.0/lib/rdoc/markup/to_html.rb +682 -0
  164. data/rdoc-8.0.0/lib/rdoc/markup/to_html_crossref.rb +261 -0
  165. data/rdoc-8.0.0/lib/rdoc/markup/to_html_snippet.rb +287 -0
  166. data/rdoc-8.0.0/lib/rdoc/markup/to_joined_paragraph.rb +41 -0
  167. data/rdoc-8.0.0/lib/rdoc/markup/to_label.rb +84 -0
  168. data/rdoc-8.0.0/lib/rdoc/markup/to_markdown.rb +215 -0
  169. data/rdoc-8.0.0/lib/rdoc/markup/to_rdoc.rb +421 -0
  170. data/rdoc-8.0.0/lib/rdoc/markup/to_table_of_contents.rb +88 -0
  171. data/rdoc-8.0.0/lib/rdoc/markup/to_test.rb +77 -0
  172. data/rdoc-8.0.0/lib/rdoc/markup/to_tt_only.rb +107 -0
  173. data/rdoc-8.0.0/lib/rdoc/markup/verbatim.rb +83 -0
  174. data/rdoc-8.0.0/lib/rdoc/markup.rb +219 -0
  175. data/rdoc-8.0.0/lib/rdoc/options.rb +1412 -0
  176. data/rdoc-8.0.0/lib/rdoc/parser/c.rb +1227 -0
  177. data/rdoc-8.0.0/lib/rdoc/parser/changelog.rb +379 -0
  178. data/rdoc-8.0.0/lib/rdoc/parser/markdown.rb +22 -0
  179. data/rdoc-8.0.0/lib/rdoc/parser/rbs.rb +275 -0
  180. data/rdoc-8.0.0/lib/rdoc/parser/rd.rb +22 -0
  181. data/rdoc-8.0.0/lib/rdoc/parser/ruby.rb +1266 -0
  182. data/rdoc-8.0.0/lib/rdoc/parser/ruby_colorizer.rb +253 -0
  183. data/rdoc-8.0.0/lib/rdoc/parser/simple.rb +44 -0
  184. data/rdoc-8.0.0/lib/rdoc/parser/text.rb +11 -0
  185. data/rdoc-8.0.0/lib/rdoc/parser.rb +298 -0
  186. data/rdoc-8.0.0/lib/rdoc/rbs_helper.rb +186 -0
  187. data/rdoc-8.0.0/lib/rdoc/rd/block_parser.rb +1706 -0
  188. data/rdoc-8.0.0/lib/rdoc/rd/block_parser.ry +643 -0
  189. data/rdoc-8.0.0/lib/rdoc/rd/inline.rb +71 -0
  190. data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.rb +1854 -0
  191. data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.ry +593 -0
  192. data/rdoc-8.0.0/lib/rdoc/rd.rb +99 -0
  193. data/rdoc-8.0.0/lib/rdoc/rdoc.rb +724 -0
  194. data/rdoc-8.0.0/lib/rdoc/ri/driver.rb +1572 -0
  195. data/rdoc-8.0.0/lib/rdoc/ri/formatter.rb +6 -0
  196. data/rdoc-8.0.0/lib/rdoc/ri/paths.rb +171 -0
  197. data/rdoc-8.0.0/lib/rdoc/ri/servlet.rb +452 -0
  198. data/rdoc-8.0.0/lib/rdoc/ri/store.rb +6 -0
  199. data/rdoc-8.0.0/lib/rdoc/ri/task.rb +71 -0
  200. data/rdoc-8.0.0/lib/rdoc/ri.rb +21 -0
  201. data/rdoc-8.0.0/lib/rdoc/rubygems_hook.rb +327 -0
  202. data/rdoc-8.0.0/lib/rdoc/server.rb +460 -0
  203. data/rdoc-8.0.0/lib/rdoc/stats/normal.rb +58 -0
  204. data/rdoc-8.0.0/lib/rdoc/stats/quiet.rb +59 -0
  205. data/rdoc-8.0.0/lib/rdoc/stats/verbose.rb +44 -0
  206. data/rdoc-8.0.0/lib/rdoc/stats.rb +484 -0
  207. data/rdoc-8.0.0/lib/rdoc/store.rb +1205 -0
  208. data/rdoc-8.0.0/lib/rdoc/task.rb +355 -0
  209. data/rdoc-8.0.0/lib/rdoc/text.rb +244 -0
  210. data/rdoc-8.0.0/lib/rdoc/token_stream.rb +104 -0
  211. data/rdoc-8.0.0/lib/rdoc/tom_doc.rb +257 -0
  212. data/rdoc-8.0.0/lib/rdoc/version.rb +10 -0
  213. data/rdoc-8.0.0/lib/rdoc.rb +239 -0
  214. data/rdoc-8.0.0/lib/rubygems_plugin.rb +14 -0
  215. data/rdoc-8.0.0/man/ri.1 +249 -0
  216. data/rdoc-8.0.0/rdoc-logo.svg +43 -0
  217. data/rdoc-8.0.0/rdoc.gemspec +74 -0
  218. metadata +256 -0
@@ -0,0 +1,1412 @@
1
+ # frozen_string_literal: true
2
+ require 'optparse'
3
+ require 'pathname'
4
+
5
+ ##
6
+ # RDoc::Options handles the parsing and storage of options
7
+ #
8
+ # == Saved Options
9
+ #
10
+ # You can save some options like the markup format in the
11
+ # <tt>.rdoc_options</tt> file in your gem. The easiest way to do this is:
12
+ #
13
+ # rdoc --markup tomdoc --write-options
14
+ #
15
+ # Which will automatically create the file and fill it with the options you
16
+ # specified.
17
+ #
18
+ # The following options will not be saved since they interfere with the user's
19
+ # preferences or with the normal operation of RDoc:
20
+ #
21
+ # * +--coverage-report+
22
+ # * +--dry-run+
23
+ # * +--encoding+
24
+ # * +--force-update+
25
+ # * +--format+
26
+ # * +--pipe+
27
+ # * +--quiet+
28
+ # * +--template+
29
+ # * +--verbose+
30
+ #
31
+ # == Custom Options
32
+ #
33
+ # Generators can hook into RDoc::Options to add generator-specific command
34
+ # line options.
35
+ #
36
+ # When <tt>--format</tt> is encountered in ARGV, RDoc calls ::setup_options on
37
+ # the generator class to add extra options to the option parser. Options for
38
+ # custom generators must occur after <tt>--format</tt>. <tt>rdoc --help</tt>
39
+ # will list options for all installed generators.
40
+ #
41
+ # Example:
42
+ #
43
+ # class RDoc::Generator::Spellcheck
44
+ # RDoc::RDoc.add_generator self
45
+ #
46
+ # def self.setup_options rdoc_options
47
+ # op = rdoc_options.option_parser
48
+ #
49
+ # op.on('--spell-dictionary DICTIONARY',
50
+ # RDoc::Options::Path) do |dictionary|
51
+ # rdoc_options.spell_dictionary = dictionary
52
+ # end
53
+ # end
54
+ # end
55
+ #
56
+ # Of course, RDoc::Options does not respond to +spell_dictionary+ by default
57
+ # so you will need to add it:
58
+ #
59
+ # class RDoc::Options
60
+ #
61
+ # ##
62
+ # # The spell dictionary used by the spell-checking plugin.
63
+ #
64
+ # attr_accessor :spell_dictionary
65
+ #
66
+ # end
67
+ #
68
+ # == Option Validators
69
+ #
70
+ # OptionParser validators will validate and cast user input values. In
71
+ # addition to the validators that ship with OptionParser (String, Integer,
72
+ # Float, TrueClass, FalseClass, Array, Regexp, Date, Time, URI, etc.),
73
+ # RDoc::Options adds Path, PathArray and Template.
74
+
75
+ class RDoc::Options
76
+
77
+ ##
78
+ # RDoc options ignored (or handled specially) by --write-options
79
+
80
+ SPECIAL = %w[
81
+ coverage_report
82
+ dry_run
83
+ encoding
84
+ files
85
+ force_output
86
+ force_update
87
+ generator
88
+ generator_name
89
+ generator_options
90
+ generators
91
+ locale
92
+ op_dir
93
+ page_dir
94
+ option_parser
95
+ pipe
96
+ rdoc_include
97
+ root
98
+ server_port
99
+ static_path
100
+ template
101
+ template_dir
102
+ update_output_dir
103
+ verbosity
104
+ write_options
105
+ ]
106
+
107
+ ##
108
+ # Option validator for OptionParser that matches a directory that exists on
109
+ # the filesystem.
110
+
111
+ Directory = Object.new
112
+
113
+ ##
114
+ # Option validator for OptionParser that matches a file or directory that
115
+ # exists on the filesystem.
116
+
117
+ Path = Object.new
118
+
119
+ ##
120
+ # Option validator for OptionParser that matches a comma-separated list of
121
+ # files or directories that exist on the filesystem.
122
+
123
+ PathArray = Object.new
124
+
125
+ ##
126
+ # Option validator for OptionParser that matches a template directory for an
127
+ # installed generator that lives in
128
+ # <tt>"rdoc/generator/template/#{template_name}"</tt>
129
+
130
+ Template = Object.new
131
+
132
+ ##
133
+ # Character-set for HTML output. #encoding is preferred over #charset
134
+
135
+ attr_accessor :charset
136
+
137
+ ##
138
+ # If true, RDoc will not write any files.
139
+
140
+ attr_accessor :dry_run
141
+
142
+ ##
143
+ # The output encoding. All input files will be transcoded to this encoding.
144
+ #
145
+ # The default encoding is UTF-8. This is set via --encoding.
146
+
147
+ attr_accessor :encoding
148
+
149
+ ##
150
+ # Files matching this pattern will be excluded
151
+
152
+ attr_writer :exclude
153
+
154
+ ##
155
+ # The list of files to be processed
156
+
157
+ attr_accessor :files
158
+
159
+ ##
160
+ # Create the output even if the output directory does not look
161
+ # like an rdoc output directory
162
+
163
+ attr_accessor :force_output
164
+
165
+ ##
166
+ # Scan newer sources than the flag file if true.
167
+
168
+ attr_accessor :force_update
169
+
170
+ ##
171
+ # Formatter to mark up text with
172
+
173
+ attr_accessor :formatter
174
+
175
+ ##
176
+ # Description of the output generator (set with the <tt>--format</tt> option)
177
+
178
+ attr_accessor :generator
179
+
180
+ ##
181
+ # For #==
182
+
183
+ attr_reader :generator_name # :nodoc:
184
+
185
+ ##
186
+ # Loaded generator options. Used to prevent --help from loading the same
187
+ # options multiple times.
188
+
189
+ attr_accessor :generator_options
190
+
191
+ ##
192
+ # Old rdoc behavior: hyperlink all words that match a method name,
193
+ # even if not preceded by '#' or '::'
194
+
195
+ attr_accessor :hyperlink_all
196
+
197
+ ##
198
+ # Include line numbers in the source code
199
+
200
+ attr_accessor :line_numbers
201
+
202
+ ##
203
+ # The output locale.
204
+
205
+ attr_accessor :locale
206
+
207
+ ##
208
+ # The directory where locale data live.
209
+
210
+ attr_accessor :locale_dir
211
+
212
+ ##
213
+ # Name of the file, class or module to display in the initial index page (if
214
+ # not specified the first file we encounter is used)
215
+
216
+ attr_accessor :main_page
217
+
218
+ ##
219
+ # The markup format.
220
+ # One of: +rdoc+ (the default), +markdown+, +rd+, +tomdoc+.
221
+ # See {Markup Formats}[rdoc-ref:RDoc::Markup@Markup+Formats].
222
+ attr_accessor :markup
223
+
224
+ ##
225
+ # If true, only report on undocumented files
226
+
227
+ attr_accessor :coverage_report
228
+
229
+ ##
230
+ # The name of the output directory
231
+
232
+ attr_accessor :op_dir
233
+
234
+ ##
235
+ # The OptionParser for this instance
236
+
237
+ attr_accessor :option_parser
238
+
239
+ ##
240
+ # Output heading decorations?
241
+ attr_accessor :output_decoration
242
+
243
+ ##
244
+ # Directory where guides, FAQ, and other pages not associated with a class
245
+ # live. You may leave this unset if these are at the root of your project.
246
+
247
+ attr_accessor :page_dir
248
+
249
+ ##
250
+ # Is RDoc in pipe mode?
251
+
252
+ attr_accessor :pipe
253
+
254
+ ##
255
+ # Array of directories to search for files to satisfy an :include:
256
+
257
+ attr_accessor :rdoc_include
258
+
259
+ ##
260
+ # Root of the source documentation will be generated for. Set this when
261
+ # building documentation outside the source directory. Defaults to the
262
+ # current directory.
263
+
264
+ attr_accessor :root
265
+
266
+ ##
267
+ # Include the '#' at the front of hyperlinked instance method names
268
+
269
+ attr_accessor :show_hash
270
+
271
+ ##
272
+ # Directory to copy static files from
273
+
274
+ attr_accessor :static_path
275
+
276
+ ##
277
+ # The number of columns in a tab
278
+
279
+ attr_accessor :tab_width
280
+
281
+ ##
282
+ # Template to be used when generating output
283
+
284
+ attr_accessor :template
285
+
286
+ ##
287
+ # Directory the template lives in
288
+
289
+ attr_accessor :template_dir
290
+
291
+ ##
292
+ # Additional template stylesheets
293
+
294
+ attr_accessor :template_stylesheets
295
+
296
+ ##
297
+ # Documentation title
298
+
299
+ attr_accessor :title
300
+
301
+ ##
302
+ # Should RDoc update the timestamps in the output dir?
303
+
304
+ attr_accessor :update_output_dir
305
+
306
+ ##
307
+ # Verbosity, zero means quiet
308
+
309
+ attr_accessor :verbosity
310
+
311
+ ##
312
+ # Warn if rdoc-ref links can't be resolved
313
+ # Default is +true+
314
+
315
+ attr_accessor :warn_missing_rdoc_ref
316
+
317
+ ##
318
+ # URL of web cvs frontend
319
+
320
+ attr_accessor :webcvs
321
+
322
+ ##
323
+ # Minimum visibility of a documented method. One of +:public+, +:protected+,
324
+ # +:private+ or +:nodoc+.
325
+ #
326
+ # The +:nodoc+ visibility ignores all directives related to visibility. The
327
+ # other visibilities may be overridden on a per-method basis with the :doc:
328
+ # directive.
329
+
330
+ attr_reader :visibility
331
+
332
+ ##
333
+ # When set to a port number, starts a live-reloading server instead of
334
+ # writing files. Defaults to +false+ (no server). Set via
335
+ # <tt>--server[=PORT]</tt>.
336
+
337
+ attr_reader :server_port
338
+
339
+ ##
340
+ # Indicates if files of test suites should be skipped
341
+ attr_accessor :skip_tests
342
+
343
+ ##
344
+ # Embed mixin methods, attributes, and constants into class documentation. Set via
345
+ # +--[no-]embed-mixins+ (Default is +false+.)
346
+ attr_accessor :embed_mixins
347
+
348
+ ##
349
+ # Exclude the default patterns as well if true.
350
+ attr_reader :apply_default_exclude
351
+
352
+ ##
353
+ # Words to be ignored in autolink cross-references
354
+ attr_accessor :autolink_excluded_words
355
+
356
+ ##
357
+ # The prefix to use for class and module page paths
358
+
359
+ attr_accessor :class_module_path_prefix
360
+
361
+ ##
362
+ # The prefix to use for file page paths
363
+
364
+ attr_accessor :file_path_prefix
365
+
366
+ ##
367
+ # The preferred root URL for the documentation
368
+
369
+ attr_accessor :canonical_root
370
+
371
+ ##
372
+ # Custom footer content configuration for themes that support it.
373
+ # Currently only supported by the Aliki theme.
374
+ #
375
+ # A hash where keys are column titles and values are hashes of link text => URL pairs.
376
+ # Each column will be displayed in the upper footer section.
377
+ #
378
+ # Example:
379
+ # {
380
+ # "DOCUMENTATION" => {"Home" => "/index.html", "Guide" => "/guide.html"},
381
+ # "RESOURCES" => {"RDoc" => "https://ruby.github.io/rdoc/", "GitHub" => "https://github.com/ruby/rdoc"}
382
+ # }
383
+
384
+ attr_accessor :footer_content
385
+
386
+ def initialize(loaded_options = nil) # :nodoc:
387
+ init_ivars
388
+ override loaded_options if loaded_options
389
+ end
390
+
391
+ DEFAULT_EXCLUDE = %w[
392
+ ~\z \.orig\z \.rej\z \.bak\z
393
+ \.gemspec\z
394
+ ]
395
+
396
+ def init_ivars # :nodoc:
397
+ @autolink_excluded_words = []
398
+ @dry_run = false
399
+ @embed_mixins = false
400
+ @exclude = []
401
+ @files = nil
402
+ @force_output = false
403
+ @force_update = true
404
+ @generator_name = "aliki"
405
+ @generators = RDoc::RDoc::GENERATORS
406
+ @generator_options = []
407
+ @hyperlink_all = false
408
+ @line_numbers = false
409
+ @locale = nil
410
+ @locale_name = nil
411
+ @locale_dir = 'locale'
412
+ @main_page = nil
413
+ @markup = 'rdoc'
414
+ @coverage_report = false
415
+ @op_dir = nil
416
+ @page_dir = nil
417
+ @pipe = false
418
+ @output_decoration = true
419
+ @rdoc_include = []
420
+ @root = Pathname(Dir.pwd)
421
+ @server_port = false
422
+ @show_hash = false
423
+ @static_path = []
424
+ @tab_width = 8
425
+ @template = nil
426
+ @template_dir = nil
427
+ @template_stylesheets = []
428
+ @title = nil
429
+ @update_output_dir = true
430
+ @verbosity = 1
431
+ @visibility = :protected
432
+ @warn_missing_rdoc_ref = true
433
+ @webcvs = nil
434
+ @write_options = false
435
+ @encoding = Encoding::UTF_8
436
+ @charset = @encoding.name
437
+ @skip_tests = true
438
+ @apply_default_exclude = true
439
+ @class_module_path_prefix = nil
440
+ @file_path_prefix = nil
441
+ @canonical_root = nil
442
+ @footer_content = nil
443
+ end
444
+
445
+ def init_with(map) # :nodoc:
446
+ init_ivars
447
+
448
+ encoding = map['encoding']
449
+ @encoding = encoding ? Encoding.find(encoding) : encoding
450
+
451
+ @charset = map['charset']
452
+ @embed_mixins = map['embed_mixins']
453
+ @exclude = map['exclude']
454
+ @generator_name = map['generator_name']
455
+ @hyperlink_all = map['hyperlink_all']
456
+ @line_numbers = map['line_numbers']
457
+ @locale_name = map['locale_name']
458
+ @locale_dir = map['locale_dir']
459
+ @main_page = map['main_page']
460
+ @markup = map['markup']
461
+ @op_dir = map['op_dir']
462
+ @show_hash = map['show_hash']
463
+ @tab_width = map['tab_width']
464
+ @template_dir = map['template_dir']
465
+ @title = map['title']
466
+ @visibility = map['visibility']
467
+ @webcvs = map['webcvs']
468
+
469
+ @apply_default_exclude = map['apply_default_exclude']
470
+ @autolink_excluded_words = map['autolink_excluded_words']
471
+ @footer_content = map['footer_content']
472
+
473
+ @rdoc_include = sanitize_path map['rdoc_include']
474
+ @static_path = sanitize_path map['static_path']
475
+ end
476
+
477
+ def yaml_initialize(tag, map) # :nodoc:
478
+ init_with map
479
+ end
480
+
481
+ def override(map) # :nodoc:
482
+ if map.has_key?('encoding')
483
+ encoding = map['encoding']
484
+ @encoding = encoding ? Encoding.find(encoding) : encoding
485
+ end
486
+
487
+ @charset = map['charset'] if map.has_key?('charset')
488
+ @embed_mixins = map['embed_mixins'] if map.has_key?('embed_mixins')
489
+ @exclude = map['exclude'] if map.has_key?('exclude')
490
+ @generator_name = map['generator_name'] if map.has_key?('generator_name')
491
+ @hyperlink_all = map['hyperlink_all'] if map.has_key?('hyperlink_all')
492
+ @line_numbers = map['line_numbers'] if map.has_key?('line_numbers')
493
+ @locale_name = map['locale_name'] if map.has_key?('locale_name')
494
+ @locale_dir = map['locale_dir'] if map.has_key?('locale_dir')
495
+ @main_page = map['main_page'] if map.has_key?('main_page')
496
+ @markup = map['markup'] if map.has_key?('markup')
497
+ @op_dir = map['op_dir'] if map.has_key?('op_dir')
498
+ @page_dir = map['page_dir'] if map.has_key?('page_dir')
499
+ @show_hash = map['show_hash'] if map.has_key?('show_hash')
500
+ @tab_width = map['tab_width'] if map.has_key?('tab_width')
501
+ @template_dir = map['template_dir'] if map.has_key?('template_dir')
502
+ @title = map['title'] if map.has_key?('title')
503
+ @visibility = map['visibility'] if map.has_key?('visibility')
504
+ @webcvs = map['webcvs'] if map.has_key?('webcvs')
505
+ @autolink_excluded_words = map['autolink_excluded_words'] if map.has_key?('autolink_excluded_words')
506
+ @apply_default_exclude = map['apply_default_exclude'] if map.has_key?('apply_default_exclude')
507
+ @canonical_root = map['canonical_root'] if map.has_key?('canonical_root')
508
+ @footer_content = map['footer_content'] if map.has_key?('footer_content')
509
+
510
+ @warn_missing_rdoc_ref = map['warn_missing_rdoc_ref'] if map.has_key?('warn_missing_rdoc_ref')
511
+
512
+ if map.has_key?('rdoc_include')
513
+ @rdoc_include = sanitize_path map['rdoc_include']
514
+ end
515
+ if map.has_key?('static_path')
516
+ @static_path = sanitize_path map['static_path']
517
+ end
518
+ end
519
+
520
+ def ==(other) # :nodoc:
521
+ self.class === other and
522
+ @encoding == other.encoding and
523
+ @embed_mixins == other.embed_mixins and
524
+ @generator_name == other.generator_name and
525
+ @hyperlink_all == other.hyperlink_all and
526
+ @line_numbers == other.line_numbers and
527
+ @locale == other.locale and
528
+ @locale_dir == other.locale_dir and
529
+ @main_page == other.main_page and
530
+ @markup == other.markup and
531
+ @op_dir == other.op_dir and
532
+ @rdoc_include == other.rdoc_include and
533
+ @show_hash == other.show_hash and
534
+ @static_path == other.static_path and
535
+ @tab_width == other.tab_width and
536
+ @template == other.template and
537
+ @title == other.title and
538
+ @visibility == other.visibility and
539
+ @webcvs == other.webcvs and
540
+ @apply_default_exclude == other.apply_default_exclude and
541
+ @autolink_excluded_words == other.autolink_excluded_words
542
+ end
543
+
544
+ ##
545
+ # Check that the files on the command line exist
546
+
547
+ def check_files
548
+ @files.delete_if do |file|
549
+ if File.exist? file then
550
+ if File.readable? file then
551
+ false
552
+ else
553
+ warn "file '#{file}' not readable"
554
+
555
+ true
556
+ end
557
+ else
558
+ warn "file '#{file}' not found"
559
+
560
+ true
561
+ end
562
+ end
563
+ end
564
+
565
+ ##
566
+ # Ensure only one generator is loaded
567
+
568
+ def check_generator
569
+ if @generator then
570
+ raise OptionParser::InvalidOption,
571
+ "generator already set to #{@generator_name}"
572
+ end
573
+ end
574
+
575
+ ##
576
+ # Set the title, but only if not already set. Used to set the title
577
+ # from a source file, so that a title set from the command line
578
+ # will have the priority.
579
+
580
+ def default_title=(string)
581
+ @title ||= string
582
+ end
583
+
584
+ ##
585
+ # For dumping YAML
586
+
587
+ def to_yaml(*options) # :nodoc:
588
+ encoding = @encoding ? @encoding.name : nil
589
+
590
+ yaml = {}
591
+ yaml['encoding'] = encoding
592
+ yaml['static_path'] = sanitize_path(@static_path)
593
+ yaml['rdoc_include'] = sanitize_path(@rdoc_include)
594
+ yaml['page_dir'] = (sanitize_path([@page_dir]).first if @page_dir)
595
+
596
+ ivars = instance_variables.map { |ivar| ivar.to_s[1..-1] }
597
+ ivars -= SPECIAL
598
+
599
+ ivars.sort.each do |ivar|
600
+ yaml[ivar] = instance_variable_get("@#{ivar}")
601
+ end
602
+
603
+ if yaml.respond_to?(:to_yaml)
604
+ yaml.to_yaml
605
+ else
606
+ RDoc.yaml_serializer.dump(yaml)
607
+ end
608
+ end
609
+
610
+ ##
611
+ # Create a regexp for #exclude
612
+
613
+ def exclude
614
+ if @exclude.nil? or Regexp === @exclude then
615
+ # done, #finish is being re-run
616
+ @exclude
617
+ elsif !@apply_default_exclude and @exclude.empty? then
618
+ nil
619
+ else
620
+ exclude = @exclude
621
+ exclude |= DEFAULT_EXCLUDE if @apply_default_exclude
622
+ Regexp.new(exclude.join("|"))
623
+ end
624
+ end
625
+
626
+ ##
627
+ # Completes any unfinished option setup business such as filtering for
628
+ # existent files, creating a regexp for #exclude and setting a default
629
+ # #template.
630
+
631
+ def finish
632
+ if @write_options then
633
+ write_options
634
+ exit
635
+ end
636
+
637
+ @op_dir ||= 'doc'
638
+
639
+ root = @root.to_s
640
+ if @rdoc_include.empty? || !@rdoc_include.include?(root)
641
+ @rdoc_include << root
642
+ end
643
+
644
+ @exclude = self.exclude
645
+
646
+ finish_page_dir
647
+
648
+ check_files
649
+
650
+ # If no template was specified, use the default template for the output
651
+ # formatter
652
+
653
+ unless @template then
654
+ @template = @generator_name
655
+ @template_dir = template_dir_for @template
656
+ end
657
+
658
+ if @locale_name
659
+ @locale = RDoc::I18n::Locale[@locale_name]
660
+ @locale.load(@locale_dir)
661
+ else
662
+ @locale = nil
663
+ end
664
+
665
+ self
666
+ end
667
+
668
+ ##
669
+ # Fixes the page_dir to be relative to the root_dir and adds the page_dir to
670
+ # the files list.
671
+
672
+ def finish_page_dir
673
+ return unless @page_dir
674
+
675
+ @files << @page_dir
676
+
677
+ page_dir = Pathname(@page_dir)
678
+ begin
679
+ page_dir = page_dir.expand_path.relative_path_from @root
680
+ rescue ArgumentError
681
+ # On Windows, sometimes crosses different drive letters.
682
+ page_dir = page_dir.expand_path
683
+ end
684
+
685
+ @page_dir = page_dir
686
+ end
687
+
688
+ ##
689
+ # Returns a properly-space list of generators and their descriptions.
690
+
691
+ def generator_descriptions
692
+ lengths = []
693
+
694
+ generators = RDoc::RDoc::GENERATORS.map do |name, generator|
695
+ lengths << name.length
696
+
697
+ description = generator::DESCRIPTION if
698
+ generator.const_defined? :DESCRIPTION
699
+
700
+ [name, description]
701
+ end
702
+
703
+ longest = lengths.max
704
+
705
+ generators.sort.map do |name, description|
706
+ if description then
707
+ " %-*s - %s" % [longest, name, description]
708
+ else
709
+ " #{name}"
710
+ end
711
+ end.join "\n"
712
+ end
713
+
714
+ ##
715
+ # Parses command line options.
716
+
717
+ def parse(argv)
718
+ ignore_invalid = true
719
+
720
+ argv.insert(0, *ENV['RDOCOPT'].split) if ENV['RDOCOPT']
721
+
722
+ opts = OptionParser.new do |opt|
723
+ @option_parser = opt
724
+ opt.program_name = File.basename $0
725
+ opt.version = RDoc::VERSION
726
+ opt.release = nil
727
+ opt.summary_indent = ' ' * 4
728
+ opt.banner = <<-EOF
729
+ Usage: #{opt.program_name} [options] [names...]
730
+
731
+ Files are parsed, and the information they contain collected, before any
732
+ output is produced. This allows cross references between all files to be
733
+ resolved. If a name is a directory, it is traversed. If no names are
734
+ specified, all Ruby files in the current directory (and subdirectories) are
735
+ processed.
736
+
737
+ How RDoc generates output depends on the output formatter being used, and on
738
+ the options you give.
739
+
740
+ Options can be specified via the RDOCOPT environment variable, which
741
+ functions similar to the RUBYOPT environment variable for ruby.
742
+
743
+ $ export RDOCOPT="--show-hash"
744
+
745
+ will make rdoc show hashes in method links by default. Command-line options
746
+ always will override those in RDOCOPT.
747
+
748
+ Available formatters:
749
+
750
+ #{generator_descriptions}
751
+
752
+ RDoc understands the following file formats:
753
+
754
+ EOF
755
+
756
+ parsers = Hash.new { |h, parser| h[parser] = [] }
757
+
758
+ RDoc::Parser.parsers.each do |regexp, parser|
759
+ parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source
760
+ end
761
+
762
+ parsers.sort.each do |parser, regexp|
763
+ opt.banner += " - #{parser}: #{regexp.join ', '}\n"
764
+ end
765
+ opt.banner += " - TomDoc: Only in ruby files\n"
766
+
767
+ opt.accept Template do |template|
768
+ template_dir = template_dir_for template
769
+
770
+ unless template_dir then
771
+ $stderr.puts "could not find template #{template}"
772
+ nil
773
+ else
774
+ [template, template_dir]
775
+ end
776
+ end
777
+
778
+ opt.accept Directory do |directory|
779
+ directory = File.expand_path directory
780
+
781
+ raise OptionParser::InvalidArgument unless File.directory? directory
782
+
783
+ directory
784
+ end
785
+
786
+ opt.accept Path do |path|
787
+ path = File.expand_path path
788
+
789
+ raise OptionParser::InvalidArgument unless File.exist? path
790
+
791
+ path
792
+ end
793
+
794
+ opt.accept PathArray do |paths,|
795
+ paths = if paths then
796
+ paths.split(',').map { |d| d unless d.empty? }
797
+ end
798
+
799
+ paths.map do |path|
800
+ path = File.expand_path path
801
+
802
+ raise OptionParser::InvalidArgument unless File.exist? path
803
+
804
+ path
805
+ end
806
+ end
807
+
808
+ opt.separator nil
809
+ opt.separator "Parsing options:"
810
+ opt.separator nil
811
+
812
+ opt.on("--encoding=ENCODING", "-e", Encoding.list.map { |e| e.name },
813
+ "Specifies the output encoding. All files",
814
+ "read will be converted to this encoding.",
815
+ "The default encoding is UTF-8.",
816
+ "--encoding is preferred over --charset") do |value|
817
+ @encoding = Encoding.find value
818
+ @charset = @encoding.name # may not be valid value
819
+ end
820
+
821
+ opt.separator nil
822
+
823
+ opt.on("--locale=NAME",
824
+ "Specifies the output locale.") do |value|
825
+ @locale_name = value
826
+ end
827
+
828
+ opt.on("--locale-data-dir=DIR",
829
+ "Specifies the directory where locale data live.") do |value|
830
+ @locale_dir = value
831
+ end
832
+
833
+ opt.separator nil
834
+
835
+ opt.on("--all", "-a",
836
+ "Synonym for --visibility=private.") do |value|
837
+ @visibility = :private
838
+ end
839
+
840
+ opt.separator nil
841
+
842
+ opt.on("--exclude=PATTERN", "-x", Regexp,
843
+ "Do not process files or directories",
844
+ "matching PATTERN.") do |value|
845
+ @exclude << value
846
+ end
847
+
848
+ opt.on("--[no-]apply-default-exclude",
849
+ "Use default PATTERN to exclude.") do |value|
850
+ @apply_default_exclude = value
851
+ end
852
+
853
+ opt.separator nil
854
+
855
+ opt.on("--no-skipping-tests", nil,
856
+ "Don't skip generating documentation for test and spec files") do |value|
857
+ @skip_tests = false
858
+ end
859
+
860
+ opt.separator nil
861
+
862
+ opt.on("--extension=NEW=OLD", "-E",
863
+ "Treat files ending with .new as if they",
864
+ "ended with .old. Using '-E cgi=rb' will",
865
+ "cause xxx.cgi to be parsed as a Ruby file.") do |value|
866
+ new, old = value.split(/=/, 2)
867
+
868
+ unless new and old then
869
+ raise OptionParser::InvalidArgument, "Invalid parameter to '-E'"
870
+ end
871
+
872
+ unless RDoc::Parser.alias_extension old, new then
873
+ raise OptionParser::InvalidArgument, "Unknown extension .#{old} to -E"
874
+ end
875
+ end
876
+
877
+ opt.separator nil
878
+
879
+ opt.on("--[no-]force-update", "-U",
880
+ "Forces rdoc to scan all sources even if",
881
+ "no files are newer than the flag file.") do |value|
882
+ @force_update = value
883
+ end
884
+
885
+ opt.separator nil
886
+
887
+ opt.on("--pipe", "-p",
888
+ "Convert RDoc on stdin to HTML") do
889
+ @pipe = true
890
+ end
891
+
892
+ opt.separator nil
893
+
894
+ opt.on("--tab-width=WIDTH", "-w", Integer,
895
+ "Set the width of tab characters.") do |value|
896
+ raise OptionParser::InvalidArgument,
897
+ "#{value} is an invalid tab width" if value <= 0
898
+ @tab_width = value
899
+ end
900
+
901
+ opt.separator nil
902
+
903
+ opt.on("--visibility=VISIBILITY", RDoc::VISIBILITIES + [:nodoc],
904
+ "Minimum visibility to document a method.",
905
+ "One of 'public', 'protected' (the default),",
906
+ "'private' or 'nodoc' (show everything)") do |value|
907
+ @visibility = value
908
+ end
909
+
910
+ opt.separator nil
911
+
912
+ opt.on("--[no-]embed-mixins",
913
+ "Embed mixin methods, attributes, and constants",
914
+ "into class documentation. (default false)") do |value|
915
+ @embed_mixins = value
916
+ end
917
+
918
+ opt.separator nil
919
+
920
+ markup_formats = RDoc::Text::MARKUP_FORMAT.keys.sort
921
+
922
+ opt.on("--markup=MARKUP", markup_formats,
923
+ "The markup format for the named files.",
924
+ "The default is rdoc. Valid values are:",
925
+ markup_formats.join(', ')) do |value|
926
+ @markup = value
927
+ end
928
+
929
+ opt.separator nil
930
+
931
+ opt.on("--root=ROOT", Directory,
932
+ "Root of the source tree documentation",
933
+ "will be generated for. Set this when",
934
+ "building documentation outside the",
935
+ "source directory. Default is the",
936
+ "current directory.") do |root|
937
+ @root = Pathname(root)
938
+ end
939
+
940
+ opt.separator nil
941
+
942
+ opt.on("--page-dir=DIR", Directory,
943
+ "Directory where guides, your FAQ or",
944
+ "other pages not associated with a class",
945
+ "live. Set this when you don't store",
946
+ "such files at your project root.",
947
+ "NOTE: Do not use the same file name in",
948
+ "the page dir and the root of your project") do |page_dir|
949
+ @page_dir = page_dir
950
+ end
951
+
952
+ opt.separator nil
953
+ opt.separator "Common generator options:"
954
+ opt.separator nil
955
+
956
+ opt.on("--force-output", "-O",
957
+ "Forces rdoc to write the output files,",
958
+ "even if the output directory exists",
959
+ "and does not seem to have been created",
960
+ "by rdoc.") do |value|
961
+ @force_output = value
962
+ end
963
+
964
+ opt.separator nil
965
+
966
+ generator_text = @generators.keys.map { |name| " #{name}" }.sort
967
+
968
+ opt.on("-f", "--fmt=FORMAT", "--format=FORMAT", @generators.keys,
969
+ "Set the output formatter. One of:", *generator_text) do |value|
970
+ check_generator
971
+
972
+ @generator_name = value.downcase
973
+ setup_generator
974
+ end
975
+
976
+ opt.separator nil
977
+
978
+ opt.on("--include=DIRECTORIES", "-i", PathArray,
979
+ "Set (or add to) the list of directories to",
980
+ "be searched when satisfying :include:",
981
+ "requests. Can be used more than once.") do |value|
982
+ @rdoc_include.concat value.map { |dir| dir.strip }
983
+ end
984
+
985
+ opt.separator nil
986
+
987
+ opt.on("--[no-]coverage-report=[LEVEL]", "--[no-]dcov", "-C", Integer,
988
+ "Prints a report on undocumented items.",
989
+ "Does not generate files.") do |value|
990
+ value = 0 if value.nil? # Integer converts -C to nil
991
+
992
+ @coverage_report = value
993
+ @force_update = true if value
994
+ end
995
+
996
+ opt.separator nil
997
+
998
+ opt.on("--output=DIR", "--op", "-o",
999
+ "Set the output directory.") do |value|
1000
+ @op_dir = value
1001
+ end
1002
+
1003
+ opt.separator nil
1004
+ opt.separator 'HTML generator options:'
1005
+ opt.separator nil
1006
+
1007
+ opt.on("--charset=CHARSET", "-c",
1008
+ "Specifies the output HTML character-set.",
1009
+ "Use --encoding instead of --charset if",
1010
+ "available.") do |value|
1011
+ @charset = value
1012
+ end
1013
+
1014
+ opt.separator nil
1015
+
1016
+ opt.on("--autolink-excluded-words=WORDS", Array,
1017
+ "Words to be ignored in autolink cross-references") do |value|
1018
+ @autolink_excluded_words.concat value
1019
+ end
1020
+
1021
+ opt.separator nil
1022
+
1023
+ opt.on("--hyperlink-all", "-A",
1024
+ "Generate hyperlinks for all words that",
1025
+ "correspond to known methods, even if they",
1026
+ "do not start with '#' or '::' (legacy",
1027
+ "behavior).") do |value|
1028
+ @hyperlink_all = value
1029
+ end
1030
+
1031
+ opt.separator nil
1032
+
1033
+ opt.on("--main=NAME", "-m",
1034
+ "NAME will be the initial page displayed.") do |value|
1035
+ @main_page = value
1036
+ end
1037
+
1038
+ opt.separator nil
1039
+
1040
+ opt.on("--[no-]line-numbers", "-N",
1041
+ "Include line numbers in the source code.",
1042
+ "By default, only the number of the first",
1043
+ "line is displayed, in a leading comment.") do |value|
1044
+ @line_numbers = value
1045
+ end
1046
+
1047
+ opt.separator nil
1048
+
1049
+ opt.on("--show-hash", "-H",
1050
+ "A name of the form #name in a comment is a",
1051
+ "possible hyperlink to an instance method",
1052
+ "name. When displayed, the '#' is removed",
1053
+ "unless this option is specified.") do |value|
1054
+ @show_hash = value
1055
+ end
1056
+
1057
+ opt.separator nil
1058
+
1059
+ opt.on("--template=NAME", "-T", Template,
1060
+ "Set the template used when generating",
1061
+ "output. The default depends on the",
1062
+ "formatter used.") do |(template, template_dir)|
1063
+ @template = template
1064
+ @template_dir = template_dir
1065
+ end
1066
+
1067
+ opt.separator nil
1068
+
1069
+ opt.on("--template-stylesheets=FILES", PathArray,
1070
+ "Set (or add to) the list of files to",
1071
+ "include with the html template.") do |value|
1072
+ @template_stylesheets.concat value
1073
+ end
1074
+
1075
+ opt.separator nil
1076
+
1077
+ opt.on("--title=TITLE", "-t",
1078
+ "Set TITLE as the title for HTML output.") do |value|
1079
+ @title = value
1080
+ end
1081
+
1082
+ opt.separator nil
1083
+
1084
+ opt.on("--copy-files=PATH", Path,
1085
+ "Specify a file or directory to copy static",
1086
+ "files from.",
1087
+ "If a file is given it will be copied into",
1088
+ "the output dir. If a directory is given the",
1089
+ "entire directory will be copied.",
1090
+ "You can use this multiple times") do |value|
1091
+ @static_path << value
1092
+ end
1093
+
1094
+ opt.separator nil
1095
+
1096
+ opt.on("--webcvs=URL", "-W",
1097
+ "Specify a URL for linking to a web frontend",
1098
+ "to CVS. If the URL contains a '\%s', the",
1099
+ "name of the current file will be",
1100
+ "substituted; if the URL doesn't contain a",
1101
+ "'\%s', the filename will be appended to it.") do |value|
1102
+ @webcvs = value
1103
+ end
1104
+
1105
+ opt.separator nil
1106
+ opt.separator "ri generator options:"
1107
+ opt.separator nil
1108
+
1109
+ opt.on("--ri", "-r",
1110
+ "Generate output for use by `ri`. The files",
1111
+ "are stored in the '.rdoc' directory under",
1112
+ "your home directory unless overridden by a",
1113
+ "subsequent --op parameter, so no special",
1114
+ "privileges are needed.") do |value|
1115
+ check_generator
1116
+
1117
+ @generator_name = "ri"
1118
+ @op_dir ||= RDoc::RI::Paths::HOMEDIR
1119
+ setup_generator
1120
+ end
1121
+
1122
+ opt.separator nil
1123
+
1124
+ opt.on("--ri-site", "-R",
1125
+ "Generate output for use by `ri`. The files",
1126
+ "are stored in a site-wide directory,",
1127
+ "making them accessible to others, so",
1128
+ "special privileges are needed.") do |value|
1129
+ check_generator
1130
+
1131
+ @generator_name = "ri"
1132
+ @op_dir = RDoc::RI::Paths.site_dir
1133
+ setup_generator
1134
+ end
1135
+
1136
+ opt.separator nil
1137
+ opt.separator "Generic options:"
1138
+ opt.separator nil
1139
+
1140
+ opt.on("--server[=PORT]", Integer,
1141
+ "Start a web server to preview",
1142
+ "documentation with live reload.",
1143
+ "Defaults to port 4000.") do |port|
1144
+ @server_port = port || 4000
1145
+ end
1146
+
1147
+ opt.separator nil
1148
+
1149
+ opt.on("--write-options",
1150
+ "Write .rdoc_options to the current",
1151
+ "directory with the given options. Not all",
1152
+ "options will be used. See RDoc::Options",
1153
+ "for details.") do |value|
1154
+ @write_options = true
1155
+ end
1156
+
1157
+ opt.separator nil
1158
+
1159
+ opt.on("--[no-]dry-run",
1160
+ "Don't write any files") do |value|
1161
+ @dry_run = value
1162
+ end
1163
+
1164
+ opt.separator nil
1165
+
1166
+ opt.on("-D", "--[no-]debug",
1167
+ "Displays lots on internal stuff.") do |value|
1168
+ $DEBUG_RDOC = value
1169
+ end
1170
+
1171
+ opt.separator nil
1172
+
1173
+ opt.on("--warn-missing-rdoc-ref",
1174
+ "Warn if rdoc-ref links can't be resolved") do |value|
1175
+ @warn_missing_rdoc_ref = value
1176
+ end
1177
+
1178
+ opt.separator nil
1179
+
1180
+ opt.on("--[no-]ignore-invalid",
1181
+ "Ignore invalid options and continue",
1182
+ "(default true).") do |value|
1183
+ ignore_invalid = value
1184
+ end
1185
+
1186
+ opt.separator nil
1187
+
1188
+ opt.on("--quiet", "-q",
1189
+ "Don't show progress as we parse.") do |value|
1190
+ @verbosity = 0
1191
+ end
1192
+
1193
+ opt.separator nil
1194
+
1195
+ opt.on("--verbose", "-V",
1196
+ "Display extra progress as RDoc parses") do |value|
1197
+ @verbosity = 2
1198
+ end
1199
+
1200
+ opt.separator nil
1201
+
1202
+ opt.on("--version", "-v", "print the version") do
1203
+ puts opt.version
1204
+ exit
1205
+ end
1206
+
1207
+ opt.separator nil
1208
+
1209
+ opt.on("--help", "-h", "Display this help") do
1210
+ RDoc::RDoc::GENERATORS.each_key do |generator|
1211
+ setup_generator generator
1212
+ end
1213
+
1214
+ puts opt.help
1215
+ exit
1216
+ end
1217
+
1218
+ opt.separator nil
1219
+ end
1220
+
1221
+ invalid = []
1222
+
1223
+ begin
1224
+ opts.parse! argv
1225
+ rescue OptionParser::ParseError => e
1226
+ if %w[--format --ri -r --ri-site -R].include? e.args.first then
1227
+ raise
1228
+ else
1229
+ invalid << e.args.join(' ')
1230
+ end
1231
+
1232
+ retry
1233
+ end
1234
+
1235
+ setup_generator unless @generator
1236
+
1237
+ if @pipe and not argv.empty? then
1238
+ @pipe = false
1239
+ invalid << '-p (with files)'
1240
+ end
1241
+
1242
+ unless invalid.empty? then
1243
+ invalid = "invalid options: #{invalid.join ', '}"
1244
+
1245
+ if ignore_invalid then
1246
+ unless quiet then
1247
+ $stderr.puts invalid
1248
+ $stderr.puts '(invalid options are ignored)'
1249
+ end
1250
+ else
1251
+ unless quiet then
1252
+ $stderr.puts opts
1253
+ end
1254
+ $stderr.puts invalid
1255
+ exit 1
1256
+ end
1257
+ end
1258
+
1259
+ @files = argv.dup
1260
+
1261
+ self
1262
+ end
1263
+
1264
+ ##
1265
+ # Don't display progress as we process the files
1266
+
1267
+ def quiet
1268
+ @verbosity.zero?
1269
+ end
1270
+
1271
+ ##
1272
+ # Set quietness to +bool+
1273
+
1274
+ def quiet=(bool)
1275
+ @verbosity = bool ? 0 : 1
1276
+ end
1277
+
1278
+ ##
1279
+ # Removes directories from +path+ that are outside the current directory
1280
+
1281
+ def sanitize_path(path)
1282
+ require 'pathname'
1283
+ dot = Pathname.new('.').expand_path
1284
+
1285
+ path.reject do |item|
1286
+ path = Pathname.new(item).expand_path
1287
+ is_reject = nil
1288
+ relative = nil
1289
+ begin
1290
+ relative = path.relative_path_from(dot).to_s
1291
+ rescue ArgumentError
1292
+ # On Windows, sometimes crosses different drive letters.
1293
+ is_reject = true
1294
+ else
1295
+ is_reject = relative.start_with? '..'
1296
+ end
1297
+ is_reject
1298
+ end
1299
+ end
1300
+
1301
+ ##
1302
+ # Set up an output generator for the named +generator_name+.
1303
+ #
1304
+ # If the found generator responds to :setup_options it will be called with
1305
+ # the options instance. This allows generators to add custom options or set
1306
+ # default options.
1307
+
1308
+ def setup_generator(generator_name = @generator_name)
1309
+ @generator = @generators[generator_name]
1310
+
1311
+ unless @generator then
1312
+ raise OptionParser::InvalidArgument,
1313
+ "Invalid output formatter #{generator_name}"
1314
+ end
1315
+
1316
+ return if @generator_options.include? @generator
1317
+
1318
+ @generator_name = generator_name
1319
+ @generator_options << @generator
1320
+
1321
+ if @generator.respond_to? :setup_options then
1322
+ @option_parser ||= OptionParser.new
1323
+ @generator.setup_options self
1324
+ end
1325
+ end
1326
+
1327
+ ##
1328
+ # Finds the template dir for +template+
1329
+
1330
+ def template_dir_for(template)
1331
+ template_path = File.join 'rdoc', 'generator', 'template', template
1332
+
1333
+ $LOAD_PATH.map do |path|
1334
+ File.join File.expand_path(path), template_path
1335
+ end.find do |dir|
1336
+ File.directory? dir
1337
+ end
1338
+ end
1339
+
1340
+ # Sets the minimum visibility of a documented method.
1341
+ #
1342
+ # Accepts +:public+, +:protected+, +:private+, +:nodoc+, or +:all+.
1343
+ #
1344
+ # When +:all+ is passed, visibility is set to +:private+, similarly to
1345
+ # RDOCOPT="--all", see #visibility for more information.
1346
+
1347
+ def visibility=(visibility)
1348
+ case visibility
1349
+ when :all
1350
+ @visibility = :private
1351
+ else
1352
+ @visibility = visibility
1353
+ end
1354
+ end
1355
+
1356
+ ##
1357
+ # Displays a warning using Kernel#warn if we're being verbose
1358
+
1359
+ def warn(message)
1360
+ super message if @verbosity > 1
1361
+ end
1362
+
1363
+ ##
1364
+ # Writes the YAML file .rdoc_options to the current directory containing the
1365
+ # parsed options.
1366
+
1367
+ def write_options
1368
+ RDoc.load_yaml
1369
+
1370
+ File.open '.rdoc_options', 'w' do |io|
1371
+ io.set_encoding Encoding::UTF_8
1372
+
1373
+ io.print to_yaml
1374
+ end
1375
+ end
1376
+
1377
+ ##
1378
+ # Loads options from .rdoc_options if the file exists, otherwise creates a
1379
+ # new RDoc::Options instance.
1380
+
1381
+ def self.load_options
1382
+ options_file = File.expand_path '.rdoc_options'
1383
+ return RDoc::Options.new unless File.exist? options_file
1384
+
1385
+ RDoc.load_yaml
1386
+
1387
+ content = File.read('.rdoc_options')
1388
+
1389
+ if defined?(Psych)
1390
+ begin
1391
+ options = Psych.safe_load content, permitted_classes: [RDoc::Options, Symbol]
1392
+ rescue Psych::SyntaxError
1393
+ raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
1394
+ end
1395
+ else
1396
+ options = RDoc.yaml_serializer.load(content)
1397
+ end
1398
+
1399
+ return RDoc::Options.new unless options # Allow empty file.
1400
+
1401
+ raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
1402
+ RDoc::Options === options or Hash === options
1403
+
1404
+ if Hash === options
1405
+ # Override the default values with the contents of YAML file.
1406
+ options = RDoc::Options.new options
1407
+ end
1408
+
1409
+ options
1410
+ end
1411
+
1412
+ end