rdoc 6.3.3 → 6.6.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.rdoc +1 -2
  3. data/LEGAL.rdoc +1 -1
  4. data/README.rdoc +2 -2
  5. data/TODO.rdoc +1 -1
  6. data/exe/rdoc +0 -1
  7. data/lib/rdoc/alias.rb +0 -1
  8. data/lib/rdoc/anon_class.rb +0 -1
  9. data/lib/rdoc/any_method.rb +21 -3
  10. data/lib/rdoc/attr.rb +0 -1
  11. data/lib/rdoc/class_module.rb +0 -1
  12. data/lib/rdoc/code_objects.rb +1 -2
  13. data/lib/rdoc/comment.rb +20 -41
  14. data/lib/rdoc/constant.rb +0 -1
  15. data/lib/rdoc/context/section.rb +2 -1
  16. data/lib/rdoc/context.rb +1 -3
  17. data/lib/rdoc/cross_reference.rb +45 -19
  18. data/lib/rdoc/encoding.rb +1 -17
  19. data/lib/rdoc/erb_partial.rb +0 -1
  20. data/lib/rdoc/erbio.rb +2 -7
  21. data/lib/rdoc/extend.rb +0 -1
  22. data/lib/rdoc/generator/darkfish.rb +4 -8
  23. data/lib/rdoc/generator/json_index.rb +2 -2
  24. data/lib/rdoc/generator/markup.rb +1 -2
  25. data/lib/rdoc/generator/pot.rb +1 -0
  26. data/lib/rdoc/generator/ri.rb +0 -1
  27. data/lib/rdoc/generator/template/darkfish/_head.rhtml +11 -13
  28. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +27 -3
  29. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +22 -2
  30. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -1
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +25 -4
  32. data/lib/rdoc/generator/template/darkfish/class.rhtml +28 -20
  33. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +55 -7
  34. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  35. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  36. data/lib/rdoc/generator/template/darkfish/index.rhtml +1 -1
  37. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +14 -1
  38. data/lib/rdoc/generator/template/darkfish/js/search.js +4 -4
  39. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +7 -6
  40. data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
  41. data/lib/rdoc/generator.rb +5 -5
  42. data/lib/rdoc/ghost_method.rb +0 -1
  43. data/lib/rdoc/i18n.rb +1 -1
  44. data/lib/rdoc/include.rb +0 -1
  45. data/lib/rdoc/known_classes.rb +5 -4
  46. data/lib/rdoc/markdown/entities.rb +0 -1
  47. data/lib/rdoc/markdown/literals.kpeg +0 -2
  48. data/lib/rdoc/markdown/literals.rb +73 -35
  49. data/lib/rdoc/markdown.kpeg +26 -19
  50. data/lib/rdoc/markdown.rb +326 -227
  51. data/lib/rdoc/markup/attr_changer.rb +0 -1
  52. data/lib/rdoc/markup/attr_span.rb +0 -1
  53. data/lib/rdoc/markup/attribute_manager.rb +32 -36
  54. data/lib/rdoc/markup/attributes.rb +0 -1
  55. data/lib/rdoc/markup/blank_line.rb +0 -1
  56. data/lib/rdoc/markup/block_quote.rb +0 -1
  57. data/lib/rdoc/markup/document.rb +0 -1
  58. data/lib/rdoc/markup/formatter.rb +1 -2
  59. data/lib/rdoc/markup/hard_break.rb +0 -1
  60. data/lib/rdoc/markup/heading.rb +0 -1
  61. data/lib/rdoc/markup/include.rb +0 -1
  62. data/lib/rdoc/markup/indented_paragraph.rb +0 -1
  63. data/lib/rdoc/markup/list.rb +0 -1
  64. data/lib/rdoc/markup/list_item.rb +0 -1
  65. data/lib/rdoc/markup/paragraph.rb +0 -1
  66. data/lib/rdoc/markup/parser.rb +17 -7
  67. data/lib/rdoc/markup/pre_process.rb +2 -0
  68. data/lib/rdoc/markup/raw.rb +0 -1
  69. data/lib/rdoc/markup/regexp_handling.rb +0 -1
  70. data/lib/rdoc/markup/rule.rb +0 -1
  71. data/lib/rdoc/markup/table.rb +11 -2
  72. data/lib/rdoc/markup/to_ansi.rb +0 -1
  73. data/lib/rdoc/markup/to_html.rb +27 -19
  74. data/lib/rdoc/markup/to_html_crossref.rb +1 -1
  75. data/lib/rdoc/markup/to_html_snippet.rb +3 -1
  76. data/lib/rdoc/markup/to_joined_paragraph.rb +2 -3
  77. data/lib/rdoc/markup/to_label.rb +1 -2
  78. data/lib/rdoc/markup/to_markdown.rb +0 -1
  79. data/lib/rdoc/markup/to_rdoc.rb +3 -21
  80. data/lib/rdoc/markup/to_table_of_contents.rb +0 -1
  81. data/lib/rdoc/markup/to_test.rb +0 -1
  82. data/lib/rdoc/markup/to_tt_only.rb +0 -1
  83. data/lib/rdoc/markup/verbatim.rb +0 -1
  84. data/lib/rdoc/markup.rb +35 -667
  85. data/lib/rdoc/meta_method.rb +0 -1
  86. data/lib/rdoc/method_attr.rb +1 -2
  87. data/lib/rdoc/mixin.rb +0 -1
  88. data/lib/rdoc/normal_class.rb +1 -2
  89. data/lib/rdoc/normal_module.rb +1 -2
  90. data/lib/rdoc/options.rb +66 -21
  91. data/lib/rdoc/parser/c.rb +125 -124
  92. data/lib/rdoc/parser/changelog.rb +15 -1
  93. data/lib/rdoc/parser/markdown.rb +0 -2
  94. data/lib/rdoc/parser/rd.rb +0 -1
  95. data/lib/rdoc/parser/ripper_state_lex.rb +11 -1
  96. data/lib/rdoc/parser/ruby.rb +50 -14
  97. data/lib/rdoc/parser/ruby_tools.rb +0 -2
  98. data/lib/rdoc/parser/text.rb +0 -1
  99. data/lib/rdoc/parser.rb +19 -2
  100. data/lib/rdoc/rd/block_parser.rb +666 -12
  101. data/lib/rdoc/rd/block_parser.ry +13 -9
  102. data/lib/rdoc/rd/inline.rb +0 -1
  103. data/lib/rdoc/rd/inline_parser.rb +653 -3
  104. data/lib/rdoc/rd.rb +3 -4
  105. data/lib/rdoc/rdoc.rb +21 -37
  106. data/lib/rdoc/require.rb +0 -1
  107. data/lib/rdoc/ri/driver.rb +31 -90
  108. data/lib/rdoc/ri/store.rb +0 -1
  109. data/lib/rdoc/ri.rb +4 -5
  110. data/lib/rdoc/rubygems_hook.rb +4 -2
  111. data/lib/rdoc/servlet.rb +1 -1
  112. data/lib/rdoc/single_class.rb +5 -1
  113. data/lib/rdoc/stats/quiet.rb +0 -1
  114. data/lib/rdoc/stats/verbose.rb +0 -2
  115. data/lib/rdoc/stats.rb +3 -4
  116. data/lib/rdoc/store.rb +29 -19
  117. data/lib/rdoc/task.rb +31 -5
  118. data/lib/rdoc/text.rb +22 -4
  119. data/lib/rdoc/token_stream.rb +1 -2
  120. data/lib/rdoc/top_level.rb +3 -1
  121. data/lib/rdoc/version.rb +3 -1
  122. data/lib/rdoc.rb +58 -46
  123. metadata +13 -18
  124. data/Gemfile +0 -12
  125. data/Rakefile +0 -101
  126. data/bin/console +0 -7
  127. data/bin/setup +0 -6
  128. data/rdoc.gemspec +0 -249
@@ -3,16 +3,37 @@
3
3
  else
4
4
  current.comment
5
5
  end
6
- table = current.parse(comment).table_of_contents
6
+ table = current.parse(comment).table_of_contents.dup
7
7
 
8
8
  if table.length > 1 then %>
9
9
  <div class="nav-section">
10
10
  <h3>Table of Contents</h3>
11
11
 
12
+ <%- display_link = proc do |heading| -%>
13
+ <a href="#<%= heading.label current %>"><%= heading.plain_html %></a>
14
+ <%- end -%>
15
+
16
+ <%- list_siblings = proc do -%>
17
+ <%- level = table.first&.level -%>
18
+ <%- while table.first && table.first.level >= level -%>
19
+ <%- heading = table.shift -%>
20
+ <%- if table.first.nil? || table.first.level <= heading.level -%>
21
+ <li><% display_link.call heading -%>
22
+ <%- else -%>
23
+ <li>
24
+ <details open>
25
+ <summary><%- display_link.call heading -%></summary>
26
+ <ul class="link-list" role="directory">
27
+ <% list_siblings.call %>
28
+ </ul>
29
+ </details>
30
+ </li>
31
+ <%- end -%>
32
+ <%- end -%>
33
+ <%- end -%>
34
+
12
35
  <ul class="link-list" role="directory">
13
- <%- table.each do |heading| -%>
14
- <li><a href="#<%= heading.label current %>"><%= heading.plain_html %></a>
15
- <%- end -%>
36
+ <% list_siblings.call %>
16
37
  </ul>
17
38
  </div>
18
39
  <%- end -%>
@@ -98,29 +98,36 @@
98
98
 
99
99
  <%- methods.each do |method| -%>
100
100
  <div id="<%= method.aref %>" class="method-detail <%= method.is_alias_for ? "method-alias" : '' %>">
101
- <%- if (call_seq = method.call_seq) then -%>
102
- <%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%>
103
- <div class="method-heading">
104
- <span class="method-callseq">
105
- <%= h(call_seq.strip.
106
- gsub( /^\w+\./m, '')).
107
- gsub(/(.*)[-=]&gt;/, '\1&rarr;') %>
108
- </span>
109
- <%- if i == 0 and method.token_stream then -%>
110
- <span class="method-click-advice">click to toggle source</span>
111
- <%- end -%>
112
- </div>
113
- <%- end -%>
114
- <%- else -%>
115
- <div class="method-heading">
116
- <span class="method-name"><%= h method.name %></span><span
117
- class="method-args"><%= h method.param_seq %></span>
118
- <%- if method.token_stream then -%>
119
- <span class="method-click-advice">click to toggle source</span>
101
+ <div class="method-header">
102
+ <%- if (call_seq = method.call_seq) then -%>
103
+ <%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%>
104
+ <div class="method-heading">
105
+ <span class="method-callseq">
106
+ <%= h(call_seq.strip.
107
+ gsub( /^\w+\./m, '')).
108
+ gsub(/(.*)[-=]&gt;/, '\1&rarr;') %>
109
+ </span>
110
+ <%- if i == 0 and method.token_stream then -%>
111
+ <span class="method-click-advice">click to toggle source</span>
112
+ <%- end -%>
113
+ </div>
114
+ <%- end -%>
115
+ <%- elsif method.has_call_seq? then -%>
116
+ <div class="method-heading">
117
+ <span class="method-name"><%= h method.name %></span>
118
+ </div>
119
+ <%- else -%>
120
+ <div class="method-heading">
121
+ <span class="method-name"><%= h method.name %></span><span
122
+ class="method-args"><%= h method.param_seq %></span>
123
+ <%- if method.token_stream then -%>
124
+ <span class="method-click-advice">click to toggle source</span>
125
+ <%- end -%>
126
+ </div>
120
127
  <%- end -%>
121
128
  </div>
122
- <%- end -%>
123
129
 
130
+ <%- unless method.skip_description? then -%>
124
131
  <div class="method-description">
125
132
  <%- if method.comment then -%>
126
133
  <%= method.description.strip %>
@@ -143,6 +150,7 @@
143
150
  </div>
144
151
  <%- end -%>
145
152
  </div>
153
+ <%- end -%>
146
154
 
147
155
  <%- unless method.aliases.empty? then -%>
148
156
  <div class="aliases">
@@ -17,6 +17,14 @@ body {
17
17
  background: #fafafa;
18
18
  font-family: Lato, sans-serif;
19
19
  font-weight: 300;
20
+
21
+ /* Layout */
22
+ display: grid;
23
+ grid-template-columns: auto 1fr;
24
+ }
25
+
26
+ body > :last-child {
27
+ grid-column: 1 / 3;
20
28
  }
21
29
 
22
30
  h1 span,
@@ -79,6 +87,17 @@ pre {
79
87
  border-radius: 0.2em;
80
88
  }
81
89
 
90
+ em {
91
+ text-decoration-color: rgba(52, 48, 64, 0.25);
92
+ text-decoration-line: underline;
93
+ text-decoration-style: dotted;
94
+ }
95
+
96
+ strong,
97
+ em {
98
+ background-color: rgba(158, 178, 255, 0.1);
99
+ }
100
+
82
101
  table {
83
102
  margin: 0;
84
103
  border-spacing: 0;
@@ -181,17 +200,25 @@ table tr:nth-child(even) td {
181
200
  /* @group Top-Level Structure */
182
201
 
183
202
  nav {
184
- float: left;
185
- width: 260px;
186
203
  font-family: Helvetica, sans-serif;
187
204
  font-size: 14px;
188
205
  border-right: 1px solid #ccc;
206
+ position: sticky;
207
+ top: 0;
208
+ overflow: auto;
209
+
210
+ /* Layout */
211
+ width: 260px; /* fallback */
212
+ width: max(50px, 20vw);
213
+ min-width: 50px;
214
+ max-width: 80vw;
215
+ height: calc(100vh - 100px); /* reduce the footer height */
216
+ resize: horizontal;
189
217
  }
190
218
 
191
219
  main {
192
220
  display: block;
193
- margin: 0 2em 5em 260px;
194
- padding-left: 20px;
221
+ margin: 1em;
195
222
  min-width: 340px;
196
223
  font-size: 16px;
197
224
  }
@@ -210,7 +237,6 @@ main h6 {
210
237
  }
211
238
 
212
239
  #validator-badges {
213
- clear: both;
214
240
  margin: 1em 1em 2em;
215
241
  font-size: smaller;
216
242
  }
@@ -305,6 +331,28 @@ dl.note-list dt {
305
331
  background: url(../images/arrow_up.png) no-repeat right center;
306
332
  }
307
333
 
334
+ .nav-section details > summary {
335
+ display: block;
336
+ }
337
+
338
+ .nav-section details > summary::-webkit-details-marker {
339
+ display: none;
340
+ }
341
+
342
+ .nav-section details > summary::before {
343
+ content: "";
344
+ }
345
+
346
+ .nav-section details > summary::after {
347
+ content: "\25B6"; /* BLACK RIGHT-POINTING TRIANGLE */
348
+ font-size: 0.8em;
349
+ margin-left: 0.4em;
350
+ }
351
+
352
+ .nav-section details[open] > summary::after {
353
+ content: "\25BD"; /* WHITE DOWN-POINTING TRIANGLE */
354
+ }
355
+
308
356
  /* @end */
309
357
 
310
358
  /* @group Documentation Section */
@@ -482,7 +530,7 @@ main header h3 {
482
530
 
483
531
  main .method-source-code {
484
532
  max-height: 0;
485
- overflow: hidden;
533
+ overflow: auto;
486
534
  transition-duration: 200ms;
487
535
  transition-delay: 0ms;
488
536
  transition-property: all;
@@ -530,7 +578,7 @@ main .method-click-advice {
530
578
  line-height: 20px;
531
579
  background: url(../images/zoom.png) no-repeat right top;
532
580
  }
533
- main .method-heading:hover .method-click-advice {
581
+ main .method-header:hover .method-click-advice {
534
582
  visibility: visible;
535
583
  }
536
584
 
@@ -17,6 +17,6 @@
17
17
  main_page = @files.find { |f| f.full_name == @options.main_page } then %>
18
18
  <%= main_page.description %>
19
19
  <%- else -%>
20
- <p>This is the API documentation for <%= @title %>.
20
+ <p>This is the API documentation for <%= h @title %>.
21
21
  <%- end -%>
22
22
  </main>
@@ -54,7 +54,7 @@ function hookSearch() {
54
54
  var html = '';
55
55
 
56
56
  // TODO add relative path to <script> per-page
57
- html += '<p class="search-match"><a href="' + index_rel_prefix + result.path + '">' + this.hlt(result.title);
57
+ html += '<p class="search-match"><a href="' + index_rel_prefix + this.escapeHTML(result.path) + '">' + this.hlt(result.title);
58
58
  if (result.params)
59
59
  html += '<span class="params">' + result.params + '</span>';
60
60
  html += '</a>';
@@ -78,7 +78,20 @@ function hookSearch() {
78
78
  search.scrollIntoView = search.scrollInWindow;
79
79
  };
80
80
 
81
+ function hookFocus() {
82
+ document.addEventListener("keydown", (event) => {
83
+ if (document.activeElement.tagName === 'INPUT') {
84
+ return;
85
+ }
86
+ if (event.key === "/") {
87
+ event.preventDefault();
88
+ document.querySelector('#search-field').focus();
89
+ }
90
+ });
91
+ }
92
+
81
93
  document.addEventListener('DOMContentLoaded', function() {
82
94
  hookSourceViews();
83
95
  hookSearch();
96
+ hookFocus();
84
97
  });
@@ -15,9 +15,9 @@ Search.prototype = Object.assign({}, Navigation, new function() {
15
15
  this.init = function() {
16
16
  var _this = this;
17
17
  var observer = function(e) {
18
- switch(e.keyCode) {
19
- case 38: // Event.KEY_UP
20
- case 40: // Event.KEY_DOWN
18
+ switch(e.key) {
19
+ case 'ArrowUp':
20
+ case 'ArrowDown':
21
21
  return;
22
22
  }
23
23
  _this.search(_this.input.value);
@@ -101,7 +101,7 @@ Search.prototype = Object.assign({}, Navigation, new function() {
101
101
  }
102
102
 
103
103
  this.escapeHTML = function(html) {
104
- return html.replace(/[&<>]/g, function(c) {
104
+ return html.replace(/[&<>"`']/g, function(c) {
105
105
  return '&#' + c.charCodeAt(0) + ';';
106
106
  });
107
107
  }
@@ -8,14 +8,14 @@
8
8
  <ul>
9
9
  <%- simple_files.sort.each do |file| -%>
10
10
  <li class="file">
11
- <a href="<%= file.path %>"><%= h file.page_name %></a>
11
+ <a href="<%= h file.path %>"><%= h file.page_name %></a>
12
12
  <%
13
13
  # HACK table_of_contents should not exist on Document
14
14
  table = file.parse(file.comment).table_of_contents
15
15
  unless table.empty? then %>
16
16
  <ul>
17
17
  <%- table.each do |heading| -%>
18
- <li><a href="<%= file.path %>#<%= heading.aref %>"><%= heading.plain_html %></a>
18
+ <li><a href="<%= h file.path %>#<%= heading.aref %>"><%= heading.plain_html %></a>
19
19
  <%- end -%>
20
20
  </ul>
21
21
  <%- end -%>
@@ -36,8 +36,9 @@
36
36
  unless table.empty? then %>
37
37
  <ul>
38
38
  <%- table.each do |item| -%>
39
- <li><a href="<%= klass.path %>#<%= item.aref %>"><%= item.plain_html %></a>
40
- <%- end -%>
39
+ <%- label = item.respond_to?(:label) ? item.label(klass) : item.aref -%>
40
+ <li><a href="<%= klass.path %>#<%= label %>"><%= item.plain_html %></a>
41
+ <%- end -%>
41
42
  </ul>
42
43
  <%- end -%>
43
44
  </li>
@@ -46,9 +47,9 @@
46
47
 
47
48
  <h2 id="methods">Methods</h2>
48
49
  <ul>
49
- <%- @store.all_classes_and_modules.map do |mod|
50
+ <%- @store.all_classes_and_modules.flat_map do |mod|
50
51
  mod.method_list
51
- end.flatten.sort.each do |method| %>
52
+ end.sort.each do |method| %>
52
53
  <li class="method">
53
54
  <a href="<%= method.path %>"><%= h method.pretty_name %></a>
54
55
  &mdash;
@@ -23,24 +23,24 @@ Navigation = new function() {
23
23
 
24
24
  this.onkeydown = function(e) {
25
25
  if (!this.navigationActive) return;
26
- switch(e.keyCode) {
27
- case 37: //Event.KEY_LEFT:
26
+ switch(e.key) {
27
+ case 'ArrowLeft':
28
28
  if (this.moveLeft()) e.preventDefault();
29
29
  break;
30
- case 38: //Event.KEY_UP:
31
- if (e.keyCode == 38 || e.ctrlKey) {
30
+ case 'ArrowUp':
31
+ if (e.key == 'ArrowUp' || e.ctrlKey) {
32
32
  if (this.moveUp()) e.preventDefault();
33
33
  }
34
34
  break;
35
- case 39: //Event.KEY_RIGHT:
35
+ case 'ArrowRight':
36
36
  if (this.moveRight()) e.preventDefault();
37
37
  break;
38
- case 40: //Event.KEY_DOWN:
39
- if (e.keyCode == 40 || e.ctrlKey) {
38
+ case 'ArrowDown':
39
+ if (e.key == 'ArrowDown' || e.ctrlKey) {
40
40
  if (this.moveDown()) e.preventDefault();
41
41
  }
42
42
  break;
43
- case 13: //Event.KEY_RETURN:
43
+ case 'Enter':
44
44
  if (this.current) e.preventDefault();
45
45
  this.select(this.current);
46
46
  break;
@@ -41,11 +41,11 @@
41
41
 
42
42
  module RDoc::Generator
43
43
 
44
- autoload :Markup, 'rdoc/generator/markup'
44
+ autoload :Markup, "#{__dir__}/generator/markup"
45
45
 
46
- autoload :Darkfish, 'rdoc/generator/darkfish'
47
- autoload :JsonIndex, 'rdoc/generator/json_index'
48
- autoload :RI, 'rdoc/generator/ri'
49
- autoload :POT, 'rdoc/generator/pot'
46
+ autoload :Darkfish, "#{__dir__}/generator/darkfish"
47
+ autoload :JsonIndex, "#{__dir__}/generator/json_index"
48
+ autoload :RI, "#{__dir__}/generator/ri"
49
+ autoload :POT, "#{__dir__}/generator/pot"
50
50
 
51
51
  end
@@ -4,4 +4,3 @@
4
4
 
5
5
  class RDoc::GhostMethod < RDoc::AnyMethod
6
6
  end
7
-
data/lib/rdoc/i18n.rb CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  module RDoc::I18n
6
6
 
7
- autoload :Locale, 'rdoc/i18n/locale'
7
+ autoload :Locale, "#{__dir__}/i18n/locale"
8
8
  require_relative 'i18n/text'
9
9
 
10
10
  end
data/lib/rdoc/include.rb CHANGED
@@ -7,4 +7,3 @@
7
7
  class RDoc::Include < RDoc::Mixin
8
8
 
9
9
  end
10
-
@@ -25,6 +25,7 @@ module RDoc
25
25
  "rb_cObject" => "Object",
26
26
  "rb_cProc" => "Proc",
27
27
  "rb_cRange" => "Range",
28
+ "rb_cRefinement" => "Refinement",
28
29
  "rb_cRegexp" => "Regexp",
29
30
  "rb_cRubyVM" => "RubyVM",
30
31
  "rb_cSocket" => "Socket",
@@ -35,7 +36,7 @@ module RDoc
35
36
  "rb_cTime" => "Time",
36
37
  "rb_cTrueClass" => "TrueClass",
37
38
 
38
- "rb_eArgError" => "ArgError",
39
+ "rb_eArgError" => "ArgumentError",
39
40
  "rb_eEOFError" => "EOFError",
40
41
  "rb_eException" => "Exception",
41
42
  "rb_eFatal" => "fatal",
@@ -45,8 +46,8 @@ module RDoc
45
46
  "rb_eInterrupt" => "Interrupt",
46
47
  "rb_eLoadError" => "LoadError",
47
48
  "rb_eNameError" => "NameError",
48
- "rb_eNoMemError" => "NoMemError",
49
- "rb_eNotImpError" => "NotImpError",
49
+ "rb_eNoMemError" => "NoMemoryError",
50
+ "rb_eNotImpError" => "NotImplementedError",
50
51
  "rb_eRangeError" => "RangeError",
51
52
  "rb_eRuntimeError" => "RuntimeError",
52
53
  "rb_eScriptError" => "ScriptError",
@@ -57,7 +58,7 @@ module RDoc
57
58
  "rb_eSystemCallError" => "SystemCallError",
58
59
  "rb_eSystemExit" => "SystemExit",
59
60
  "rb_eTypeError" => "TypeError",
60
- "rb_eZeroDivError" => "ZeroDivError",
61
+ "rb_eZeroDivError" => "ZeroDivisionError",
61
62
 
62
63
  "rb_mComparable" => "Comparable",
63
64
  "rb_mEnumerable" => "Enumerable",
@@ -2129,4 +2129,3 @@ RDoc::Markdown::HTML_ENTITIES = {
2129
2129
  "zwj" => [0x0200D],
2130
2130
  "zwnj" => [0x0200C],
2131
2131
  }
2132
-
@@ -6,7 +6,6 @@
6
6
  # :markup: markdown
7
7
 
8
8
  ##
9
- #--
10
9
  # This set of literals is for Ruby 1.9 regular expressions and gives full
11
10
  # unicode support.
12
11
  #
@@ -20,4 +19,3 @@ BOM = "\uFEFF"
20
19
  Newline = /\n|\r\n?|\p{Zl}|\p{Zp}/
21
20
  NonAlphanumeric = /\p{^Word}/
22
21
  Spacechar = /\t|\p{Zs}/
23
-
@@ -3,7 +3,6 @@
3
3
  # :markup: markdown
4
4
 
5
5
  ##
6
- #--
7
6
  # This set of literals is for Ruby 1.9 regular expressions and gives full
8
7
  # unicode support.
9
8
  #
@@ -29,6 +28,7 @@ class RDoc::Markdown::Literals
29
28
  @result = nil
30
29
  @failed_rule = nil
31
30
  @failing_rule_offset = -1
31
+ @line_offsets = nil
32
32
 
33
33
  setup_foreign_grammar
34
34
  end
@@ -38,30 +38,75 @@ class RDoc::Markdown::Literals
38
38
  attr_accessor :result, :pos
39
39
 
40
40
  def current_column(target=pos)
41
- if c = string.rindex("\n", target-1)
42
- return target - c - 1
41
+ if string[target] == "\n" && (c = string.rindex("\n", target-1) || -1)
42
+ return target - c
43
+ elsif c = string.rindex("\n", target)
44
+ return target - c
43
45
  end
44
46
 
45
47
  target + 1
46
48
  end
47
49
 
48
- def current_line(target=pos)
49
- cur_offset = 0
50
- cur_line = 0
50
+ def position_line_offsets
51
+ unless @position_line_offsets
52
+ @position_line_offsets = []
53
+ total = 0
54
+ string.each_line do |line|
55
+ total += line.size
56
+ @position_line_offsets << total
57
+ end
58
+ end
59
+ @position_line_offsets
60
+ end
51
61
 
52
- string.each_line do |line|
53
- cur_line += 1
54
- cur_offset += line.size
55
- return cur_line if cur_offset >= target
62
+ if [].respond_to? :bsearch_index
63
+ def current_line(target=pos)
64
+ if line = position_line_offsets.bsearch_index {|x| x > target }
65
+ return line + 1
66
+ end
67
+ raise "Target position #{target} is outside of string"
56
68
  end
69
+ else
70
+ def current_line(target=pos)
71
+ if line = position_line_offsets.index {|x| x > target }
72
+ return line + 1
73
+ end
74
+
75
+ raise "Target position #{target} is outside of string"
76
+ end
77
+ end
78
+
79
+ def current_character(target=pos)
80
+ if target < 0 || target >= string.size
81
+ raise "Target position #{target} is outside of string"
82
+ end
83
+ string[target, 1]
84
+ end
85
+
86
+ KpegPosInfo = Struct.new(:pos, :lno, :col, :line, :char)
57
87
 
58
- -1
88
+ def current_pos_info(target=pos)
89
+ l = current_line target
90
+ c = current_column target
91
+ ln = get_line(l-1)
92
+ chr = string[target,1]
93
+ KpegPosInfo.new(target, l, c, ln, chr)
59
94
  end
60
95
 
61
96
  def lines
62
- lines = []
63
- string.each_line { |l| lines << l }
64
- lines
97
+ string.lines
98
+ end
99
+
100
+ def get_line(no)
101
+ loff = position_line_offsets
102
+ if no < 0
103
+ raise "Line No is out of range: #{no} < 0"
104
+ elsif no >= loff.size
105
+ raise "Line No is out of range: #{no} >= #{loff.size}"
106
+ end
107
+ lend = loff[no]-1
108
+ lstart = no > 0 ? loff[no-1] : 0
109
+ string[lstart..lend]
65
110
  end
66
111
 
67
112
 
@@ -75,6 +120,7 @@ class RDoc::Markdown::Literals
75
120
  @string = string
76
121
  @string_size = string ? string.size : 0
77
122
  @pos = pos
123
+ @position_line_offsets = nil
78
124
  end
79
125
 
80
126
  def show_pos
@@ -99,30 +145,22 @@ class RDoc::Markdown::Literals
99
145
  end
100
146
 
101
147
  def failure_caret
102
- l = current_line @failing_rule_offset
103
- c = current_column @failing_rule_offset
104
-
105
- line = lines[l-1]
106
- "#{line}\n#{' ' * (c - 1)}^"
148
+ p = current_pos_info @failing_rule_offset
149
+ "#{p.line.chomp}\n#{' ' * (p.col - 1)}^"
107
150
  end
108
151
 
109
152
  def failure_character
110
- l = current_line @failing_rule_offset
111
- c = current_column @failing_rule_offset
112
- lines[l-1][c-1, 1]
153
+ current_character @failing_rule_offset
113
154
  end
114
155
 
115
156
  def failure_oneline
116
- l = current_line @failing_rule_offset
117
- c = current_column @failing_rule_offset
118
-
119
- char = lines[l-1][c-1, 1]
157
+ p = current_pos_info @failing_rule_offset
120
158
 
121
159
  if @failed_rule.kind_of? Symbol
122
160
  info = self.class::Rules[@failed_rule]
123
- "@#{l}:#{c} failed rule '#{info.name}', got '#{char}'"
161
+ "@#{p.lno}:#{p.col} failed rule '#{info.name}', got '#{p.char}'"
124
162
  else
125
- "@#{l}:#{c} failed rule '#{@failed_rule}', got '#{char}'"
163
+ "@#{p.lno}:#{p.col} failed rule '#{@failed_rule}', got '#{p.char}'"
126
164
  end
127
165
  end
128
166
 
@@ -135,10 +173,9 @@ class RDoc::Markdown::Literals
135
173
 
136
174
  def show_error(io=STDOUT)
137
175
  error_pos = @failing_rule_offset
138
- line_no = current_line(error_pos)
139
- col_no = current_column(error_pos)
176
+ p = current_pos_info(error_pos)
140
177
 
141
- io.puts "On line #{line_no}, column #{col_no}:"
178
+ io.puts "On line #{p.lno}, column #{p.col}:"
142
179
 
143
180
  if @failed_rule.kind_of? Symbol
144
181
  info = self.class::Rules[@failed_rule]
@@ -147,10 +184,9 @@ class RDoc::Markdown::Literals
147
184
  io.puts "Failed to match rule '#{@failed_rule}'"
148
185
  end
149
186
 
150
- io.puts "Got: #{string[error_pos,1].inspect}"
151
- line = lines[line_no-1]
152
- io.puts "=> #{line}"
153
- io.print(" " * (col_no + 3))
187
+ io.puts "Got: #{p.char.inspect}"
188
+ io.puts "=> #{p.line}"
189
+ io.print(" " * (p.col + 2))
154
190
  io.puts "^"
155
191
  end
156
192
 
@@ -259,6 +295,7 @@ class RDoc::Markdown::Literals
259
295
  end
260
296
 
261
297
  def apply_with_args(rule, *args)
298
+ @result = nil
262
299
  memo_key = [rule, args]
263
300
  if m = @memoizations[memo_key][@pos]
264
301
  @pos = m.pos
@@ -292,6 +329,7 @@ class RDoc::Markdown::Literals
292
329
  end
293
330
 
294
331
  def apply(rule)
332
+ @result = nil
295
333
  if m = @memoizations[rule][@pos]
296
334
  @pos = m.pos
297
335
  if !m.set