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,261 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # Subclass of the RDoc::Markup::ToHtml class that supports looking up method
4
+ # names, classes, etc to create links. RDoc::CrossReference is used to
5
+ # generate those links based on the current context.
6
+
7
+ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
8
+
9
+ # :stopdoc:
10
+ ALL_CROSSREF_REGEXP = RDoc::CrossReference::ALL_CROSSREF_REGEXP
11
+ CROSSREF_REGEXP = RDoc::CrossReference::CROSSREF_REGEXP
12
+ # :startdoc:
13
+
14
+ ##
15
+ # RDoc::CodeObject for generating references
16
+
17
+ attr_accessor :context
18
+
19
+ ##
20
+ # Should we show '#' characters on method references?
21
+
22
+ attr_accessor :show_hash
23
+
24
+ ##
25
+ # Creates a new crossref resolver that generates links relative to +context+
26
+ # which lives at +from_path+ in the generated files. '#' characters on
27
+ # references are removed unless +show_hash+ is true. Only method names
28
+ # preceded by '#' or '::' are linked, unless +hyperlink_all+ is true.
29
+
30
+ def initialize(from_path, context, pipe: false, output_decoration: true,
31
+ hyperlink_all: false, show_hash: false,
32
+ autolink_excluded_words: [], warn_missing_rdoc_ref: true)
33
+ raise ArgumentError, 'from_path cannot be nil' if from_path.nil?
34
+
35
+ super(pipe: pipe, output_decoration: output_decoration)
36
+
37
+ @context = context
38
+ @from_path = from_path
39
+ @hyperlink_all = hyperlink_all
40
+ @show_hash = show_hash
41
+ @autolink_excluded_words = autolink_excluded_words
42
+ @warn_missing_rdoc_ref = warn_missing_rdoc_ref
43
+
44
+ @cross_reference = RDoc::CrossReference.new @context
45
+ end
46
+
47
+ # :nodoc:
48
+ def init_link_notation_regexp_handlings
49
+ add_regexp_handling_RDOCLINK
50
+
51
+ # The crossref must be linked before tidylink because Klass.method[:sym]
52
+ # will be processed as a tidylink first and will be broken.
53
+ crossref_re = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
54
+ @markup.add_regexp_handling crossref_re, :CROSSREF
55
+ end
56
+
57
+ ##
58
+ # Creates a link to the reference +name+ if the name exists. If +text+ is
59
+ # given it is used as the link text, otherwise +name+ is used.
60
+ # Returns +nil+ if the link target could not be resolved.
61
+
62
+ def cross_reference(name, text = nil, code = true, rdoc_ref: false)
63
+ # Strip '#' for link display text (e.g. #method shows as "method" in links)
64
+ display = !@show_hash && name.start_with?('#') ? name[1..] : name
65
+
66
+ if !display.end_with?('+@', '-@') && match = display.match(/(.*[^#:])?@(.*)/)
67
+ context_name = match[1]
68
+ label = convert_string(RDoc::Text.decode_legacy_label(match[2]))
69
+ text ||= "#{label} at <code>#{convert_string(context_name)}</code>" if context_name
70
+ text ||= label
71
+ code = false
72
+ else
73
+ text ||= convert_string(display)
74
+ end
75
+
76
+ link(name, text, code, rdoc_ref: rdoc_ref)
77
+ end
78
+
79
+ ##
80
+ # We're invoked when any text matches the CROSSREF pattern. If we find the
81
+ # corresponding reference, generate a link. If the name we're looking for
82
+ # contains no punctuation, we look for it up the module/class chain. For
83
+ # example, ToHtml is found, even without the <tt>RDoc::Markup::</tt> prefix,
84
+ # because we look for it in module Markup first.
85
+
86
+ def handle_regexp_CROSSREF(name)
87
+ return convert_string(name) if in_tidylink_label?
88
+ return name if @autolink_excluded_words&.include?(name)
89
+
90
+ return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails
91
+
92
+ unless @hyperlink_all then
93
+ # This ensures that words entirely consisting of lowercase letters will
94
+ # not have cross-references generated (to suppress lots of erroneous
95
+ # cross-references to "new" in text, for instance)
96
+ return name if name =~ /\A[a-z]*\z/
97
+ end
98
+ cross_reference(name, rdoc_ref: false) || convert_string(name)
99
+ end
100
+
101
+ ##
102
+ # Handles <tt>rdoc-ref:</tt> scheme links and allows RDoc::Markup::ToHtml to
103
+ # handle other schemes.
104
+
105
+ def handle_regexp_HYPERLINK(url)
106
+ return convert_string(url) if in_tidylink_label?
107
+
108
+ case url
109
+ when /\Ardoc-ref:/
110
+ ref = $'
111
+ cross_reference(ref, rdoc_ref: true) || convert_string(ref)
112
+ else
113
+ super
114
+ end
115
+ end
116
+
117
+ ##
118
+ # +target+ is an rdoc-schemed link that will be converted into a hyperlink.
119
+ # For the rdoc-ref scheme the cross-reference will be looked up and the
120
+ # given name will be used.
121
+ #
122
+ # All other contents are handled by
123
+ # {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_regexp_RDOCLINK]
124
+
125
+ def handle_regexp_RDOCLINK(url)
126
+ case url
127
+ when /\Ardoc-ref:/
128
+ if in_tidylink_label?
129
+ convert_string(url)
130
+ else
131
+ ref = $'
132
+ cross_reference(ref, rdoc_ref: true) || convert_string(ref)
133
+ end
134
+ else
135
+ super
136
+ end
137
+ end
138
+
139
+ ##
140
+ # Generates links for <tt>rdoc-ref:</tt> scheme URLs and allows
141
+ # RDoc::Markup::ToHtml to handle other schemes.
142
+
143
+ def gen_url(url, text)
144
+ if url =~ /\Ardoc-ref:/
145
+ name = $'
146
+ cross_reference(name, text, name == text, rdoc_ref: true) || text
147
+ else
148
+ super
149
+ end
150
+ end
151
+
152
+ ##
153
+ # Creates an HTML link to +name+ with the given +html_string+.
154
+ # +html_string+ should be already escaped and may contain HTML tags.
155
+ # Returns the link HTML string, or +nil+ if the reference could not be resolved.
156
+
157
+ def link(name, html_string, code = true, rdoc_ref: false)
158
+ if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])?@/
159
+ name = $1
160
+ label = $'
161
+ end
162
+
163
+ ref = @cross_reference.resolve name if name
164
+
165
+ # Non-text source files (C, Ruby, etc.) don't get HTML pages generated,
166
+ # so don't auto-link to them. Explicit rdoc-ref: links are still allowed.
167
+ if !rdoc_ref && RDoc::TopLevel === ref && !ref.text?
168
+ return
169
+ end
170
+
171
+ if ref
172
+ path = ref.as_href(@from_path)
173
+
174
+ if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
175
+ html_string = "<code>#{html_string}</code>"
176
+ end
177
+ elsif name
178
+ if rdoc_ref && @warn_missing_rdoc_ref
179
+ puts "#{@from_path}: `rdoc-ref:#{name}` can't be resolved for `#{html_string}`"
180
+ end
181
+ return
182
+ else
183
+ # A bare label reference like @foo still produces a valid anchor link
184
+ return unless label
185
+ path = +""
186
+ end
187
+
188
+ if label
189
+ # Decode legacy labels (e.g., "What-27s+Here" -> "What's Here")
190
+ # then convert to GitHub-style anchor format
191
+ decoded_label = RDoc::Text.decode_legacy_label(label)
192
+ formatted_label = RDoc::Text.to_anchor(decoded_label)
193
+
194
+ # Case 1: Path already has an anchor (e.g., method link)
195
+ # Input: C1#method@label -> path="C1.html#method-i-m"
196
+ # Output: C1.html#method-i-m-label
197
+ if path =~ /#/
198
+ path << "-#{formatted_label}"
199
+
200
+ # Case 2: Label matches a section title
201
+ # Input: C1@Section -> path="C1.html", section "Section" exists
202
+ # Output: C1.html#section (uses section.aref for GitHub-style)
203
+ elsif (section = ref&.sections&.find { |s| decoded_label == s.title })
204
+ path << "##{section.aref}"
205
+
206
+ # Case 3: Ref has an aref (class/module context)
207
+ # Input: C1@heading -> path="C1.html", ref=C1 class
208
+ # Output: C1.html#class-c1-heading
209
+ elsif ref.respond_to?(:aref)
210
+ path << "##{ref.aref}-#{formatted_label}"
211
+
212
+ # Case 4: No context, just the label (e.g., TopLevel/file)
213
+ # Input: README@section -> path="README_md.html"
214
+ # Output: README_md.html#section
215
+ else
216
+ path << "##{formatted_label}"
217
+ end
218
+ end
219
+
220
+ "<a href=\"#{path}\">#{html_string}</a>"
221
+ end
222
+
223
+ def handle_TT(code)
224
+ emit_inline(tt_cross_reference(code) || "<code>#{convert_string(code)}</code>")
225
+ end
226
+
227
+ # Applies additional special handling on top of the one defined in ToHtml.
228
+ # When a tidy link is <tt>{Foo}[rdoc-ref:Foo]</tt>, the label part is surrounded by <tt><code></code></tt>.
229
+ # TODO: reconsider this workaround.
230
+ def apply_tidylink_label_special_handling(label, url)
231
+ if url == "rdoc-ref:#{label}" && cross_reference(label)&.include?('<code>')
232
+ "<code>#{convert_string(label)}</code>"
233
+ else
234
+ super
235
+ end
236
+ end
237
+
238
+ # Handles cross-reference and suppressed-crossref inside tt tag.
239
+ # Returns nil if code is not an existing cross-reference nor a suppressed-crossref.
240
+ def tt_cross_reference(code)
241
+ return if in_tidylink_label?
242
+
243
+ crossref_regexp = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
244
+ # REGEXP sometimes matches a string that starts with a backslash but is not a
245
+ # suppressed cross-reference (for example, `\+`), so the backslash-removed
246
+ # part needs to be checked against crossref_regexp.
247
+ match = crossref_regexp.match(code.delete_prefix('\\'))
248
+ return unless match && match.begin(1).zero?
249
+ return unless match.post_match.match?(/\A[[:punct:]\s]*\z/)
250
+
251
+ # cross_reference(file_page) may return a link without code tag.
252
+ # We need to check it because this method shouldn't return an html text without code tag.
253
+ if code.start_with?('\\')
254
+ # Remove leading backslash if crossref exists
255
+ "<code>#{convert_string(code[1..])}</code>" if cross_reference(code[1..])&.include?('<code>')
256
+ else
257
+ html = cross_reference(code)
258
+ html if html&.include?('<code>')
259
+ end
260
+ end
261
+ end
@@ -0,0 +1,287 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # Outputs RDoc markup as paragraphs with inline markup only.
4
+
5
+ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
6
+
7
+ ##
8
+ # After this many characters the input will be cut off.
9
+
10
+ attr_reader :character_limit
11
+
12
+ ##
13
+ # The number of characters seen so far.
14
+
15
+ attr_reader :characters # :nodoc:
16
+
17
+ ##
18
+ # The attribute bitmask
19
+
20
+ attr_reader :mask
21
+
22
+ ##
23
+ # After this many paragraphs the input will be cut off.
24
+
25
+ attr_reader :paragraph_limit
26
+
27
+ ##
28
+ # Count of paragraphs found
29
+
30
+ attr_reader :paragraphs
31
+
32
+ ##
33
+ # Creates a new ToHtmlSnippet formatter that will cut off the input on the
34
+ # next word boundary after the given number of +characters+ or +paragraphs+
35
+ # of text have been encountered.
36
+
37
+ def initialize(characters = 100, paragraphs = 3)
38
+ super()
39
+
40
+ @character_limit = characters
41
+ @paragraph_limit = paragraphs
42
+
43
+ @characters = 0
44
+ @mask = 0
45
+ @paragraphs = 0
46
+
47
+ @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
48
+ end
49
+
50
+ ##
51
+ # Adds +heading+ to the output as a paragraph
52
+
53
+ def accept_heading(heading)
54
+ @res << "<p>#{to_html heading.text}\n"
55
+
56
+ add_paragraph
57
+ end
58
+
59
+ ##
60
+ # Raw sections are untrusted and ignored
61
+
62
+ alias accept_raw ignore
63
+
64
+ ##
65
+ # Rules are ignored
66
+
67
+ alias accept_rule ignore
68
+
69
+ ##
70
+ # Adds +paragraph+ to the output
71
+
72
+ def accept_paragraph(paragraph)
73
+ para = @in_list_entry.last || "<p>"
74
+
75
+ text = paragraph.text @hard_break
76
+
77
+ @res << "#{para}#{to_html text}\n"
78
+
79
+ add_paragraph
80
+ end
81
+
82
+ ##
83
+ # Finishes consumption of +list_item+
84
+
85
+ def accept_list_item_end(list_item)
86
+ end
87
+
88
+ ##
89
+ # Prepares the visitor for consuming +list_item+
90
+
91
+ def accept_list_item_start(list_item)
92
+ @res << list_item_start(list_item, @list.last)
93
+ end
94
+
95
+ ##
96
+ # Prepares the visitor for consuming +list+
97
+
98
+ def accept_list_start(list)
99
+ @list << list.type
100
+ @res << html_list_name(list.type, true)
101
+ @in_list_entry.push ''
102
+ end
103
+
104
+ ##
105
+ # Adds +verbatim+ to the output
106
+
107
+ def accept_verbatim(verbatim)
108
+ throw :done if @characters >= @character_limit
109
+ input = verbatim.text.rstrip
110
+ text = truncate(input, @character_limit - @characters)
111
+ @characters += input.length
112
+ text << " #{TO_HTML_CHARACTERS[text.encoding][:ellipsis]}" unless text == input
113
+
114
+ super RDoc::Markup::Verbatim.new text
115
+
116
+ add_paragraph
117
+ end
118
+
119
+ ##
120
+ # Prepares the visitor for HTML snippet generation
121
+
122
+ def start_accepting
123
+ super
124
+
125
+ @characters = 0
126
+ end
127
+
128
+ ##
129
+ # Removes escaping from the cross-references in +target+
130
+
131
+ def handle_regexp_CROSSREF(text)
132
+ text.sub(/\A\\/, '')
133
+ end
134
+
135
+ ##
136
+ # Lists are paragraphs, but notes and labels have a separator
137
+
138
+ def list_item_start(list_item, list_type)
139
+ throw :done if @characters >= @character_limit
140
+
141
+ case list_type
142
+ when :BULLET, :LALPHA, :NUMBER, :UALPHA then
143
+ "<p>"
144
+ when :LABEL, :NOTE then
145
+ labels = Array(list_item.label).map do |label|
146
+ to_html label
147
+ end.join ', '
148
+
149
+ labels << " &mdash; " unless labels.empty?
150
+
151
+ start = "<p>#{labels}"
152
+ @characters += 1 # try to include the label
153
+ start
154
+ else
155
+ raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
156
+ end
157
+ end
158
+
159
+ ##
160
+ # Returns just the text of +link+, +url+ is only used to determine the link
161
+ # type.
162
+
163
+ def gen_url(url, text)
164
+ if url =~ /^rdoc-label:([^:]*)(?::(.*))?/ then
165
+ type = "link"
166
+ elsif url =~ /([A-Za-z]+):(.*)/ then
167
+ type = $1
168
+ else
169
+ type = "http"
170
+ end
171
+
172
+ if (type == "http" or type == "https" or type == "link") and
173
+ url =~ /\.(gif|png|jpg|jpeg|bmp)$/ then
174
+ ''
175
+ else
176
+ text.sub(%r%^#{type}:/*%, '')
177
+ end
178
+ end
179
+
180
+ ##
181
+ # In snippets, there are no lists
182
+
183
+ def html_list_name(list_type, open_tag)
184
+ ''
185
+ end
186
+
187
+ ##
188
+ # Throws +:done+ when paragraph_limit paragraphs have been encountered
189
+
190
+ def add_paragraph
191
+ @paragraphs += 1
192
+
193
+ throw :done if @paragraphs >= @paragraph_limit
194
+ end
195
+
196
+ ##
197
+ # Marks up +content+
198
+
199
+ def convert(content)
200
+ catch :done do
201
+ return super
202
+ end
203
+
204
+ end_accepting
205
+ end
206
+
207
+ def handle_PLAIN_TEXT(text) # :nodoc:
208
+ return if inline_limit_reached?
209
+
210
+ truncated = truncate(text, @inline_character_limit)
211
+ @inline_character_limit -= text.size
212
+ emit_inline(convert_string(truncated))
213
+ end
214
+
215
+ def handle_REGEXP_HANDLING_TEXT(text) # :nodoc:
216
+ return if inline_limit_reached?
217
+
218
+ # We can't truncate text including html tags.
219
+ # Just emit as is, and count all characters including html tag part.
220
+ emit_inline(text)
221
+ @inline_character_limit -= text.size
222
+ end
223
+
224
+ def handle_BOLD(nodes)
225
+ super unless inline_limit_reached?
226
+ end
227
+
228
+ def handle_BOLD_WORD(word)
229
+ super unless inline_limit_reached?
230
+ end
231
+
232
+ def handle_EM(nodes)
233
+ super unless inline_limit_reached?
234
+ end
235
+
236
+ def handle_EM_WORD(word)
237
+ super unless inline_limit_reached?
238
+ end
239
+
240
+ def handle_TT(code)
241
+ super unless inline_limit_reached?
242
+ end
243
+
244
+ def handle_STRIKE(nodes)
245
+ super unless inline_limit_reached?
246
+ end
247
+
248
+ def handle_HARD_BREAK
249
+ super unless inline_limit_reached?
250
+ end
251
+
252
+ def handle_TIDYLINK(label_part, url)
253
+ traverse_inline_nodes(label_part) unless inline_limit_reached?
254
+ end
255
+
256
+ def inline_limit_reached?
257
+ @inline_character_limit <= 0
258
+ end
259
+
260
+ def handle_inline(text)
261
+ limit = @character_limit - @characters
262
+ return ['', 0] if limit <= 0
263
+ @inline_character_limit = limit
264
+ res = super
265
+ res << " #{TO_HTML_CHARACTERS[text.encoding][:ellipsis]}" if @inline_character_limit <= 0
266
+ @characters += limit - @inline_character_limit
267
+ res
268
+ end
269
+
270
+ def to_html(item)
271
+ throw :done if @characters >= @character_limit
272
+ handle_inline(item)
273
+ end
274
+
275
+ ##
276
+ # Truncates +text+ at the end of the first word after the limit.
277
+
278
+ def truncate(text, limit)
279
+ return text if limit >= text.size
280
+ return '' if limit <= 0
281
+
282
+ text =~ /\A(.{#{limit},}?)(\s|$)/m # TODO word-break instead of \s?
283
+
284
+ $1
285
+ end
286
+
287
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # Joins the parts of an RDoc::Markup::Paragraph into a single String.
4
+ #
5
+ # This allows for easier maintenance and testing of Markdown support.
6
+ #
7
+ # This formatter only works on Paragraph instances. Attempting to process
8
+ # other markup syntax items will not work.
9
+
10
+ class RDoc::Markup::ToJoinedParagraph < RDoc::Markup::Formatter
11
+ def start_accepting # :nodoc:
12
+ end
13
+
14
+ def end_accepting # :nodoc:
15
+ end
16
+
17
+ ##
18
+ # Converts the parts of +paragraph+ to a single entry.
19
+
20
+ def accept_paragraph(paragraph)
21
+ parts = paragraph.parts.chunk do |part|
22
+ String === part
23
+ end.flat_map do |string, chunk|
24
+ string ? chunk.join.rstrip : chunk
25
+ end
26
+
27
+ paragraph.parts.replace parts
28
+ end
29
+
30
+ alias accept_block_quote ignore
31
+ alias accept_heading ignore
32
+ alias accept_list_end ignore
33
+ alias accept_list_item_end ignore
34
+ alias accept_list_item_start ignore
35
+ alias accept_list_start ignore
36
+ alias accept_raw ignore
37
+ alias accept_rule ignore
38
+ alias accept_verbatim ignore
39
+ alias accept_table ignore
40
+
41
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+ require 'cgi/escape'
3
+ require 'cgi/util' unless defined?(CGI::EscapeExt)
4
+
5
+ ##
6
+ # Creates HTML-safe labels suitable for use in id attributes. Tidylinks are
7
+ # converted to their link part and cross-reference links have the suppression
8
+ # marks removed (\\SomeClass is converted to SomeClass).
9
+
10
+ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
11
+
12
+ attr_reader :res # :nodoc:
13
+
14
+ ##
15
+ # Creates a new formatter that will output HTML-safe labels
16
+
17
+ def initialize
18
+ super
19
+
20
+ @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
21
+
22
+ @res = []
23
+ end
24
+
25
+ def handle_PLAIN_TEXT(text)
26
+ @res << text
27
+ end
28
+
29
+ def handle_REGEXP_HANDLING_TEXT(text)
30
+ @res << text
31
+ end
32
+
33
+ def handle_TT(text)
34
+ @res << text
35
+ end
36
+
37
+ def extract_plaintext(text)
38
+ @res = []
39
+ handle_inline(text)
40
+ @res.join
41
+ end
42
+
43
+ ##
44
+ # Converts +text+ to an HTML-safe label using GitHub-style anchor formatting.
45
+
46
+ def convert(text)
47
+ label = extract_plaintext(text)
48
+
49
+ RDoc::Text.to_anchor(label)
50
+ end
51
+
52
+ ##
53
+ # Converts +text+ to an HTML-safe label using legacy RDoc formatting.
54
+ # Used for generating backward-compatible anchor aliases.
55
+
56
+ def convert_legacy(text)
57
+ label = extract_plaintext(text)
58
+
59
+ CGI.escape(label).gsub('%', '-').sub(/^-/, '')
60
+ end
61
+
62
+ ##
63
+ # Converts the CROSSREF +target+ to plain text, removing the suppression
64
+ # marker, if any
65
+
66
+ def handle_regexp_CROSSREF(text)
67
+ text.sub(/^\\/, '')
68
+ end
69
+
70
+ alias accept_blank_line ignore
71
+ alias accept_block_quote ignore
72
+ alias accept_heading ignore
73
+ alias accept_list_end ignore
74
+ alias accept_list_item_end ignore
75
+ alias accept_list_item_start ignore
76
+ alias accept_list_start ignore
77
+ alias accept_paragraph ignore
78
+ alias accept_raw ignore
79
+ alias accept_rule ignore
80
+ alias accept_verbatim ignore
81
+ alias end_accepting ignore
82
+ alias start_accepting ignore
83
+
84
+ end