super-quick-rb 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. checksums.yaml +7 -0
  2. data/rdoc-8.0.0/CONTRIBUTING.md +195 -0
  3. data/rdoc-8.0.0/CVE-2013-0256.rdoc +49 -0
  4. data/rdoc-8.0.0/History.rdoc +1668 -0
  5. data/rdoc-8.0.0/LEGAL.rdoc +56 -0
  6. data/rdoc-8.0.0/LICENSE.rdoc +63 -0
  7. data/rdoc-8.0.0/README.md +236 -0
  8. data/rdoc-8.0.0/RI.md +842 -0
  9. data/rdoc-8.0.0/TODO.rdoc +60 -0
  10. data/rdoc-8.0.0/doc/markup_reference/markdown.md +659 -0
  11. data/rdoc-8.0.0/doc/markup_reference/rdoc.rdoc +1169 -0
  12. data/rdoc-8.0.0/exe/rdoc +43 -0
  13. data/rdoc-8.0.0/exe/ri +12 -0
  14. data/rdoc-8.0.0/lib/rdoc/code_object/alias.rb +98 -0
  15. data/rdoc-8.0.0/lib/rdoc/code_object/any_method.rb +387 -0
  16. data/rdoc-8.0.0/lib/rdoc/code_object/attr.rb +178 -0
  17. data/rdoc-8.0.0/lib/rdoc/code_object/class_module.rb +969 -0
  18. data/rdoc-8.0.0/lib/rdoc/code_object/constant.rb +221 -0
  19. data/rdoc-8.0.0/lib/rdoc/code_object/context/section.rb +182 -0
  20. data/rdoc-8.0.0/lib/rdoc/code_object/context.rb +1238 -0
  21. data/rdoc-8.0.0/lib/rdoc/code_object/extend.rb +9 -0
  22. data/rdoc-8.0.0/lib/rdoc/code_object/include.rb +9 -0
  23. data/rdoc-8.0.0/lib/rdoc/code_object/method_attr.rb +417 -0
  24. data/rdoc-8.0.0/lib/rdoc/code_object/mixin.rb +123 -0
  25. data/rdoc-8.0.0/lib/rdoc/code_object/normal_class.rb +92 -0
  26. data/rdoc-8.0.0/lib/rdoc/code_object/normal_module.rb +73 -0
  27. data/rdoc-8.0.0/lib/rdoc/code_object/require.rb +51 -0
  28. data/rdoc-8.0.0/lib/rdoc/code_object/single_class.rb +30 -0
  29. data/rdoc-8.0.0/lib/rdoc/code_object/top_level.rb +286 -0
  30. data/rdoc-8.0.0/lib/rdoc/code_object.rb +393 -0
  31. data/rdoc-8.0.0/lib/rdoc/code_objects.rb +5 -0
  32. data/rdoc-8.0.0/lib/rdoc/comment.rb +353 -0
  33. data/rdoc-8.0.0/lib/rdoc/cross_reference.rb +215 -0
  34. data/rdoc-8.0.0/lib/rdoc/encoding.rb +120 -0
  35. data/rdoc-8.0.0/lib/rdoc/erb_partial.rb +18 -0
  36. data/rdoc-8.0.0/lib/rdoc/erbio.rb +37 -0
  37. data/rdoc-8.0.0/lib/rdoc/generator/aliki.rb +200 -0
  38. data/rdoc-8.0.0/lib/rdoc/generator/darkfish.rb +824 -0
  39. data/rdoc-8.0.0/lib/rdoc/generator/json_index.rb +284 -0
  40. data/rdoc-8.0.0/lib/rdoc/generator/markup.rb +196 -0
  41. data/rdoc-8.0.0/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  42. data/rdoc-8.0.0/lib/rdoc/generator/pot/po.rb +84 -0
  43. data/rdoc-8.0.0/lib/rdoc/generator/pot/po_entry.rb +141 -0
  44. data/rdoc-8.0.0/lib/rdoc/generator/pot.rb +94 -0
  45. data/rdoc-8.0.0/lib/rdoc/generator/ri.rb +30 -0
  46. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
  47. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  48. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  49. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
  50. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  51. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  52. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  53. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  54. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
  55. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
  56. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  57. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  58. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  59. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  60. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  61. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  62. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
  63. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
  64. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  65. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
  66. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
  67. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  68. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
  69. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  70. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  71. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  72. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  73. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  74. data/rdoc-8.0.0/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  75. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  76. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_head.rhtml +43 -0
  77. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +5 -0
  78. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +17 -0
  79. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +17 -0
  80. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +16 -0
  81. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +21 -0
  82. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  83. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +32 -0
  84. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +6 -0
  85. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +15 -0
  86. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  87. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +39 -0
  88. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  89. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/class.rhtml +220 -0
  90. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  91. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/css/rdoc.css +701 -0
  92. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  93. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  94. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  95. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  96. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  97. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  98. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  99. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  100. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  101. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  102. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  103. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  104. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  105. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  106. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  107. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  108. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  109. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  110. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  111. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  112. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  113. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  114. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  115. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  116. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  117. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  118. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  119. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  120. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  121. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  122. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  123. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/index.rhtml +24 -0
  124. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/darkfish.js +140 -0
  125. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/js/search.js +120 -0
  126. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/page.rhtml +19 -0
  127. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +21 -0
  128. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +65 -0
  129. data/rdoc-8.0.0/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +72 -0
  130. data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  131. data/rdoc-8.0.0/lib/rdoc/generator/template/json_index/js/searcher.js +271 -0
  132. data/rdoc-8.0.0/lib/rdoc/generator.rb +52 -0
  133. data/rdoc-8.0.0/lib/rdoc/i18n/locale.rb +102 -0
  134. data/rdoc-8.0.0/lib/rdoc/i18n/text.rb +126 -0
  135. data/rdoc-8.0.0/lib/rdoc/i18n.rb +10 -0
  136. data/rdoc-8.0.0/lib/rdoc/known_classes.rb +74 -0
  137. data/rdoc-8.0.0/lib/rdoc/markdown/entities.rb +2131 -0
  138. data/rdoc-8.0.0/lib/rdoc/markdown/literals.kpeg +21 -0
  139. data/rdoc-8.0.0/lib/rdoc/markdown/literals.rb +454 -0
  140. data/rdoc-8.0.0/lib/rdoc/markdown.kpeg +1315 -0
  141. data/rdoc-8.0.0/lib/rdoc/markdown.rb +16865 -0
  142. data/rdoc-8.0.0/lib/rdoc/markup/blank_line.rb +29 -0
  143. data/rdoc-8.0.0/lib/rdoc/markup/block_quote.rb +14 -0
  144. data/rdoc-8.0.0/lib/rdoc/markup/document.rb +164 -0
  145. data/rdoc-8.0.0/lib/rdoc/markup/element.rb +21 -0
  146. data/rdoc-8.0.0/lib/rdoc/markup/formatter.rb +285 -0
  147. data/rdoc-8.0.0/lib/rdoc/markup/hard_break.rb +34 -0
  148. data/rdoc-8.0.0/lib/rdoc/markup/heading.rb +170 -0
  149. data/rdoc-8.0.0/lib/rdoc/markup/include.rb +42 -0
  150. data/rdoc-8.0.0/lib/rdoc/markup/indented_paragraph.rb +47 -0
  151. data/rdoc-8.0.0/lib/rdoc/markup/inline_parser.rb +312 -0
  152. data/rdoc-8.0.0/lib/rdoc/markup/list.rb +101 -0
  153. data/rdoc-8.0.0/lib/rdoc/markup/list_item.rb +99 -0
  154. data/rdoc-8.0.0/lib/rdoc/markup/paragraph.rb +28 -0
  155. data/rdoc-8.0.0/lib/rdoc/markup/parser.rb +585 -0
  156. data/rdoc-8.0.0/lib/rdoc/markup/pre_process.rb +317 -0
  157. data/rdoc-8.0.0/lib/rdoc/markup/raw.rb +66 -0
  158. data/rdoc-8.0.0/lib/rdoc/markup/rule.rb +20 -0
  159. data/rdoc-8.0.0/lib/rdoc/markup/table.rb +64 -0
  160. data/rdoc-8.0.0/lib/rdoc/markup/to_ansi.rb +144 -0
  161. data/rdoc-8.0.0/lib/rdoc/markup/to_bs.rb +86 -0
  162. data/rdoc-8.0.0/lib/rdoc/markup/to_html.rb +682 -0
  163. data/rdoc-8.0.0/lib/rdoc/markup/to_html_crossref.rb +261 -0
  164. data/rdoc-8.0.0/lib/rdoc/markup/to_html_snippet.rb +287 -0
  165. data/rdoc-8.0.0/lib/rdoc/markup/to_joined_paragraph.rb +41 -0
  166. data/rdoc-8.0.0/lib/rdoc/markup/to_label.rb +84 -0
  167. data/rdoc-8.0.0/lib/rdoc/markup/to_markdown.rb +215 -0
  168. data/rdoc-8.0.0/lib/rdoc/markup/to_rdoc.rb +421 -0
  169. data/rdoc-8.0.0/lib/rdoc/markup/to_table_of_contents.rb +88 -0
  170. data/rdoc-8.0.0/lib/rdoc/markup/to_test.rb +77 -0
  171. data/rdoc-8.0.0/lib/rdoc/markup/to_tt_only.rb +107 -0
  172. data/rdoc-8.0.0/lib/rdoc/markup/verbatim.rb +83 -0
  173. data/rdoc-8.0.0/lib/rdoc/markup.rb +219 -0
  174. data/rdoc-8.0.0/lib/rdoc/options.rb +1412 -0
  175. data/rdoc-8.0.0/lib/rdoc/parser/c.rb +1227 -0
  176. data/rdoc-8.0.0/lib/rdoc/parser/changelog.rb +379 -0
  177. data/rdoc-8.0.0/lib/rdoc/parser/markdown.rb +22 -0
  178. data/rdoc-8.0.0/lib/rdoc/parser/rbs.rb +275 -0
  179. data/rdoc-8.0.0/lib/rdoc/parser/rd.rb +22 -0
  180. data/rdoc-8.0.0/lib/rdoc/parser/ruby.rb +1266 -0
  181. data/rdoc-8.0.0/lib/rdoc/parser/ruby_colorizer.rb +253 -0
  182. data/rdoc-8.0.0/lib/rdoc/parser/simple.rb +44 -0
  183. data/rdoc-8.0.0/lib/rdoc/parser/text.rb +11 -0
  184. data/rdoc-8.0.0/lib/rdoc/parser.rb +298 -0
  185. data/rdoc-8.0.0/lib/rdoc/rbs_helper.rb +186 -0
  186. data/rdoc-8.0.0/lib/rdoc/rd/block_parser.rb +1706 -0
  187. data/rdoc-8.0.0/lib/rdoc/rd/block_parser.ry +643 -0
  188. data/rdoc-8.0.0/lib/rdoc/rd/inline.rb +71 -0
  189. data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.rb +1854 -0
  190. data/rdoc-8.0.0/lib/rdoc/rd/inline_parser.ry +593 -0
  191. data/rdoc-8.0.0/lib/rdoc/rd.rb +99 -0
  192. data/rdoc-8.0.0/lib/rdoc/rdoc.rb +724 -0
  193. data/rdoc-8.0.0/lib/rdoc/ri/driver.rb +1572 -0
  194. data/rdoc-8.0.0/lib/rdoc/ri/formatter.rb +6 -0
  195. data/rdoc-8.0.0/lib/rdoc/ri/paths.rb +171 -0
  196. data/rdoc-8.0.0/lib/rdoc/ri/servlet.rb +452 -0
  197. data/rdoc-8.0.0/lib/rdoc/ri/store.rb +6 -0
  198. data/rdoc-8.0.0/lib/rdoc/ri/task.rb +71 -0
  199. data/rdoc-8.0.0/lib/rdoc/ri.rb +21 -0
  200. data/rdoc-8.0.0/lib/rdoc/rubygems_hook.rb +327 -0
  201. data/rdoc-8.0.0/lib/rdoc/server.rb +460 -0
  202. data/rdoc-8.0.0/lib/rdoc/stats/normal.rb +58 -0
  203. data/rdoc-8.0.0/lib/rdoc/stats/quiet.rb +59 -0
  204. data/rdoc-8.0.0/lib/rdoc/stats/verbose.rb +44 -0
  205. data/rdoc-8.0.0/lib/rdoc/stats.rb +484 -0
  206. data/rdoc-8.0.0/lib/rdoc/store.rb +1205 -0
  207. data/rdoc-8.0.0/lib/rdoc/task.rb +355 -0
  208. data/rdoc-8.0.0/lib/rdoc/text.rb +244 -0
  209. data/rdoc-8.0.0/lib/rdoc/token_stream.rb +104 -0
  210. data/rdoc-8.0.0/lib/rdoc/tom_doc.rb +257 -0
  211. data/rdoc-8.0.0/lib/rdoc/version.rb +10 -0
  212. data/rdoc-8.0.0/lib/rdoc.rb +239 -0
  213. data/rdoc-8.0.0/lib/rubygems_plugin.rb +14 -0
  214. data/rdoc-8.0.0/man/ri.1 +249 -0
  215. data/rdoc-8.0.0/rdoc-logo.svg +43 -0
  216. data/rdoc-8.0.0/rdoc.gemspec +74 -0
  217. data/super-quick-rb.gemspec +12 -0
  218. metadata +257 -0
@@ -0,0 +1,271 @@
1
+ Searcher = function(data) {
2
+ this.data = data;
3
+ this.handlers = [];
4
+ }
5
+
6
+ Searcher.prototype = new function() {
7
+ // search is performed in chunks of 1000 for non-blocking user input
8
+ var CHUNK_SIZE = 1000;
9
+ // do not try to find more than 100 results
10
+ var MAX_RESULTS = 100;
11
+ var huid = 1;
12
+ var suid = 1;
13
+ var runs = 0;
14
+
15
+ this.find = function(query) {
16
+ var queries = splitQuery(query);
17
+ var regexps = buildRegexps(queries);
18
+ var highlighters = buildHilighters(queries);
19
+ var state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++};
20
+ var _this = this;
21
+
22
+ this.currentSuid = state.n;
23
+
24
+ if (!query) return;
25
+
26
+ var run = function() {
27
+ // stop current search thread if new search started
28
+ if (state.n != _this.currentSuid) return;
29
+
30
+ var results =
31
+ performSearch(_this.data, regexps, queries, highlighters, state);
32
+ var hasMore = (state.limit > 0 && state.pass < 6);
33
+
34
+ triggerResults.call(_this, results, !hasMore);
35
+ if (hasMore) {
36
+ setTimeout(run, 2);
37
+ }
38
+ runs++;
39
+ };
40
+ runs = 0;
41
+
42
+ // start search thread
43
+ run();
44
+ }
45
+
46
+ /* ----- Events ------ */
47
+ this.ready = function(fn) {
48
+ fn.huid = huid;
49
+ this.handlers.push(fn);
50
+ }
51
+
52
+ /* ----- Utilities ------ */
53
+ function splitQuery(query) {
54
+ return query.split(/(\s+|::?|\(\)?)/).filter(function(string) {
55
+ return string.match(/\S/);
56
+ });
57
+ }
58
+
59
+ function buildRegexps(queries) {
60
+ // A small minority of older browsers don't have RegExp.escape
61
+ // but it's not worth including a complex polyfill.
62
+ var escape = RegExp.escape || function(s) { return s };
63
+
64
+ return queries.map(function(query) {
65
+ var pattern = [];
66
+ for (var i = 0; i < query.length; i++) {
67
+ var char = escape(query[i]);
68
+ pattern.push('([' + char + '])([^' + char + ']*?)');
69
+ }
70
+ return new RegExp(pattern.join(''), 'i');
71
+ });
72
+ }
73
+
74
+ function buildHilighters(queries) {
75
+ return queries.map(function(query) {
76
+ return query.split('').map(function(l, i) {
77
+ return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2);
78
+ }).join('');
79
+ });
80
+ }
81
+
82
+ // function longMatchRegexp(index, longIndex, regexps) {
83
+ // for (var i = regexps.length - 1; i >= 0; i--){
84
+ // if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
85
+ // };
86
+ // return true;
87
+ // }
88
+
89
+
90
+ /* ----- Mathchers ------ */
91
+
92
+ /*
93
+ * This record matches if both the index and longIndex exactly equal queries[0]
94
+ * and the record matches all of the regexps. This ensures top-level exact matches
95
+ * like "String" are prioritized over nested classes like "Gem::Module::String".
96
+ */
97
+ function matchPassExact(index, longIndex, queries) {
98
+ return index == queries[0] && longIndex == queries[0];
99
+ }
100
+
101
+ /*
102
+ * This record matches if the index without "()" exactly equals queries[0].
103
+ * This prioritizes methods like "attribute()" when searching for "attribute".
104
+ */
105
+ function matchPassExactMethod(index, longIndex, queries, regexps) {
106
+ var indexWithoutParens = index.replace(/\(\)$/, '');
107
+ if (indexWithoutParens != queries[0]) return false;
108
+ if (index === indexWithoutParens) return false; // Not a method (no parens to remove)
109
+ for (var i=1, l = regexps.length; i < l; i++) {
110
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
111
+ return false;
112
+ };
113
+ return true;
114
+ }
115
+
116
+ /*
117
+ * This record matches if the index starts with queries[0] and the record
118
+ * matches all of the regexps
119
+ */
120
+ function matchPassBeginning(index, longIndex, queries, regexps) {
121
+ if (index.indexOf(queries[0]) != 0) return false;
122
+ for (var i=1, l = regexps.length; i < l; i++) {
123
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
124
+ return false;
125
+ };
126
+ return true;
127
+ }
128
+
129
+ /*
130
+ * This record matches if the longIndex starts with queries[0] and the
131
+ * longIndex matches all of the regexps
132
+ */
133
+ function matchPassLongIndex(index, longIndex, queries, regexps) {
134
+ if (longIndex.indexOf(queries[0]) != 0) return false;
135
+ for (var i=1, l = regexps.length; i < l; i++) {
136
+ if (!longIndex.match(regexps[i]))
137
+ return false;
138
+ };
139
+ return true;
140
+ }
141
+
142
+ /*
143
+ * This record matches if the index contains queries[0] and the record
144
+ * matches all of the regexps
145
+ */
146
+ function matchPassContains(index, longIndex, queries, regexps) {
147
+ if (index.indexOf(queries[0]) == -1) return false;
148
+ for (var i=1, l = regexps.length; i < l; i++) {
149
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
150
+ return false;
151
+ };
152
+ return true;
153
+ }
154
+
155
+ /*
156
+ * This record matches if regexps[0] matches the index and the record
157
+ * matches all of the regexps
158
+ */
159
+ function matchPassRegexp(index, longIndex, queries, regexps) {
160
+ if (!index.match(regexps[0])) return false;
161
+ for (var i=1, l = regexps.length; i < l; i++) {
162
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
163
+ return false;
164
+ };
165
+ return true;
166
+ }
167
+
168
+
169
+ /* ----- Highlighters ------ */
170
+ function highlightRegexp(info, queries, regexps, highlighters) {
171
+ var result = createResult(info);
172
+ for (var i=0, l = regexps.length; i < l; i++) {
173
+ result.title = result.title.replace(regexps[i], highlighters[i]);
174
+ result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
175
+ };
176
+ return result;
177
+ }
178
+
179
+ function hltSubstring(string, pos, length) {
180
+ return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
181
+ }
182
+
183
+ function highlightQuery(info, queries, regexps, highlighters) {
184
+ var result = createResult(info);
185
+ var pos = 0;
186
+ var lcTitle = result.title.toLowerCase();
187
+
188
+ pos = lcTitle.indexOf(queries[0]);
189
+ if (pos != -1) {
190
+ result.title = hltSubstring(result.title, pos, queries[0].length);
191
+ }
192
+
193
+ result.namespace = result.namespace.replace(regexps[0], highlighters[0]);
194
+ for (var i=1, l = regexps.length; i < l; i++) {
195
+ result.title = result.title.replace(regexps[i], highlighters[i]);
196
+ result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
197
+ };
198
+ return result;
199
+ }
200
+
201
+ function createResult(info) {
202
+ var result = {};
203
+ result.title = info[0];
204
+ result.namespace = info[1];
205
+ result.path = info[2];
206
+ result.params = info[3];
207
+ result.snippet = info[4];
208
+ result.badge = info[6];
209
+ return result;
210
+ }
211
+
212
+ /* ----- Searching ------ */
213
+ function performSearch(data, regexps, queries, highlighters, state) {
214
+ var searchIndex = data.searchIndex;
215
+ var longSearchIndex = data.longSearchIndex;
216
+ var info = data.info;
217
+ var result = [];
218
+ var i = state.from;
219
+ var l = searchIndex.length;
220
+ var togo = CHUNK_SIZE;
221
+ var matchFunc, hltFunc;
222
+
223
+ var isLowercaseQuery = queries[0] === queries[0].toLowerCase();
224
+
225
+ while (state.pass < 6 && state.limit > 0 && togo > 0) {
226
+ // When query is lowercase, prioritize methods over classes
227
+ if (state.pass == 0) {
228
+ matchFunc = isLowercaseQuery ? matchPassExactMethod : matchPassExact;
229
+ hltFunc = highlightQuery;
230
+ } else if (state.pass == 1) {
231
+ matchFunc = isLowercaseQuery ? matchPassExact : matchPassExactMethod;
232
+ hltFunc = highlightQuery;
233
+ } else if (state.pass == 2) {
234
+ matchFunc = matchPassBeginning;
235
+ hltFunc = highlightQuery;
236
+ } else if (state.pass == 3) {
237
+ matchFunc = matchPassLongIndex;
238
+ hltFunc = highlightQuery;
239
+ } else if (state.pass == 4) {
240
+ matchFunc = matchPassContains;
241
+ hltFunc = highlightQuery;
242
+ } else if (state.pass == 5) {
243
+ matchFunc = matchPassRegexp;
244
+ hltFunc = highlightRegexp;
245
+ }
246
+
247
+ for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
248
+ if (info[i].n == state.n) continue;
249
+ if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
250
+ info[i].n = state.n;
251
+ result.push(hltFunc(info[i], queries, regexps, highlighters));
252
+ state.limit--;
253
+ }
254
+ };
255
+ if (searchIndex.length <= i) {
256
+ state.pass++;
257
+ i = state.from = 0;
258
+ } else {
259
+ state.from = i;
260
+ }
261
+ }
262
+ return result;
263
+ }
264
+
265
+ function triggerResults(results, isLast) {
266
+ this.handlers.forEach(function(fn) {
267
+ fn.call(this, results, isLast)
268
+ });
269
+ }
270
+ }
271
+
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # RDoc uses generators to turn parsed source code in the form of an
4
+ # RDoc::CodeObject tree into some form of output. RDoc comes with the HTML
5
+ # generator RDoc::Generator::Darkfish and an ri data generator
6
+ # RDoc::Generator::RI.
7
+ #
8
+ # == Registering a Generator
9
+ #
10
+ # Generators are registered by calling RDoc::RDoc.add_generator with the class
11
+ # of the generator:
12
+ #
13
+ # class My::Awesome::Generator
14
+ # RDoc::RDoc.add_generator self
15
+ # end
16
+ #
17
+ # == Adding Options to +rdoc+
18
+ #
19
+ # Before option processing in +rdoc+, RDoc::Options will call ::setup_options
20
+ # on the generator class with an RDoc::Options instance. The generator can
21
+ # use RDoc::Options#option_parser to add command-line options to the +rdoc+
22
+ # tool. See RDoc::Options@Custom+Options for an example and see OptionParser
23
+ # for details on how to add options.
24
+ #
25
+ # You can extend the RDoc::Options instance with additional accessors for your
26
+ # generator.
27
+ #
28
+ # == Generator Instantiation
29
+ #
30
+ # After parsing, RDoc::RDoc will instantiate a generator by calling
31
+ # #initialize with an RDoc::Store instance and an RDoc::Options instance.
32
+ #
33
+ # The RDoc::Store instance holds documentation for parsed source code. In
34
+ # RDoc 3 and earlier the RDoc::TopLevel class held this data. When upgrading
35
+ # a generator from RDoc 3 and earlier you should only need to replace
36
+ # RDoc::TopLevel with the store instance.
37
+ #
38
+ # RDoc will then call #generate on the generator instance. You can use the
39
+ # various methods on RDoc::Store and in the RDoc::CodeObject tree to create
40
+ # your desired output format.
41
+
42
+ module RDoc::Generator
43
+
44
+ autoload :Markup, "#{__dir__}/generator/markup"
45
+
46
+ autoload :Aliki, "#{__dir__}/generator/aliki"
47
+ autoload :Darkfish, "#{__dir__}/generator/darkfish"
48
+ autoload :JsonIndex, "#{__dir__}/generator/json_index"
49
+ autoload :RI, "#{__dir__}/generator/ri"
50
+ autoload :POT, "#{__dir__}/generator/pot"
51
+
52
+ end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # A message container for a locale.
4
+ #
5
+ # This object provides the following two features:
6
+ #
7
+ # * Loads translated messages from .po file.
8
+ # * Translates a message into the locale.
9
+
10
+ class RDoc::I18n::Locale
11
+
12
+ @@locales = {} # :nodoc:
13
+
14
+ class << self
15
+
16
+ ##
17
+ # Returns the locale object for +locale_name+.
18
+
19
+ def [](locale_name)
20
+ @@locales[locale_name] ||= new(locale_name)
21
+ end
22
+
23
+ ##
24
+ # Sets the locale object for +locale_name+.
25
+ #
26
+ # Normally, this method is not used. This method is useful for
27
+ # testing.
28
+
29
+ def []=(locale_name, locale)
30
+ @@locales[locale_name] = locale
31
+ end
32
+
33
+ end
34
+
35
+ ##
36
+ # The name of the locale. It uses IETF language tag format
37
+ # +[language[_territory][.codeset][@modifier]]+.
38
+ #
39
+ # See also {BCP 47 - Tags for Identifying
40
+ # Languages}[http://tools.ietf.org/rfc/bcp/bcp47.txt].
41
+
42
+ attr_reader :name
43
+
44
+ ##
45
+ # Creates a new locale object for +name+ locale. +name+ must
46
+ # follow IETF language tag format.
47
+
48
+ def initialize(name)
49
+ @name = name
50
+ @messages = {}
51
+ end
52
+
53
+ ##
54
+ # Loads translation messages from +locale_directory+/+@name+/rdoc.po
55
+ # or +locale_directory+/+@name+.po. The former has high priority.
56
+ #
57
+ # This method requires gettext gem for parsing .po file. If you
58
+ # don't have gettext gem, this method doesn't load .po file. This
59
+ # method warns and returns +false+.
60
+ #
61
+ # Returns +true+ if succeeded, +false+ otherwise.
62
+
63
+ def load(locale_directory)
64
+ return false if @name.nil?
65
+
66
+ po_file_candidates = [
67
+ File.join(locale_directory, @name, 'rdoc.po'),
68
+ File.join(locale_directory, "#{@name}.po"),
69
+ ]
70
+ po_file = po_file_candidates.find do |po_file_candidate|
71
+ File.exist?(po_file_candidate)
72
+ end
73
+ return false unless po_file
74
+
75
+ begin
76
+ require 'gettext/po_parser'
77
+ require 'gettext/mo'
78
+ rescue LoadError
79
+ warn('Need gettext gem for i18n feature:')
80
+ warn(' gem install gettext')
81
+ return false
82
+ end
83
+
84
+ po_parser = GetText::POParser.new
85
+ messages = GetText::MO.new
86
+ po_parser.report_warning = false
87
+ po_parser.parse_file(po_file, messages)
88
+
89
+ @messages.merge!(messages)
90
+
91
+ true
92
+ end
93
+
94
+ ##
95
+ # Translates the +message+ into locale. If there is no translation
96
+ # messages for +message+ in locale, +message+ itself is returned.
97
+
98
+ def translate(message)
99
+ @messages[message] || message
100
+ end
101
+
102
+ end
@@ -0,0 +1,126 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # An i18n supported text.
4
+ #
5
+ # This object provides the following two features:
6
+ #
7
+ # * Extracts translation messages from wrapped raw text.
8
+ # * Translates wrapped raw text in specified locale.
9
+ #
10
+ # Wrapped raw text is one of String, RDoc::Comment or Array of them.
11
+
12
+ class RDoc::I18n::Text
13
+
14
+ ##
15
+ # Creates a new i18n supported text for +raw+ text.
16
+
17
+ def initialize(raw)
18
+ @raw = raw
19
+ end
20
+
21
+ ##
22
+ # Extracts translation target messages and yields each message.
23
+ #
24
+ # Each yielded message is a Hash. It consists of the followings:
25
+ #
26
+ # :type :: :paragraph
27
+ # :paragraph :: String (The translation target message itself.)
28
+ # :line_no :: Integer (The line number of the :paragraph is started.)
29
+ #
30
+ # The above content may be added in the future.
31
+
32
+ def extract_messages
33
+ parse do |part|
34
+ case part[:type]
35
+ when :empty_line
36
+ # ignore
37
+ when :paragraph
38
+ yield(part)
39
+ end
40
+ end
41
+ end
42
+
43
+ # Translates raw text into +locale+.
44
+ def translate(locale)
45
+ translated_text = ''
46
+ parse do |part|
47
+ case part[:type]
48
+ when :paragraph
49
+ translated_text += locale.translate(part[:paragraph])
50
+ when :empty_line
51
+ translated_text += part[:line]
52
+ else
53
+ raise "should not reach here: unexpected type: #{type}"
54
+ end
55
+ end
56
+ translated_text
57
+ end
58
+
59
+ private
60
+ def parse(&block)
61
+ paragraph = ''
62
+ paragraph_start_line = 0
63
+ line_no = 0
64
+
65
+ each_line(@raw) do |line|
66
+ line_no += 1
67
+ case line
68
+ when /\A\s*\z/
69
+ if paragraph.empty?
70
+ emit_empty_line_event(line, line_no, &block)
71
+ else
72
+ paragraph += line
73
+ emit_paragraph_event(paragraph, paragraph_start_line, line_no,
74
+ &block)
75
+ paragraph = ''
76
+ end
77
+ else
78
+ paragraph_start_line = line_no if paragraph.empty?
79
+ paragraph += line
80
+ end
81
+ end
82
+
83
+ unless paragraph.empty?
84
+ emit_paragraph_event(paragraph, paragraph_start_line, line_no, &block)
85
+ end
86
+ end
87
+
88
+ def each_line(raw, &block)
89
+ case raw
90
+ when RDoc::Comment
91
+ raw.text.each_line(&block)
92
+ when Hash
93
+ raw.each_value do |comments|
94
+ comments.each { |comment| each_line(comment, &block) }
95
+ end
96
+ else
97
+ raw.each_line(&block)
98
+ end
99
+ end
100
+
101
+ def emit_empty_line_event(line, line_no)
102
+ part = {
103
+ :type => :empty_line,
104
+ :line => line,
105
+ :line_no => line_no,
106
+ }
107
+ yield(part)
108
+ end
109
+
110
+ def emit_paragraph_event(paragraph, paragraph_start_line, line_no, &block)
111
+ paragraph_part = {
112
+ :type => :paragraph,
113
+ :line_no => paragraph_start_line,
114
+ }
115
+ match_data = /(\s*)\z/.match(paragraph)
116
+ if match_data
117
+ paragraph_part[:paragraph] = match_data.pre_match
118
+ yield(paragraph_part)
119
+ emit_empty_line_event(match_data[1], line_no, &block)
120
+ else
121
+ paragraph_part[:paragraph] = paragraph
122
+ yield(paragraph_part)
123
+ end
124
+ end
125
+
126
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # This module provides i18n related features.
4
+
5
+ module RDoc::I18n
6
+
7
+ autoload :Locale, "#{__dir__}/i18n/locale"
8
+ require_relative 'i18n/text'
9
+
10
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+ module RDoc
3
+
4
+ ##
5
+ # Ruby's built-in classes, modules and exceptions
6
+
7
+ KNOWN_CLASSES = {
8
+ "rb_cArray" => "Array",
9
+ "rb_cBasicObject" => "BasicObject",
10
+ "rb_cBignum" => "Bignum",
11
+ "rb_cClass" => "Class",
12
+ "rb_cData" => "Data",
13
+ "rb_cDir" => "Dir",
14
+ "rb_cEncoding" => "Encoding",
15
+ "rb_cFalseClass" => "FalseClass",
16
+ "rb_cFile" => "File",
17
+ "rb_cFixnum" => "Fixnum",
18
+ "rb_cFloat" => "Float",
19
+ "rb_cHash" => "Hash",
20
+ "rb_cIO" => "IO",
21
+ "rb_cInteger" => "Integer",
22
+ "rb_cModule" => "Module",
23
+ "rb_cNilClass" => "NilClass",
24
+ "rb_cNumeric" => "Numeric",
25
+ "rb_cObject" => "Object",
26
+ "rb_cProc" => "Proc",
27
+ "rb_cRange" => "Range",
28
+ "rb_cRefinement" => "Refinement",
29
+ "rb_cRegexp" => "Regexp",
30
+ "rb_cRubyVM" => "RubyVM",
31
+ "rb_cSocket" => "Socket",
32
+ "rb_cString" => "String",
33
+ "rb_cStruct" => "Struct",
34
+ "rb_cSymbol" => "Symbol",
35
+ "rb_cThread" => "Thread",
36
+ "rb_cTime" => "Time",
37
+ "rb_cTrueClass" => "TrueClass",
38
+
39
+ "rb_eArgError" => "ArgumentError",
40
+ "rb_eEOFError" => "EOFError",
41
+ "rb_eException" => "Exception",
42
+ "rb_eFatal" => "fatal",
43
+ "rb_eFloatDomainError" => "FloatDomainError",
44
+ "rb_eIOError" => "IOError",
45
+ "rb_eIndexError" => "IndexError",
46
+ "rb_eInterrupt" => "Interrupt",
47
+ "rb_eLoadError" => "LoadError",
48
+ "rb_eNameError" => "NameError",
49
+ "rb_eNoMemError" => "NoMemoryError",
50
+ "rb_eNotImpError" => "NotImplementedError",
51
+ "rb_eRangeError" => "RangeError",
52
+ "rb_eRuntimeError" => "RuntimeError",
53
+ "rb_eScriptError" => "ScriptError",
54
+ "rb_eSecurityError" => "SecurityError",
55
+ "rb_eSignal" => "SignalException",
56
+ "rb_eStandardError" => "StandardError",
57
+ "rb_eSyntaxError" => "SyntaxError",
58
+ "rb_eSystemCallError" => "SystemCallError",
59
+ "rb_eSystemExit" => "SystemExit",
60
+ "rb_eTypeError" => "TypeError",
61
+ "rb_eZeroDivError" => "ZeroDivisionError",
62
+
63
+ "rb_mComparable" => "Comparable",
64
+ "rb_mEnumerable" => "Enumerable",
65
+ "rb_mErrno" => "Errno",
66
+ "rb_mFConst" => "File::Constants",
67
+ "rb_mFileTest" => "FileTest",
68
+ "rb_mGC" => "GC",
69
+ "rb_mKernel" => "Kernel",
70
+ "rb_mMath" => "Math",
71
+ "rb_mProcess" => "Process"
72
+ }
73
+
74
+ end