rdoc 3.9.5 → 3.10.pre.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (183) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +6 -3
  3. data/History.txt +63 -13
  4. data/LICENSE.rdoc +57 -0
  5. data/Manifest.txt +60 -6
  6. data/Rakefile +24 -12
  7. data/TODO.rdoc +30 -0
  8. data/bin/rdoc +0 -2
  9. data/lib/rdoc.rb +55 -2
  10. data/lib/rdoc/alias.rb +0 -2
  11. data/lib/rdoc/anon_class.rb +0 -2
  12. data/lib/rdoc/any_method.rb +0 -3
  13. data/lib/rdoc/attr.rb +0 -2
  14. data/lib/rdoc/class_module.rb +40 -7
  15. data/lib/rdoc/code_object.rb +1 -3
  16. data/lib/rdoc/code_objects.rb +3 -21
  17. data/lib/rdoc/comment.rb +225 -0
  18. data/lib/rdoc/constant.rb +0 -2
  19. data/lib/rdoc/context.rb +37 -120
  20. data/lib/rdoc/context/section.rb +114 -0
  21. data/lib/rdoc/cross_reference.rb +16 -7
  22. data/lib/rdoc/encoding.rb +0 -2
  23. data/lib/rdoc/gauntlet.rb +1 -1
  24. data/lib/rdoc/generator.rb +7 -2
  25. data/lib/rdoc/generator/darkfish.rb +126 -20
  26. data/lib/rdoc/generator/json_index.rb +240 -0
  27. data/lib/rdoc/generator/markup.rb +17 -54
  28. data/lib/rdoc/generator/ri.rb +0 -3
  29. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  30. data/lib/rdoc/generator/template/darkfish/_head.rhtml +16 -0
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +18 -0
  32. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +8 -0
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +16 -0
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +7 -0
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +10 -0
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +10 -0
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +10 -0
  41. data/lib/rdoc/generator/template/darkfish/class.rhtml +161 -0
  42. data/lib/rdoc/generator/template/darkfish/fileinfo.rhtml +32 -0
  43. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  44. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  45. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  46. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  47. data/lib/rdoc/generator/template/darkfish/index.rhtml +16 -61
  48. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +99 -64
  49. data/lib/rdoc/generator/template/darkfish/js/jquery.js +15 -29
  50. data/lib/rdoc/generator/template/darkfish/js/search.js +94 -0
  51. data/lib/rdoc/generator/template/darkfish/page.rhtml +16 -0
  52. data/lib/rdoc/generator/template/darkfish/rdoc.css +126 -286
  53. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +50 -0
  54. data/lib/rdoc/generator/template/json_index/js/navigation.js +142 -0
  55. data/lib/rdoc/generator/template/json_index/js/searcher.js +228 -0
  56. data/lib/rdoc/ghost_method.rb +0 -2
  57. data/lib/rdoc/include.rb +0 -2
  58. data/lib/rdoc/markup.rb +204 -43
  59. data/lib/rdoc/markup/attr_changer.rb +25 -0
  60. data/lib/rdoc/markup/attr_span.rb +29 -0
  61. data/lib/rdoc/markup/attribute.rb +51 -0
  62. data/lib/rdoc/markup/document.rb +22 -1
  63. data/lib/rdoc/markup/formatter.rb +4 -11
  64. data/lib/rdoc/markup/formatter_test_case.rb +1 -2
  65. data/lib/rdoc/markup/heading.rb +44 -0
  66. data/lib/rdoc/markup/include.rb +42 -0
  67. data/lib/rdoc/markup/inline.rb +1 -144
  68. data/lib/rdoc/markup/list.rb +2 -1
  69. data/lib/rdoc/markup/parser.rb +6 -16
  70. data/lib/rdoc/markup/pre_process.rb +64 -10
  71. data/lib/rdoc/markup/raw.rb +1 -1
  72. data/lib/rdoc/markup/special.rb +40 -0
  73. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -2
  74. data/lib/rdoc/markup/to_ansi.rb +0 -2
  75. data/lib/rdoc/markup/to_bs.rb +0 -2
  76. data/lib/rdoc/markup/to_html.rb +102 -34
  77. data/lib/rdoc/markup/to_html_crossref.rb +36 -5
  78. data/lib/rdoc/markup/to_html_snippet.rb +270 -0
  79. data/lib/rdoc/markup/to_label.rb +55 -0
  80. data/lib/rdoc/markup/to_rdoc.rb +0 -3
  81. data/lib/rdoc/markup/to_table_of_contents.rb +62 -0
  82. data/lib/rdoc/markup/to_test.rb +0 -3
  83. data/lib/rdoc/markup/to_tt_only.rb +0 -3
  84. data/lib/rdoc/markup/verbatim.rb +18 -0
  85. data/lib/rdoc/meta_method.rb +0 -2
  86. data/lib/rdoc/method_attr.rb +17 -1
  87. data/lib/rdoc/normal_class.rb +0 -2
  88. data/lib/rdoc/normal_module.rb +0 -2
  89. data/lib/rdoc/options.rb +18 -3
  90. data/lib/rdoc/parser.rb +74 -42
  91. data/lib/rdoc/parser/c.rb +79 -118
  92. data/lib/rdoc/parser/rd.rb +22 -0
  93. data/lib/rdoc/parser/ruby.rb +86 -54
  94. data/lib/rdoc/parser/simple.rb +21 -9
  95. data/lib/rdoc/parser/text.rb +11 -0
  96. data/lib/rdoc/rd.rb +95 -0
  97. data/lib/rdoc/rd/block_parser.ry +638 -0
  98. data/lib/rdoc/rd/inline.rb +71 -0
  99. data/lib/rdoc/rd/inline_parser.ry +575 -0
  100. data/lib/rdoc/rdoc.rb +8 -23
  101. data/lib/rdoc/require.rb +0 -2
  102. data/lib/rdoc/ri.rb +4 -2
  103. data/lib/rdoc/ri/driver.rb +2 -6
  104. data/lib/rdoc/ri/store.rb +0 -1
  105. data/lib/rdoc/ruby_lex.rb +43 -20
  106. data/lib/rdoc/ruby_token.rb +44 -2
  107. data/lib/rdoc/single_class.rb +0 -2
  108. data/lib/rdoc/stats.rb +0 -5
  109. data/lib/rdoc/task.rb +2 -6
  110. data/lib/rdoc/test_case.rb +59 -0
  111. data/lib/rdoc/text.rb +42 -30
  112. data/lib/rdoc/token_stream.rb +45 -0
  113. data/lib/rdoc/tom_doc.rb +232 -0
  114. data/lib/rdoc/top_level.rb +36 -4
  115. data/test/test_attribute_manager.rb +26 -29
  116. data/test/test_rdoc_any_method.rb +2 -26
  117. data/test/test_rdoc_attr.rb +4 -4
  118. data/test/test_rdoc_class_module.rb +95 -12
  119. data/test/test_rdoc_code_object.rb +10 -3
  120. data/test/test_rdoc_comment.rb +504 -0
  121. data/test/test_rdoc_context.rb +60 -11
  122. data/test/test_rdoc_context_section.rb +16 -17
  123. data/test/test_rdoc_cross_reference.rb +17 -2
  124. data/test/test_rdoc_encoding.rb +4 -7
  125. data/test/test_rdoc_generator_darkfish.rb +12 -11
  126. data/test/test_rdoc_generator_json_index.rb +255 -0
  127. data/test/test_rdoc_generator_markup.rb +56 -0
  128. data/test/test_rdoc_generator_ri.rb +8 -11
  129. data/test/test_rdoc_markup.rb +9 -5
  130. data/test/test_rdoc_markup_attribute_manager.rb +5 -8
  131. data/test/test_rdoc_markup_document.rb +34 -6
  132. data/test/test_rdoc_markup_formatter.rb +11 -13
  133. data/test/test_rdoc_markup_heading.rb +20 -0
  134. data/test/test_rdoc_markup_include.rb +19 -0
  135. data/test/test_rdoc_markup_indented_paragraph.rb +4 -5
  136. data/test/test_rdoc_markup_paragraph.rb +2 -5
  137. data/test/test_rdoc_markup_parser.rb +87 -7
  138. data/test/test_rdoc_markup_pre_process.rb +60 -9
  139. data/test/test_rdoc_markup_raw.rb +4 -6
  140. data/test/test_rdoc_markup_to_ansi.rb +1 -4
  141. data/test/test_rdoc_markup_to_bs.rb +1 -4
  142. data/test/test_rdoc_markup_to_html.rb +170 -31
  143. data/test/test_rdoc_markup_to_html_crossref.rb +89 -11
  144. data/test/test_rdoc_markup_to_html_snippet.rb +668 -0
  145. data/test/test_rdoc_markup_to_label.rb +50 -0
  146. data/test/test_rdoc_markup_to_rdoc.rb +1 -4
  147. data/test/test_rdoc_markup_to_table_of_contents.rb +90 -0
  148. data/test/test_rdoc_markup_to_tt_only.rb +1 -4
  149. data/test/test_rdoc_markup_verbatim.rb +16 -0
  150. data/test/test_rdoc_method_attr.rb +16 -1
  151. data/test/test_rdoc_options.rb +17 -7
  152. data/test/test_rdoc_parser.rb +75 -6
  153. data/test/test_rdoc_parser_c.rb +56 -104
  154. data/test/test_rdoc_parser_rd.rb +52 -0
  155. data/test/test_rdoc_parser_ruby.rb +264 -323
  156. data/test/test_rdoc_parser_simple.rb +33 -17
  157. data/test/test_rdoc_rd.rb +30 -0
  158. data/test/test_rdoc_rd_block_parser.rb +527 -0
  159. data/test/test_rdoc_rd_inline.rb +63 -0
  160. data/test/test_rdoc_rd_inline_parser.rb +173 -0
  161. data/test/test_rdoc_rdoc.rb +7 -9
  162. data/test/test_rdoc_ri_driver.rb +10 -15
  163. data/test/test_rdoc_ri_paths.rb +6 -6
  164. data/test/test_rdoc_ri_store.rb +6 -13
  165. data/test/test_rdoc_ruby_lex.rb +53 -5
  166. data/test/test_rdoc_rubygems_hook.rb +2 -1
  167. data/test/test_rdoc_stats.rb +83 -103
  168. data/test/test_rdoc_task.rb +5 -4
  169. data/test/test_rdoc_text.rb +156 -11
  170. data/test/test_rdoc_token_stream.rb +42 -0
  171. data/test/test_rdoc_tom_doc.rb +458 -0
  172. data/test/test_rdoc_top_level.rb +49 -2
  173. data/test/xref_test_case.rb +4 -8
  174. metadata +217 -111
  175. metadata.gz.sig +0 -0
  176. checksums.yaml +0 -7
  177. checksums.yaml.gz.sig +0 -0
  178. data/CVE-2013-0256.rdoc +0 -49
  179. data/LICENSE.txt +0 -57
  180. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -321
  181. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
  182. data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
  183. data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
@@ -0,0 +1,50 @@
1
+ <body class="indexpage">
2
+ <h1><%= h @title %></h1>
3
+
4
+ <% simple_files = @files.select { |f| f.text? } %>
5
+ <% unless simple_files.empty? then %>
6
+ <h2>Pages</h2>
7
+ <ul>
8
+ <% simple_files.sort.each do |file| %>
9
+ <li class="file">
10
+ <a href="<%= file.path %>"><%= h file.page_name %></a>
11
+ <% table = file.parse(file.comment).table_of_contents # HACK
12
+ unless table.empty? then %>
13
+ <img class="toc-toggle" src="images/transparent.png" alt="" title="toggle headings">
14
+ <ul class="initially-hidden">
15
+ <% table.each do |heading| %>
16
+ <li><a href="<%= file.path %>#<%= heading.label %>"><%= heading.plain_html %></a>
17
+ <% end %>
18
+ </ul>
19
+ <% end %>
20
+ </li>
21
+ <% end %>
22
+ </ul>
23
+ <% end %>
24
+
25
+ <h2 id="classes">Classes/Modules</h2>
26
+ <ul>
27
+ <% @modsort.each do |klass| %>
28
+ <li class="<%= klass.type %>">
29
+ <a href="<%= klass.path %>"><%= klass.full_name %></a>
30
+ <% table = klass.parse(klass.comment).table_of_contents # HACK
31
+ unless table.empty? then %>
32
+ <img class="toc-toggle" src="images/transparent.png" alt="" title="toggle headings">
33
+ <ul class="initially-hidden">
34
+ <% table.each do |heading| %>
35
+ <li><a href="<%= klass.path %>#<%= heading.label %>"><%= heading.plain_html %></a>
36
+ <% end %>
37
+ </ul>
38
+ <% end %>
39
+ </li>
40
+ <% end %>
41
+ </ul>
42
+
43
+ <h2 id="methods">Methods</h2>
44
+ <ul>
45
+ <% RDoc::TopLevel.all_classes_and_modules.map do |mod|
46
+ mod.method_list
47
+ end.flatten.sort.each do |method| %>
48
+ <li class="method"><a href="<%= method.path %>"><%= method.pretty_name %> &mdash; <%= method.parent.full_name %></a>
49
+ <% end %>
50
+ </ul>
@@ -0,0 +1,142 @@
1
+ /*
2
+ * Navigation allows movement using the arrow keys through the search results.
3
+ *
4
+ * When using this library you will need to set scrollIntoView to the
5
+ * appropriate function for your layout. Use scrollInWindow if the container
6
+ * is not scrollable and scrollInElement if the container is a separate
7
+ * scrolling region.
8
+ */
9
+ Navigation = new function() {
10
+ this.initNavigation = function() {
11
+ var _this = this;
12
+
13
+ $(document).keydown(function(e) {
14
+ _this.onkeydown(e);
15
+ }).keyup(function(e) {
16
+ _this.onkeyup(e);
17
+ });
18
+
19
+ this.navigationActive = true;
20
+ }
21
+
22
+ this.setNavigationActive = function(state) {
23
+ this.navigationActive = state;
24
+ this.clearMoveTimeout();
25
+ }
26
+
27
+ this.onkeyup = function(e) {
28
+ if (!this.navigationActive) return;
29
+
30
+ switch(e.keyCode) {
31
+ case 37: //Event.KEY_LEFT:
32
+ case 38: //Event.KEY_UP:
33
+ case 39: //Event.KEY_RIGHT:
34
+ case 40: //Event.KEY_DOWN:
35
+ this.clearMoveTimeout();
36
+ break;
37
+ }
38
+ }
39
+
40
+ this.onkeydown = function(e) {
41
+ if (!this.navigationActive) return;
42
+ switch(e.keyCode) {
43
+ case 37: //Event.KEY_LEFT:
44
+ if (this.moveLeft()) e.preventDefault();
45
+ break;
46
+ case 38: //Event.KEY_UP:
47
+ if (e.keyCode == 38 || e.ctrlKey) {
48
+ if (this.moveUp()) e.preventDefault();
49
+ this.startMoveTimeout(false);
50
+ }
51
+ break;
52
+ case 39: //Event.KEY_RIGHT:
53
+ if (this.moveRight()) e.preventDefault();
54
+ break;
55
+ case 40: //Event.KEY_DOWN:
56
+ if (e.keyCode == 40 || e.ctrlKey) {
57
+ if (this.moveDown()) e.preventDefault();
58
+ this.startMoveTimeout(true);
59
+ }
60
+ break;
61
+ case 13: //Event.KEY_RETURN:
62
+ if (this.$current)
63
+ e.preventDefault();
64
+ this.select(this.$current);
65
+ break;
66
+ }
67
+ if (e.ctrlKey && e.shiftKey) this.select(this.$current);
68
+ }
69
+
70
+ this.clearMoveTimeout = function() {
71
+ clearTimeout(this.moveTimeout);
72
+ this.moveTimeout = null;
73
+ }
74
+
75
+ this.startMoveTimeout = function(isDown) {
76
+ if (!$.browser.mozilla && !$.browser.opera) return;
77
+ if (this.moveTimeout) this.clearMoveTimeout();
78
+ var _this = this;
79
+
80
+ var go = function() {
81
+ if (!_this.moveTimeout) return;
82
+ _this[isDown ? 'moveDown' : 'moveUp']();
83
+ _this.moveTimout = setTimeout(go, 100);
84
+ }
85
+ this.moveTimeout = setTimeout(go, 200);
86
+ }
87
+
88
+ this.moveRight = function() {
89
+ }
90
+
91
+ this.moveLeft = function() {
92
+ }
93
+
94
+ this.move = function(isDown) {
95
+ }
96
+
97
+ this.moveUp = function() {
98
+ return this.move(false);
99
+ }
100
+
101
+ this.moveDown = function() {
102
+ return this.move(true);
103
+ }
104
+
105
+ /*
106
+ * Scrolls to the given element in the scrollable element view.
107
+ */
108
+ this.scrollInElement = function(element, view) {
109
+ var offset, viewHeight, viewScroll, height;
110
+ offset = element.offsetTop;
111
+ height = element.offsetHeight;
112
+ viewHeight = view.offsetHeight;
113
+ viewScroll = view.scrollTop;
114
+
115
+ if (offset - viewScroll + height > viewHeight) {
116
+ view.scrollTop = offset - viewHeight + height;
117
+ }
118
+ if (offset < viewScroll) {
119
+ view.scrollTop = offset;
120
+ }
121
+ }
122
+
123
+ /*
124
+ * Scrolls to the given element in the window. The second argument is
125
+ * ignored
126
+ */
127
+ this.scrollInWindow = function(element, ignored) {
128
+ var offset, viewHeight, viewScroll, height;
129
+ offset = element.offsetTop;
130
+ height = element.offsetHeight;
131
+ viewHeight = window.innerHeight;
132
+ viewScroll = window.scrollY;
133
+
134
+ if (offset - viewScroll + height > viewHeight) {
135
+ window.scrollTo(window.scrollX, offset - viewHeight + height);
136
+ }
137
+ if (offset < viewScroll) {
138
+ window.scrollTo(window.scrollX, offset);
139
+ }
140
+ }
141
+ }
142
+
@@ -0,0 +1,228 @@
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 < 4);
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 jQuery.grep(query.split(/(\s+|::?|\(\)?)/), function(string) {
55
+ return string.match(/\S/)
56
+ });
57
+ }
58
+
59
+ function buildRegexps(queries) {
60
+ return jQuery.map(queries, function(query) {
61
+ return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i')
62
+ });
63
+ }
64
+
65
+ function buildHilighters(queries) {
66
+ return jQuery.map(queries, function(query) {
67
+ return jQuery.map(query.split(''), function(l, i) {
68
+ return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2);
69
+ }).join('');
70
+ });
71
+ }
72
+
73
+ // function longMatchRegexp(index, longIndex, regexps) {
74
+ // for (var i = regexps.length - 1; i >= 0; i--){
75
+ // if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
76
+ // };
77
+ // return true;
78
+ // }
79
+
80
+
81
+ /* ----- Mathchers ------ */
82
+
83
+ /*
84
+ * This record matches if the index starts with queries[0] and the record
85
+ * matches all of the regexps
86
+ */
87
+ function matchPassBeginning(index, longIndex, queries, regexps) {
88
+ if (index.indexOf(queries[0]) != 0) return false;
89
+ for (var i=1, l = regexps.length; i < l; i++) {
90
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
91
+ return false;
92
+ };
93
+ return true;
94
+ }
95
+
96
+ /*
97
+ * This record matches if the longIndex starts with queries[0] and the
98
+ * longIndex matches all of the regexps
99
+ */
100
+ function matchPassLongIndex(index, longIndex, queries, regexps) {
101
+ if (longIndex.indexOf(queries[0]) != 0) return false;
102
+ for (var i=1, l = regexps.length; i < l; i++) {
103
+ if (!longIndex.match(regexps[i]))
104
+ return false;
105
+ };
106
+ return true;
107
+ }
108
+
109
+ /*
110
+ * This record matches if the index contains queries[0] and the record
111
+ * matches all of the regexps
112
+ */
113
+ function matchPassContains(index, longIndex, queries, regexps) {
114
+ if (index.indexOf(queries[0]) == -1) return false;
115
+ for (var i=1, l = regexps.length; i < l; i++) {
116
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
117
+ return false;
118
+ };
119
+ return true;
120
+ }
121
+
122
+ /*
123
+ * This record matches if regexps[0] matches the index and the record
124
+ * matches all of the regexps
125
+ */
126
+ function matchPassRegexp(index, longIndex, queries, regexps) {
127
+ if (!index.match(regexps[0])) return false;
128
+ for (var i=1, l = regexps.length; i < l; i++) {
129
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
130
+ return false;
131
+ };
132
+ return true;
133
+ }
134
+
135
+
136
+ /* ----- Highlighters ------ */
137
+ function highlightRegexp(info, queries, regexps, highlighters) {
138
+ var result = createResult(info);
139
+ for (var i=0, l = regexps.length; i < l; i++) {
140
+ result.title = result.title.replace(regexps[i], highlighters[i]);
141
+ result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
142
+ };
143
+ return result;
144
+ }
145
+
146
+ function hltSubstring(string, pos, length) {
147
+ return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
148
+ }
149
+
150
+ function highlightQuery(info, queries, regexps, highlighters) {
151
+ var result = createResult(info);
152
+ var pos = 0;
153
+ var lcTitle = result.title.toLowerCase();
154
+
155
+ pos = lcTitle.indexOf(queries[0]);
156
+ if (pos != -1) {
157
+ result.title = hltSubstring(result.title, pos, queries[0].length);
158
+ }
159
+
160
+ result.namespace = result.namespace.replace(regexps[0], highlighters[0]);
161
+ for (var i=1, l = regexps.length; i < l; i++) {
162
+ result.title = result.title.replace(regexps[i], highlighters[i]);
163
+ result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
164
+ };
165
+ return result;
166
+ }
167
+
168
+ function createResult(info) {
169
+ var result = {};
170
+ result.title = info[0];
171
+ result.namespace = info[1];
172
+ result.path = info[2];
173
+ result.params = info[3];
174
+ result.snippet = info[4];
175
+ return result;
176
+ }
177
+
178
+ /* ----- Searching ------ */
179
+ function performSearch(data, regexps, queries, highlighters, state) {
180
+ var searchIndex = data.searchIndex;
181
+ var longSearchIndex = data.longSearchIndex;
182
+ var info = data.info;
183
+ var result = [];
184
+ var i = state.from;
185
+ var l = searchIndex.length;
186
+ var togo = CHUNK_SIZE;
187
+ var matchFunc, hltFunc;
188
+
189
+ while (state.pass < 4 && state.limit > 0 && togo > 0) {
190
+ if (state.pass == 0) {
191
+ matchFunc = matchPassBeginning;
192
+ hltFunc = highlightQuery;
193
+ } else if (state.pass == 1) {
194
+ matchFunc = matchPassLongIndex;
195
+ hltFunc = highlightQuery;
196
+ } else if (state.pass == 2) {
197
+ matchFunc = matchPassContains;
198
+ hltFunc = highlightQuery;
199
+ } else if (state.pass == 3) {
200
+ matchFunc = matchPassRegexp;
201
+ hltFunc = highlightRegexp;
202
+ }
203
+
204
+ for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
205
+ if (info[i].n == state.n) continue;
206
+ if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
207
+ info[i].n = state.n;
208
+ result.push(hltFunc(info[i], queries, regexps, highlighters));
209
+ state.limit--;
210
+ }
211
+ };
212
+ if (searchIndex.length <= i) {
213
+ state.pass++;
214
+ i = state.from = 0;
215
+ } else {
216
+ state.from = i;
217
+ }
218
+ }
219
+ return result;
220
+ }
221
+
222
+ function triggerResults(results, isLast) {
223
+ jQuery.each(this.handlers, function(i, fn) {
224
+ fn.call(this, results, isLast)
225
+ })
226
+ }
227
+ }
228
+
@@ -1,5 +1,3 @@
1
- require 'rdoc/any_method'
2
-
3
1
  ##
4
2
  # GhostMethod represents a method referenced only by a comment
5
3
 
@@ -1,5 +1,3 @@
1
- require 'rdoc/code_object'
2
-
3
1
  ##
4
2
  # A Module include in a class with \#include
5
3
 
@@ -1,5 +1,3 @@
1
- require 'rdoc'
2
-
3
1
  ##
4
2
  # RDoc::Markup parses plain text documents and attempts to decompose them into
5
3
  # their constituent parts. Some of these parts are high-level: paragraphs,
@@ -26,7 +24,7 @@ require 'rdoc'
26
24
  # the +convert+ method, so you can use the same RDoc::Markup converter to
27
25
  # convert multiple input strings.
28
26
  #
29
- # require 'rdoc/markup/to_html'
27
+ # require 'rdoc'
30
28
  #
31
29
  # h = RDoc::Markup::ToHtml.new
32
30
  #
@@ -39,8 +37,7 @@ require 'rdoc'
39
37
  # strike-through text. We then subclass the HTML output class to deal
40
38
  # with these:
41
39
  #
42
- # require 'rdoc/markup'
43
- # require 'rdoc/markup/to_html'
40
+ # require 'rdoc'
44
41
  #
45
42
  # class WikiHtml < RDoc::Markup::ToHtml
46
43
  # def handle_special_WIKIWORD(special)
@@ -96,7 +93,12 @@ require 'rdoc'
96
93
  # have been removed. In addition, the verbatim text has been shifted
97
94
  # left, so the amount of indentation of verbatim text is unimportant.
98
95
  #
99
- # === Headers and Rules
96
+ # For HTML output RDoc makes a small effort to determine if a verbatim section
97
+ # contains ruby source code. If so, the verbatim block will be marked up as
98
+ # HTML. Triggers include "def", "class", "module", "require", the "hash
99
+ # rocket"# (=>) or a block call with a parameter.
100
+ #
101
+ # === Headers
100
102
  #
101
103
  # A line starting with an equal sign (=) is treated as a
102
104
  # heading. Level one headings have one equals sign, level two headings
@@ -104,7 +106,36 @@ require 'rdoc'
104
106
  # (seven hyphens or more result in a level six heading).
105
107
  #
106
108
  # For example, the above header was obtained with:
107
- # == Headers and Rules
109
+ #
110
+ # === Headers
111
+ #
112
+ # In HTML output headers have an id matching their name. The above example's
113
+ # HTML is:
114
+ #
115
+ # <h3 id="label-Headers">Headers</h3>
116
+ #
117
+ # If a heading is inside a method body the id will be prefixed with the
118
+ # method's id. If the above header where in the documentation for a method
119
+ # such as:
120
+ #
121
+ # ##
122
+ # # This method does fun things
123
+ # #
124
+ # # = Example
125
+ # #
126
+ # # Example of fun things goes here ...
127
+ #
128
+ # def do_fun_things
129
+ # end
130
+ #
131
+ # The header's id would be:
132
+ #
133
+ # <h1 id="method-i-do_fun_things-label-Example">Example</h3>
134
+ #
135
+ # The label can be linked-to using <tt>SomeClass@Headers</tt>. See
136
+ # {Links}[RDoc::Markup@Links] for further details.
137
+ #
138
+ # === Rules
108
139
  #
109
140
  # A line starting with three or more hyphens (at the current indent)
110
141
  # generates a horizontal rule. The more hyphens, the thicker the rule
@@ -240,7 +271,6 @@ require 'rdoc'
240
271
  # verbatim text outside of the list (the list is therefore closed)
241
272
  # regular paragraph after the list
242
273
  #
243
- #
244
274
  # == Text Markup
245
275
  #
246
276
  # === Bold, Italic, Typewriter Text
@@ -272,15 +302,26 @@ require 'rdoc'
272
302
  # === Links
273
303
  #
274
304
  # Links to starting with +http:+, +https:+, +mailto:+, +ftp:+ or +www.+
275
- # are recognized. An HTTP url that references an external image file is
276
- # converted into an inline image element.
277
- #
278
- # Links starting with <tt>rdoc-ref:</tt> will link to the referenced class,
279
- # module, method, file, etc. If the referenced item is not documented the
280
- # text will be and no link will be generated.
281
- #
282
- # Links starting with +link:+ refer to local files whose path is relative to
283
- # the <tt>--op</tt> directory.
305
+ # are recognized. An HTTP url that references an external image is converted
306
+ # into an inline image element.
307
+ #
308
+ # Classes and methods will be automatically linked to their definition. For
309
+ # example, <tt>RDoc::Markup</tt> will link to this documentation. By default
310
+ # methods will only be automatically linked if they contain an <tt>_</tt> (all
311
+ # methods can be automatically linked through the <tt>--hyperlink-all</tt>
312
+ # command line option).
313
+ #
314
+ # Single-word methods can be linked by using the <tt>#</tt> character for
315
+ # instance methods or <tt>::</tt> for class methods. For example,
316
+ # <tt>#convert</tt> links to #convert. A class or method may be combined like
317
+ # <tt>RDoc::Markup#convert</tt>.
318
+ #
319
+ # A heading inside the documentation can be linked by following the class
320
+ # or method by an <tt>@</tt> then the heading name.
321
+ # <tt>RDoc::Markup@Links</tt> will link to this section like this:
322
+ # RDoc::Markup@Links. Spaces in headings with multiple words must be escaped
323
+ # with <tt>+</tt> like <tt>RDoc::Markup@Escaping+Text+Markup</tt>.
324
+ # Punctuation and other special characters must be escaped like CGI.escape.
284
325
  #
285
326
  # Links can also be of the form <tt>label[url]</tt>, in which case +label+ is
286
327
  # used in the displayed text, and +url+ is used as the target. If +label+
@@ -293,6 +334,11 @@ require 'rdoc'
293
334
  # no link will be generated and <tt>rdoc-ref:</tt> will be removed from the
294
335
  # resulting text.
295
336
  #
337
+ # Links starting with <tt>rdoc-label:label_name</tt> will link to the
338
+ # +label_name+. You can create a label for the current link (for
339
+ # bidirectional links) by supplying a name for the current link like
340
+ # <tt>rdoc-label:label-other:label-mine</tt>.
341
+ #
296
342
  # Links starting with +link:+ refer to local files whose path is relative to
297
343
  # the <tt>--op</tt> directory. Use <tt>rdoc-ref:</tt> instead of
298
344
  # <tt>link:</tt> to link to files generated by RDoc as the link target may
@@ -492,27 +538,54 @@ require 'rdoc'
492
538
  # so you won't see the documentation unless you use the +-a+ command line
493
539
  # option.
494
540
  #
495
- # === Other directives
541
+ # === Method arguments
496
542
  #
497
- # [+:include:+ _filename_]
498
- # Include the contents of the named file at this point. This directive
499
- # must appear alone on one line, possibly preceded by spaces. In this
500
- # position, it can be escaped with a \ in front of the first colon.
543
+ # [+:arg:+ or +:args:+ _parameters_]
544
+ # Overrides the default argument handling with exactly these parameters.
501
545
  #
502
- # The file will be searched for in the directories listed by the +--include+
503
- # option, or in the current directory by default. The contents of the file
504
- # will be shifted to have the same indentation as the ':' at the start of
505
- # the +:include:+ directive.
546
+ # ##
547
+ # # :args: a, b
506
548
  #
507
- # [+:title:+ _text_]
508
- # Sets the title for the document. Equivalent to the <tt>--title</tt>
509
- # command line parameter. (The command line parameter overrides any :title:
510
- # directive in the source).
549
+ # def some_method(*a)
550
+ # end
511
551
  #
512
- # [+:main:+ _name_]
513
- # Equivalent to the <tt>--main</tt> command line parameter.
552
+ # [+:yield:+ or +:yields:+ _parameters_]
553
+ # Overrides the default yield discovery with these parameters.
554
+ #
555
+ # ##
556
+ # # :yields: key, value
557
+ #
558
+ # def each_thing &block
559
+ # @things.each(&block)
560
+ # end
561
+ #
562
+ # [+:call-seq:+]
563
+ # Lines up to the next blank line or lines with a common prefix in the
564
+ # comment are treated as the method's calling sequence, overriding the
565
+ # default parsing of method parameters and yield arguments.
566
+ #
567
+ # Multiple lines may be used.
568
+ #
569
+ # # :call-seq:
570
+ # # ARGF.readlines(sep=$/) -> array
571
+ # # ARGF.readlines(limit) -> array
572
+ # # ARGF.readlines(sep, limit) -> array
573
+ # #
574
+ # # ARGF.to_a(sep=$/) -> array
575
+ # # ARGF.to_a(limit) -> array
576
+ # # ARGF.to_a(sep, limit) -> array
577
+ # #
578
+ # # The remaining lines are documentation ...
579
+ #
580
+ # === Sections
514
581
  #
515
- # [<tt>:category: section</tt>]
582
+ # Sections allow you to group methods in a class into sensible containers. If
583
+ # you use the sections 'Public', 'Internal' and 'Deprecated' (the three
584
+ # allowed method statuses from TomDoc) the sections will be displayed in that
585
+ # order placing the most useful methods at the top. Otherwise, sections will
586
+ # be displayed in alphabetical order.
587
+ #
588
+ # [+:category:+ _section_]
516
589
  # Adds this item to the named +section+ overriding the current section. Use
517
590
  # this to group methods by section in RDoc output while maintaining a
518
591
  # sensible ordering (like alphabetical).
@@ -541,7 +614,7 @@ require 'rdoc'
541
614
  # Use the :section: directive to provide introductory text for a section of
542
615
  # documentation.
543
616
  #
544
- # [<tt>:section: title</tt>]
617
+ # [+:section:+ _title_]
545
618
  # Provides section introductory text in RDoc output. The title following
546
619
  # +:section:+ is used as the section name and the remainder of the comment
547
620
  # containing the section is used as introductory text. A section's comment
@@ -573,12 +646,37 @@ require 'rdoc'
573
646
  # # ...
574
647
  # end
575
648
  #
576
- # [+:call-seq:+]
577
- # Lines up to the next blank line in the comment are treated as the method's
578
- # calling sequence, overriding the default parsing of method parameters and
579
- # yield arguments.
649
+ # === Other directives
650
+ #
651
+ # [+:markup:+ _type_]
652
+ # Overrides the default markup type for this comment with the specified
653
+ # markup type. For ruby files, if the first comment contains this directive
654
+ # it is applied automatically to all comments in the file.
655
+ #
656
+ # To add additional markup types to RDoc, add the type's name and parsing
657
+ # class to RDoc::Text::MARKUP_FORMAT. The parsing class must respond to
658
+ # \::parse and accept a String argument.
659
+ #
660
+ # The parsing class must return an RDoc::Document.
661
+ #
662
+ # [+:include:+ _filename_]
663
+ # Include the contents of the named file at this point. This directive
664
+ # must appear alone on one line, possibly preceded by spaces. In this
665
+ # position, it can be escaped with a \ in front of the first colon.
666
+ #
667
+ # The file will be searched for in the directories listed by the +--include+
668
+ # option, or in the current directory by default. The contents of the file
669
+ # will be shifted to have the same indentation as the ':' at the start of
670
+ # the +:include:+ directive.
671
+ #
672
+ # [+:title:+ _text_]
673
+ # Sets the title for the document. Equivalent to the <tt>--title</tt>
674
+ # command line parameter. (The command line parameter overrides any :title:
675
+ # directive in the source).
676
+ #
677
+ # [+:main:+ _name_]
678
+ # Equivalent to the <tt>--main</tt> command line parameter.
580
679
  #
581
- # Further directives can be found in RDoc::Parser::Ruby and RDoc::Parser::C.
582
680
  #--
583
681
  # Original Author:: Dave Thomas, dave@pragmaticprogrammer.com
584
682
  # License:: Ruby license
@@ -590,6 +688,34 @@ class RDoc::Markup
590
688
 
591
689
  attr_reader :attribute_manager
592
690
 
691
+ ##
692
+ # Parses +str+ into an RDoc::Markup::Document.
693
+
694
+ def self.parse str
695
+ RDoc::Markup::Parser.parse str
696
+ rescue RDoc::Markup::Parser::Error => e
697
+ $stderr.puts <<-EOF
698
+ While parsing markup, RDoc encountered a #{e.class}:
699
+
700
+ #{e}
701
+ \tfrom #{e.backtrace.join "\n\tfrom "}
702
+
703
+ ---8<---
704
+ #{text}
705
+ ---8<---
706
+
707
+ RDoc #{RDoc::VERSION}
708
+
709
+ Ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} #{RUBY_RELEASE_DATE}
710
+
711
+ Please file a bug report with the above information at:
712
+
713
+ https://github.com/rdoc/rdoc/issues
714
+
715
+ EOF
716
+ raise
717
+ end
718
+
593
719
  ##
594
720
  # Take a block of text and use various heuristics to determine its
595
721
  # structure (paragraphs, lists, and so on). Invoke an event handler as we
@@ -644,9 +770,44 @@ class RDoc::Markup
644
770
  document.accept formatter
645
771
  end
646
772
 
647
- end
773
+ autoload :Parser, 'rdoc/markup/parser'
774
+ autoload :PreProcess, 'rdoc/markup/pre_process'
648
775
 
649
- require 'rdoc/markup/parser'
650
- require 'rdoc/markup/attribute_manager'
651
- require 'rdoc/markup/inline'
776
+ # Inline markup classes
777
+ autoload :AttrChanger, 'rdoc/markup/attr_changer'
778
+ autoload :AttrSpan, 'rdoc/markup/attr_span'
779
+ autoload :Attribute, 'rdoc/markup/attribute'
780
+ autoload :AttributeManager, 'rdoc/markup/attribute_manager'
781
+ autoload :Special, 'rdoc/markup/special'
782
+
783
+ # RDoc::Markup AST
784
+ autoload :BlankLine, 'rdoc/markup/blank_line'
785
+ autoload :Document, 'rdoc/markup/document'
786
+ autoload :Heading, 'rdoc/markup/heading'
787
+ autoload :Include, 'rdoc/markup/include'
788
+ autoload :IndentedParagraph, 'rdoc/markup/indented_paragraph'
789
+ autoload :List, 'rdoc/markup/list'
790
+ autoload :ListItem, 'rdoc/markup/list_item'
791
+ autoload :Paragraph, 'rdoc/markup/paragraph'
792
+ autoload :Raw, 'rdoc/markup/raw'
793
+ autoload :Rule, 'rdoc/markup/rule'
794
+ autoload :Verbatim, 'rdoc/markup/verbatim'
795
+
796
+ # Formatters
797
+ autoload :Formatter, 'rdoc/markup/formatter'
798
+ autoload :FormatterTestCase, 'rdoc/markup/formatter_test_case'
799
+ autoload :TextFormatterTestCase, 'rdoc/markup/text_formatter_test_case'
800
+
801
+ autoload :ToAnsi, 'rdoc/markup/to_ansi'
802
+ autoload :ToBs, 'rdoc/markup/to_bs'
803
+ autoload :ToHtml, 'rdoc/markup/to_html'
804
+ autoload :ToHtmlCrossref, 'rdoc/markup/to_html_crossref'
805
+ autoload :ToHtmlSnippet, 'rdoc/markup/to_html_snippet'
806
+ autoload :ToLabel, 'rdoc/markup/to_label'
807
+ autoload :ToRdoc, 'rdoc/markup/to_rdoc'
808
+ autoload :ToTableOfContents, 'rdoc/markup/to_table_of_contents'
809
+ autoload :ToTest, 'rdoc/markup/to_test'
810
+ autoload :ToTtOnly, 'rdoc/markup/to_tt_only'
811
+
812
+ end
652
813