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,215 @@
1
+ # frozen_string_literal: true
2
+ # :markup: markdown
3
+
4
+ ##
5
+ # Outputs parsed markup as Markdown
6
+
7
+ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
8
+
9
+ ##
10
+ # Creates a new formatter that will output Markdown format text
11
+
12
+ def initialize
13
+ super
14
+
15
+ @headings[1] = ['# ', '']
16
+ @headings[2] = ['## ', '']
17
+ @headings[3] = ['### ', '']
18
+ @headings[4] = ['#### ', '']
19
+ @headings[5] = ['##### ', '']
20
+ @headings[6] = ['###### ', '']
21
+
22
+ add_regexp_handling_RDOCLINK
23
+
24
+ @hard_break = " \n"
25
+ end
26
+
27
+ ##
28
+ # Finishes consumption of `list`
29
+
30
+ def accept_list_end(list)
31
+ super
32
+ end
33
+
34
+ ##
35
+ # Finishes consumption of `list_item`
36
+
37
+ def accept_list_item_end(list_item)
38
+ width = case @list_type.last
39
+ when :BULLET then
40
+ 4
41
+ when :NOTE, :LABEL then
42
+ use_prefix
43
+
44
+ @res << "\n"
45
+
46
+ 4
47
+ else
48
+ @list_index[-1] = @list_index.last.succ
49
+ 4
50
+ end
51
+
52
+ @indent -= width
53
+ end
54
+
55
+ ##
56
+ # Prepares the visitor for consuming `list_item`
57
+
58
+ def accept_list_item_start(list_item)
59
+ type = @list_type.last
60
+
61
+ case type
62
+ when :NOTE, :LABEL then
63
+ bullets = Array(list_item.label).map do |label|
64
+ attributes(label).strip
65
+ end.join "\n"
66
+
67
+ bullets << "\n" unless bullets.empty?
68
+
69
+ @prefix = ' ' * @indent
70
+ @indent += 4
71
+ @prefix << bullets << ":" << (' ' * (@indent - 1))
72
+ else
73
+ bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
74
+ @prefix = (' ' * @indent) + bullet.ljust(4)
75
+
76
+ @indent += 4
77
+ end
78
+ end
79
+
80
+ def add_tag(tag, simple_tag, content)
81
+ if content.match?(/\A[\w\s]+\z/)
82
+ emit_inline("#{simple_tag}#{content}#{simple_tag}")
83
+ else
84
+ emit_inline("<#{tag}>#{content}</#{tag}>")
85
+ end
86
+ end
87
+
88
+ def handle_tag(nodes, simple_tag, tag)
89
+ if nodes.size == 1 && String === nodes[0]
90
+ content = apply_regexp_handling(nodes[0]).map do |text, converted|
91
+ converted ? text : convert_string(text)
92
+ end.join
93
+ add_tag(tag, simple_tag, content)
94
+ else
95
+ emit_inline("<#{tag}>")
96
+ traverse_inline_nodes(nodes)
97
+ emit_inline("</#{tag}>")
98
+ end
99
+ end
100
+
101
+ def handle_TIDYLINK(label_part, url)
102
+ if url =~ /^rdoc-label:foot/ then
103
+ emit_inline(handle_rdoc_link(url))
104
+ else
105
+ emit_inline('[')
106
+ traverse_inline_nodes(label_part)
107
+ emit_inline("](#{url})")
108
+ end
109
+ end
110
+
111
+ def handle_BOLD(nodes)
112
+ handle_tag(nodes, '**', 'strong')
113
+ end
114
+
115
+ def handle_EM(nodes)
116
+ handle_tag(nodes, '*', 'em')
117
+ end
118
+
119
+ def handle_BOLD_WORD(word)
120
+ add_tag('strong', '**', convert_string(word))
121
+ end
122
+
123
+ def handle_EM_WORD(word)
124
+ add_tag('em', '*', convert_string(word))
125
+ end
126
+
127
+ def handle_TT(text)
128
+ add_tag('code', '`', convert_string(text))
129
+ end
130
+
131
+ def handle_STRIKE(nodes)
132
+ handle_tag(nodes, '~~', 's')
133
+ end
134
+
135
+ def handle_HARD_BREAK
136
+ emit_inline(" \n")
137
+ end
138
+
139
+ ##
140
+ # Prepares the visitor for consuming `list`
141
+
142
+ def accept_list_start(list)
143
+ case list.type
144
+ when :BULLET, :LABEL, :NOTE then
145
+ @list_index << nil
146
+ when :LALPHA, :NUMBER, :UALPHA then
147
+ @list_index << 1
148
+ else
149
+ raise RDoc::Error, "invalid list type #{list.type}"
150
+ end
151
+
152
+ @list_width << 4
153
+ @list_type << list.type
154
+ end
155
+
156
+ ##
157
+ # Adds `rule` to the output
158
+
159
+ def accept_rule(rule)
160
+ use_prefix or @res << ' ' * @indent
161
+ @res << '-' * 3
162
+ @res << "\n"
163
+ end
164
+
165
+ ##
166
+ # Outputs `verbatim` indented 4 columns
167
+
168
+ def accept_verbatim(verbatim)
169
+ indent = ' ' * (@indent + 4)
170
+
171
+ verbatim.parts.each do |part|
172
+ @res << indent unless part == "\n"
173
+ @res << part
174
+ end
175
+
176
+ @res << "\n"
177
+ end
178
+
179
+ ##
180
+ # Creates a Markdown-style URL from +url+ with +text+.
181
+
182
+ def gen_url(url, text)
183
+ scheme, url, = parse_url url
184
+
185
+ "[#{text.sub(%r{^#{scheme}:/*}i, '')}](#{url})"
186
+ end
187
+
188
+ ##
189
+ # Handles <tt>rdoc-</tt> type links for footnotes.
190
+
191
+ def handle_rdoc_link(url)
192
+ case url
193
+ when /^rdoc-ref:/ then
194
+ $'
195
+ when /^rdoc-label:footmark-(\d+)/ then
196
+ "[^#{$1}]:"
197
+ when /^rdoc-label:foottext-(\d+)/ then
198
+ "[^#{$1}]"
199
+ when /^rdoc-label:label-/ then
200
+ gen_url url, $'
201
+ when /^rdoc-image:/ then
202
+ "![](#{$'})"
203
+ when /^rdoc-[a-z]+:/ then
204
+ $'
205
+ end
206
+ end
207
+
208
+ ##
209
+ # Converts the rdoc-...: links into a Markdown.style links.
210
+
211
+ def handle_regexp_RDOCLINK(text)
212
+ handle_rdoc_link text
213
+ end
214
+
215
+ end
@@ -0,0 +1,421 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # Outputs RDoc markup as RDoc markup! (mostly)
4
+
5
+ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
6
+ DEFAULT_HEADINGS = {
7
+ 1 => ['= ', ''],
8
+ 2 => ['== ', ''],
9
+ 3 => ['=== ', ''],
10
+ 4 => ['==== ', ''],
11
+ 5 => ['===== ', ''],
12
+ 6 => ['====== ', '']
13
+ }
14
+ DEFAULT_HEADINGS.default = []
15
+ DEFAULT_HEADINGS.freeze
16
+
17
+ ##
18
+ # Current indent amount for output in characters
19
+
20
+ attr_accessor :indent
21
+
22
+ ##
23
+ # Output width in characters
24
+
25
+ attr_accessor :width
26
+
27
+ ##
28
+ # Stack of current list indexes for alphabetic and numeric lists
29
+
30
+ attr_reader :list_index
31
+
32
+ ##
33
+ # Stack of list types
34
+
35
+ attr_reader :list_type
36
+
37
+ ##
38
+ # Stack of list widths for indentation
39
+
40
+ attr_reader :list_width
41
+
42
+ ##
43
+ # Prefix for the next list item. See #use_prefix
44
+
45
+ attr_reader :prefix
46
+
47
+ ##
48
+ # Output accumulator
49
+
50
+ attr_reader :res
51
+
52
+ ##
53
+ # Creates a new formatter that will output (mostly) \RDoc markup
54
+
55
+ def initialize
56
+ super
57
+
58
+ @markup.add_regexp_handling(/\\\S/, :SUPPRESSED_CROSSREF)
59
+ @width = 78
60
+
61
+ @headings = DEFAULT_HEADINGS.dup
62
+ @hard_break = "\n"
63
+ end
64
+
65
+ ##
66
+ # Adds +blank_line+ to the output
67
+
68
+ def accept_blank_line(blank_line)
69
+ @res << "\n"
70
+ end
71
+
72
+ ##
73
+ # Adds +paragraph+ to the output
74
+
75
+ def accept_block_quote(block_quote)
76
+ @indent += 2
77
+
78
+ block_quote.parts.each do |part|
79
+ @prefix = '> '
80
+
81
+ part.accept self
82
+ end
83
+
84
+ @indent -= 2
85
+ end
86
+
87
+ ##
88
+ # Adds +heading+ to the output
89
+
90
+ def accept_heading(heading)
91
+ use_prefix or @res << ' ' * @indent
92
+ @res << @headings[heading.level][0]
93
+ @res << attributes(heading.text)
94
+ @res << @headings[heading.level][1]
95
+ @res << "\n"
96
+ end
97
+
98
+ ##
99
+ # Finishes consumption of +list+
100
+
101
+ def accept_list_end(list)
102
+ @list_index.pop
103
+ @list_type.pop
104
+ @list_width.pop
105
+ end
106
+
107
+ ##
108
+ # Finishes consumption of +list_item+
109
+
110
+ def accept_list_item_end(list_item)
111
+ width = case @list_type.last
112
+ when :BULLET then
113
+ 2
114
+ when :NOTE, :LABEL then
115
+ if @prefix then
116
+ @res << @prefix.strip
117
+ @prefix = nil
118
+ end
119
+
120
+ @res << "\n"
121
+ 2
122
+ else
123
+ bullet = @list_index.last.to_s
124
+ @list_index[-1] = @list_index.last.succ
125
+ bullet.length + 2
126
+ end
127
+
128
+ @indent -= width
129
+ end
130
+
131
+ ##
132
+ # Prepares the visitor for consuming +list_item+
133
+
134
+ def accept_list_item_start(list_item)
135
+ type = @list_type.last
136
+
137
+ case type
138
+ when :NOTE, :LABEL then
139
+ stripped_labels = Array(list_item.label).map do |label|
140
+ attributes(label).strip
141
+ end
142
+
143
+ bullets = case type
144
+ when :NOTE
145
+ stripped_labels.map { |b| "#{b}::" }
146
+ when :LABEL
147
+ stripped_labels.map { |b| "[#{b}]" }
148
+ end
149
+
150
+ bullets = bullets.join("\n")
151
+ bullets << "\n" unless stripped_labels.empty?
152
+
153
+ @prefix = ' ' * @indent
154
+ @indent += 2
155
+ @prefix << bullets + (' ' * @indent)
156
+ else
157
+ bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
158
+ @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
159
+ width = bullet.length + 1
160
+ @indent += width
161
+ end
162
+ end
163
+
164
+ ##
165
+ # Prepares the visitor for consuming +list+
166
+
167
+ def accept_list_start(list)
168
+ case list.type
169
+ when :BULLET then
170
+ @list_index << nil
171
+ @list_width << 1
172
+ when :LABEL, :NOTE then
173
+ @list_index << nil
174
+ @list_width << 2
175
+ when :LALPHA then
176
+ @list_index << 'a'
177
+ @list_width << list.items.length.to_s.length
178
+ when :NUMBER then
179
+ @list_index << 1
180
+ @list_width << list.items.length.to_s.length
181
+ when :UALPHA then
182
+ @list_index << 'A'
183
+ @list_width << list.items.length.to_s.length
184
+ else
185
+ raise RDoc::Error, "invalid list type #{list.type}"
186
+ end
187
+
188
+ @list_type << list.type
189
+ end
190
+
191
+ ##
192
+ # Adds +paragraph+ to the output
193
+
194
+ def accept_paragraph(paragraph)
195
+ text = paragraph.text @hard_break
196
+ wrap attributes text
197
+ end
198
+
199
+ ##
200
+ # Adds +paragraph+ to the output
201
+
202
+ def accept_indented_paragraph(paragraph)
203
+ @indent += paragraph.indent
204
+ text = paragraph.text @hard_break
205
+ wrap attributes text
206
+ @indent -= paragraph.indent
207
+ end
208
+
209
+ ##
210
+ # Adds +raw+ to the output
211
+
212
+ def accept_raw(raw)
213
+ @res << raw.parts.join("\n")
214
+ end
215
+
216
+ ##
217
+ # Adds +rule+ to the output
218
+
219
+ def accept_rule(rule)
220
+ use_prefix or @res << ' ' * @indent
221
+ @res << '-' * (@width - @indent)
222
+ @res << "\n"
223
+ end
224
+
225
+ ##
226
+ # Outputs +verbatim+ indented 2 columns
227
+
228
+ def accept_verbatim(verbatim)
229
+ indent = ' ' * (@indent + 2)
230
+
231
+ verbatim.parts.each do |part|
232
+ @res << indent unless part == "\n"
233
+ @res << part
234
+ end
235
+
236
+ @res << "\n"
237
+ end
238
+
239
+ ##
240
+ # Adds +table+ to the output
241
+
242
+ def accept_table(header, body, aligns)
243
+ header = header.map { |h| attributes h }
244
+ body = body.map { |row| row.map { |t| attributes t } }
245
+ widths = header.zip(*body).map do |cols|
246
+ cols.compact.map { |col| calculate_text_width(col) }.max
247
+ end
248
+ aligns = aligns.map do |a|
249
+ case a
250
+ when nil, :center
251
+ :center
252
+ when :left
253
+ :ljust
254
+ when :right
255
+ :rjust
256
+ end
257
+ end
258
+ @res << header.zip(widths, aligns).map do |h, w, a|
259
+ extra_width = h.size - calculate_text_width(h)
260
+ h.__send__(a, w + extra_width)
261
+ end.join("|").rstrip << "\n"
262
+ @res << widths.map {|w| "-" * w }.join("|") << "\n"
263
+ body.each do |row|
264
+ @res << widths.zip(aligns).each_with_index.map do |(w, a), i|
265
+ t = row[i] || ""
266
+ extra_width = t.size - calculate_text_width(t)
267
+ t.__send__(a, w + extra_width)
268
+ end.join("|").rstrip << "\n"
269
+ end
270
+ end
271
+
272
+ def calculate_text_width(text)
273
+ text.size
274
+ end
275
+
276
+ def handle_PLAIN_TEXT(text)
277
+ add_text(text)
278
+ end
279
+
280
+ def handle_REGEXP_HANDLING_TEXT(text)
281
+ add_text(text)
282
+ end
283
+
284
+ def handle_BOLD(target)
285
+ on(:BOLD)
286
+ super
287
+ off(:BOLD)
288
+ end
289
+
290
+ def handle_EM(target)
291
+ on(:EM)
292
+ super
293
+ off(:EM)
294
+ end
295
+
296
+ def handle_BOLD_WORD(word)
297
+ on(:BOLD)
298
+ super
299
+ off(:BOLD)
300
+ end
301
+
302
+ def handle_EM_WORD(word)
303
+ on(:EM)
304
+ super
305
+ off(:EM)
306
+ end
307
+
308
+ def handle_TT(code)
309
+ on(:TT)
310
+ super
311
+ off(:TT)
312
+ end
313
+
314
+ def handle_STRIKE(target)
315
+ on(:STRIKE)
316
+ super
317
+ off(:STRIKE)
318
+ end
319
+
320
+ def handle_HARD_BREAK
321
+ add_text("\n")
322
+ end
323
+
324
+ def handle_TIDYLINK(label_part, url)
325
+ super
326
+ add_text("( #{url} )")
327
+ end
328
+
329
+ def handle_inline(text, initial_attributes = [])
330
+ @attributes = Hash.new(0)
331
+ initial_attributes.each { |attr| on(attr) }
332
+ out = @inline_output = +''
333
+ super(text)
334
+ @inline_output = nil
335
+ out
336
+ end
337
+
338
+ def on(attr)
339
+ @attributes[attr] += 1
340
+ end
341
+
342
+ def off(attr)
343
+ @attributes[attr] -= 1
344
+ @attributes.delete(attr) if @attributes[attr] == 0
345
+ end
346
+
347
+ def add_text(text)
348
+ emit_inline(text)
349
+ end
350
+
351
+ def emit_inline(text)
352
+ @inline_output << text
353
+ end
354
+
355
+ ##
356
+ # Applies attribute-specific markup to +text+ using RDoc::Markup::InlineParser
357
+
358
+ def attributes(text)
359
+ handle_inline(text)
360
+ end
361
+
362
+ ##
363
+ # Returns the generated output
364
+
365
+ def end_accepting
366
+ @res.join
367
+ end
368
+
369
+ ##
370
+ # Removes preceding \\ from the suppressed crossref +target+
371
+
372
+ def handle_regexp_SUPPRESSED_CROSSREF(text)
373
+ text.sub('\\', '')
374
+ end
375
+
376
+ ##
377
+ # Prepares the visitor for text generation
378
+
379
+ def start_accepting
380
+ @res = [""]
381
+ @indent = 0
382
+ @prefix = nil
383
+
384
+ @list_index = []
385
+ @list_type = []
386
+ @list_width = []
387
+ end
388
+
389
+ ##
390
+ # Adds the stored #prefix to the output and clears it. Lists generate a
391
+ # prefix for later consumption.
392
+
393
+ def use_prefix
394
+ prefix, @prefix = @prefix, nil
395
+ @res << prefix if prefix
396
+
397
+ prefix
398
+ end
399
+
400
+ ##
401
+ # Wraps +text+ to #width
402
+
403
+ def wrap(text)
404
+ return unless text && !text.empty?
405
+
406
+ text_len = @width - @indent
407
+
408
+ text_len = 20 if text_len < 20
409
+
410
+ next_prefix = ' ' * @indent
411
+
412
+ prefix = @prefix || next_prefix
413
+ @prefix = nil
414
+
415
+ text.scan(/\G(?:([^ \n]{#{text_len}})(?=[^ \n])|(.{1,#{text_len}})(?:[ \n]|\z))/) do
416
+ @res << prefix << ($1 || $2) << "\n"
417
+ prefix = next_prefix
418
+ end
419
+ end
420
+
421
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # Extracts just the RDoc::Markup::Heading elements from a
4
+ # RDoc::Markup::Document to help build a table of contents
5
+
6
+ class RDoc::Markup::ToTableOfContents < RDoc::Markup::Formatter
7
+
8
+ @to_toc = nil
9
+
10
+ ##
11
+ # Singleton for table-of-contents generation
12
+
13
+ def self.to_toc
14
+ @to_toc ||= new
15
+ end
16
+
17
+ ##
18
+ # Output accumulator
19
+
20
+ attr_reader :res
21
+
22
+ ##
23
+ # Omits headings with a level less than the given level.
24
+
25
+ attr_accessor :omit_headings_below
26
+
27
+ def initialize # :nodoc:
28
+ super
29
+
30
+ @omit_headings_below = nil
31
+ end
32
+
33
+ ##
34
+ # Adds +document+ to the output, using its heading cutoff if present
35
+
36
+ def accept_document(document)
37
+ @omit_headings_below = document.omit_headings_below
38
+
39
+ super
40
+ end
41
+
42
+ ##
43
+ # Adds +heading+ to the table of contents
44
+
45
+ def accept_heading(heading)
46
+ @res << heading unless suppressed? heading
47
+ end
48
+
49
+ ##
50
+ # Returns the table of contents
51
+
52
+ def end_accepting
53
+ @res
54
+ end
55
+
56
+ ##
57
+ # Prepares the visitor for text generation
58
+
59
+ def start_accepting
60
+ @omit_headings_below = nil
61
+ @res = []
62
+ end
63
+
64
+ ##
65
+ # Returns true if +heading+ is below the display threshold
66
+
67
+ def suppressed?(heading)
68
+ return false unless @omit_headings_below
69
+
70
+ heading.level > @omit_headings_below
71
+ end
72
+
73
+ # :stopdoc:
74
+ alias accept_block_quote ignore
75
+ alias accept_raw ignore
76
+ alias accept_rule ignore
77
+ alias accept_blank_line ignore
78
+ alias accept_paragraph ignore
79
+ alias accept_verbatim ignore
80
+ alias accept_list_end ignore
81
+ alias accept_list_item_start ignore
82
+ alias accept_list_item_end ignore
83
+ alias accept_list_end_bullet ignore
84
+ alias accept_list_start ignore
85
+ alias accept_table ignore
86
+ # :startdoc:
87
+
88
+ end