rdoc 6.7.0 → 6.12.0

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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/ExampleMarkdown.md +2 -0
  3. data/ExampleRDoc.rdoc +2 -0
  4. data/History.rdoc +64 -62
  5. data/LICENSE.rdoc +2 -0
  6. data/README.rdoc +13 -0
  7. data/RI.md +842 -0
  8. data/TODO.rdoc +8 -7
  9. data/lib/rdoc/{alias.rb → code_object/alias.rb} +1 -1
  10. data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +3 -3
  11. data/lib/rdoc/{attr.rb → code_object/attr.rb} +1 -1
  12. data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +82 -12
  13. data/lib/rdoc/{constant.rb → code_object/constant.rb} +1 -1
  14. data/lib/rdoc/{context → code_object/context}/section.rb +10 -68
  15. data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +17 -5
  16. data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +5 -5
  17. data/lib/rdoc/code_object.rb +6 -1
  18. data/lib/rdoc/comment.rb +11 -1
  19. data/lib/rdoc/generator/darkfish.rb +41 -3
  20. data/lib/rdoc/generator/pot/message_extractor.rb +1 -1
  21. data/lib/rdoc/generator/pot/po_entry.rb +1 -1
  22. data/lib/rdoc/generator/template/darkfish/_head.rhtml +23 -0
  23. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -0
  24. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +20 -11
  25. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +3 -8
  26. data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
  27. data/lib/rdoc/generator/template/darkfish/class.rhtml +69 -43
  28. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +380 -399
  29. data/lib/rdoc/generator/template/darkfish/index.rhtml +11 -10
  30. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +24 -1
  31. data/lib/rdoc/generator/template/darkfish/page.rhtml +5 -5
  32. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +10 -8
  33. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +5 -2
  34. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +11 -0
  35. data/lib/rdoc/markdown.kpeg +1 -1
  36. data/lib/rdoc/markdown.rb +21 -11
  37. data/lib/rdoc/markup/attribute_manager.rb +2 -2
  38. data/lib/rdoc/markup/formatter.rb +19 -12
  39. data/lib/rdoc/markup/pre_process.rb +26 -6
  40. data/lib/rdoc/markup/to_bs.rb +1 -1
  41. data/lib/rdoc/markup/to_html.rb +1 -1
  42. data/lib/rdoc/markup/to_html_crossref.rb +63 -12
  43. data/lib/rdoc/markup/to_rdoc.rb +5 -5
  44. data/lib/rdoc/markup.rb +18 -13
  45. data/lib/rdoc/options.rb +78 -12
  46. data/lib/rdoc/parser/c.rb +26 -2
  47. data/lib/rdoc/parser/changelog.rb +5 -4
  48. data/lib/rdoc/parser/prism_ruby.rb +1099 -0
  49. data/lib/rdoc/parser/ripper_state_lex.rb +7 -305
  50. data/lib/rdoc/parser/ruby.rb +16 -7
  51. data/lib/rdoc/parser/simple.rb +1 -1
  52. data/lib/rdoc/parser.rb +5 -4
  53. data/lib/rdoc/rd/block_parser.rb +3 -3
  54. data/lib/rdoc/rd/inline_parser.rb +3 -3
  55. data/lib/rdoc/rdoc.rb +6 -3
  56. data/lib/rdoc/ri/driver.rb +74 -29
  57. data/lib/rdoc/rubygems_hook.rb +90 -8
  58. data/lib/rdoc/store.rb +12 -0
  59. data/lib/rdoc/task.rb +2 -3
  60. data/lib/rdoc/tom_doc.rb +1 -7
  61. data/lib/rdoc/version.rb +1 -1
  62. data/lib/rdoc.rb +22 -24
  63. data/lib/rubygems_plugin.rb +23 -0
  64. metadata +27 -26
  65. data/RI.rdoc +0 -57
  66. data/lib/rdoc/generator/template/darkfish/.document +0 -0
  67. data/lib/rdoc/generator/template/json_index/.document +0 -1
  68. /data/lib/rdoc/{anon_class.rb → code_object/anon_class.rb} +0 -0
  69. /data/lib/rdoc/{context.rb → code_object/context.rb} +0 -0
  70. /data/lib/rdoc/{extend.rb → code_object/extend.rb} +0 -0
  71. /data/lib/rdoc/{ghost_method.rb → code_object/ghost_method.rb} +0 -0
  72. /data/lib/rdoc/{include.rb → code_object/include.rb} +0 -0
  73. /data/lib/rdoc/{meta_method.rb → code_object/meta_method.rb} +0 -0
  74. /data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +0 -0
  75. /data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +0 -0
  76. /data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +0 -0
  77. /data/lib/rdoc/{require.rb → code_object/require.rb} +0 -0
  78. /data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +0 -0
@@ -1,22 +1,23 @@
1
1
  <body id="top" role="document" class="file">
2
- <nav role="navigation">
2
+ <%= render '_sidebar_toggle.rhtml' %>
3
+
4
+ <nav id="navigation" role="navigation">
3
5
  <div id="project-navigation">
4
6
  <%= render '_sidebar_navigation.rhtml' %>
5
-
6
7
  <%= render '_sidebar_search.rhtml' %>
7
8
  </div>
8
9
 
9
- <div id="project-metadata">
10
- <%= render '_sidebar_pages.rhtml' %>
11
- <%= render '_sidebar_classes.rhtml' %>
12
- </div>
10
+ <%= render '_sidebar_table_of_contents.rhtml' if defined?(current) %>
11
+ <%= render '_sidebar_pages.rhtml' %>
12
+ <%= render '_sidebar_classes.rhtml' %>
13
+
14
+ <%= render '_footer.rhtml' %>
13
15
  </nav>
14
16
 
15
17
  <main role="main">
16
- <%- if @options.main_page and
17
- main_page = @files.find { |f| f.full_name == @options.main_page } then %>
18
- <%= main_page.description %>
18
+ <%- if @main_page %>
19
+ <%= @main_page.description %>
19
20
  <%- else -%>
20
- <p>This is the API documentation for <%= h @title %>.
21
+ <p>This is the API documentation for <%= h @title %>.
21
22
  <%- end -%>
22
23
  </main>
@@ -34,7 +34,7 @@ function showSource( e ) {
34
34
  };
35
35
 
36
36
  function hookSourceViews() {
37
- document.querySelectorAll('.method-heading').forEach(function (codeObject) {
37
+ document.querySelectorAll('.method-source-toggle').forEach(function (codeObject) {
38
38
  codeObject.addEventListener('click', showSource);
39
39
  });
40
40
  };
@@ -90,8 +90,31 @@ function hookFocus() {
90
90
  });
91
91
  }
92
92
 
93
+ function hookSidebar() {
94
+ var navigation = document.querySelector('#navigation');
95
+ var navigationToggle = document.querySelector('#navigation-toggle');
96
+
97
+ navigationToggle.addEventListener('click', function() {
98
+ navigation.hidden = !navigation.hidden;
99
+ navigationToggle.ariaExpanded = navigationToggle.ariaExpanded !== 'true';
100
+ });
101
+
102
+ var isSmallViewport = window.matchMedia("(max-width: 1023px)").matches;
103
+ if (isSmallViewport) {
104
+ navigation.hidden = true;
105
+ navigationToggle.ariaExpanded = false;
106
+ document.addEventListener('click', (e) => {
107
+ if (e.target.closest('#navigation a')) {
108
+ navigation.hidden = true;
109
+ navigationToggle.ariaExpanded = false;
110
+ }
111
+ });
112
+ }
113
+ }
114
+
93
115
  document.addEventListener('DOMContentLoaded', function() {
94
116
  hookSourceViews();
95
117
  hookSearch();
96
118
  hookFocus();
119
+ hookSidebar();
97
120
  });
@@ -1,18 +1,18 @@
1
1
  <body id="top" role="document" class="file">
2
- <nav role="navigation">
2
+ <%= render '_sidebar_toggle.rhtml' %>
3
+
4
+ <nav id="navigation" role="navigation">
3
5
  <div id="project-navigation">
4
6
  <%= render '_sidebar_navigation.rhtml' %>
5
7
  <%= render '_sidebar_search.rhtml' %>
6
8
  </div>
7
9
 
8
10
  <%= render '_sidebar_table_of_contents.rhtml' %>
11
+ <%= render '_sidebar_pages.rhtml' %>
9
12
 
10
- <div id="project-metadata">
11
- <%= render '_sidebar_pages.rhtml' %>
12
- </div>
13
+ <%= render '_footer.rhtml' %>
13
14
  </nav>
14
15
 
15
16
  <main role="main" aria-label="Page <%=h file.full_name%>">
16
17
  <%= file.description %>
17
18
  </main>
18
-
@@ -1,13 +1,16 @@
1
1
  <body role="document">
2
- <nav role="navigation">
3
- <%= render '_sidebar_navigation.rhtml' %>
2
+ <%= render '_sidebar_toggle.rhtml' %>
4
3
 
5
- <%= render '_sidebar_search.rhtml' %>
6
-
7
- <div id="project-metadata">
8
- <%= render '_sidebar_pages.rhtml' %>
9
- <%= render '_sidebar_classes.rhtml' %>
4
+ <nav id="navigation" role="navigation">
5
+ <div id="project-navigation">
6
+ <%= render '_sidebar_navigation.rhtml' %>
7
+ <%= render '_sidebar_search.rhtml' %>
10
8
  </div>
9
+
10
+ <%= render '_sidebar_pages.rhtml' %>
11
+ <%= render '_sidebar_classes.rhtml' %>
12
+
13
+ <%= render '_footer.rhtml' %>
11
14
  </nav>
12
15
 
13
16
  <main role="main">
@@ -15,4 +18,3 @@
15
18
 
16
19
  <p><%= message %>
17
20
  </main>
18
-
@@ -1,5 +1,7 @@
1
1
  <body role="document">
2
- <nav role="navigation">
2
+ <%= render '_sidebar_toggle.rhtml' %>
3
+
4
+ <nav id="navigation" role="navigation">
3
5
  <div id="project-navigation">
4
6
  <div id="home-section" class="nav-section">
5
7
  <h2>
@@ -10,7 +12,8 @@
10
12
  <%= render '_sidebar_search.rhtml' %>
11
13
  </div>
12
14
 
13
- <%= render '_sidebar_installed.rhtml' %>
15
+ <%= render '_sidebar_installed.rhtml' %>
16
+ <%= render '_footer.rhtml' %>
14
17
  </nav>
15
18
 
16
19
  <main role="main">
@@ -1,4 +1,15 @@
1
1
  <body id="top" class="table-of-contents">
2
+ <%= render '_sidebar_toggle.rhtml' %>
3
+
4
+ <nav id="navigation" role="navigation">
5
+ <div id="project-navigation">
6
+ <%= render '_sidebar_navigation.rhtml' %>
7
+
8
+ <%= render '_sidebar_search.rhtml' %>
9
+ </div>
10
+
11
+ <%= render '_footer.rhtml' %>
12
+ </nav>
2
13
  <main role="main">
3
14
  <h1 class="class"><%= h @title %></h1>
4
15
 
@@ -530,7 +530,7 @@ AtxInline = !@Newline !(@Sp /#*/ @Sp @Newline) Inline
530
530
  AtxStart = < /\#{1,6}/ >
531
531
  { text.length }
532
532
 
533
- AtxHeading = AtxStart:s @Sp AtxInline+:a (@Sp /#*/ @Sp)? @Newline
533
+ AtxHeading = AtxStart:s @Spacechar+ AtxInline+:a (@Sp /#*/ @Sp)? @Newline
534
534
  { RDoc::Markup::Heading.new(s, a.join) }
535
535
 
536
536
  SetextHeading = SetextHeading1 | SetextHeading2
data/lib/rdoc/markdown.rb CHANGED
@@ -1158,7 +1158,7 @@ class RDoc::Markdown
1158
1158
  return _tmp
1159
1159
  end
1160
1160
 
1161
- # AtxHeading = AtxStart:s @Sp AtxInline+:a (@Sp /#*/ @Sp)? @Newline { RDoc::Markup::Heading.new(s, a.join) }
1161
+ # AtxHeading = AtxStart:s @Spacechar+ AtxInline+:a (@Sp /#*/ @Sp)? @Newline { RDoc::Markup::Heading.new(s, a.join) }
1162
1162
  def _AtxHeading
1163
1163
 
1164
1164
  _save = self.pos
@@ -1169,12 +1169,22 @@ class RDoc::Markdown
1169
1169
  self.pos = _save
1170
1170
  break
1171
1171
  end
1172
- _tmp = _Sp()
1172
+ _save1 = self.pos
1173
+ _tmp = _Spacechar()
1174
+ if _tmp
1175
+ while true
1176
+ _tmp = _Spacechar()
1177
+ break unless _tmp
1178
+ end
1179
+ _tmp = true
1180
+ else
1181
+ self.pos = _save1
1182
+ end
1173
1183
  unless _tmp
1174
1184
  self.pos = _save
1175
1185
  break
1176
1186
  end
1177
- _save1 = self.pos
1187
+ _save2 = self.pos
1178
1188
  _ary = []
1179
1189
  _tmp = apply(:_AtxInline)
1180
1190
  if _tmp
@@ -1187,37 +1197,37 @@ class RDoc::Markdown
1187
1197
  _tmp = true
1188
1198
  @result = _ary
1189
1199
  else
1190
- self.pos = _save1
1200
+ self.pos = _save2
1191
1201
  end
1192
1202
  a = @result
1193
1203
  unless _tmp
1194
1204
  self.pos = _save
1195
1205
  break
1196
1206
  end
1197
- _save2 = self.pos
1198
-
1199
1207
  _save3 = self.pos
1208
+
1209
+ _save4 = self.pos
1200
1210
  while true # sequence
1201
1211
  _tmp = _Sp()
1202
1212
  unless _tmp
1203
- self.pos = _save3
1213
+ self.pos = _save4
1204
1214
  break
1205
1215
  end
1206
1216
  _tmp = scan(/\G(?-mix:#*)/)
1207
1217
  unless _tmp
1208
- self.pos = _save3
1218
+ self.pos = _save4
1209
1219
  break
1210
1220
  end
1211
1221
  _tmp = _Sp()
1212
1222
  unless _tmp
1213
- self.pos = _save3
1223
+ self.pos = _save4
1214
1224
  end
1215
1225
  break
1216
1226
  end # end sequence
1217
1227
 
1218
1228
  unless _tmp
1219
1229
  _tmp = true
1220
- self.pos = _save2
1230
+ self.pos = _save3
1221
1231
  end
1222
1232
  unless _tmp
1223
1233
  self.pos = _save
@@ -16539,7 +16549,7 @@ class RDoc::Markdown
16539
16549
  Rules[:_Plain] = rule_info("Plain", "Inlines:a { paragraph a }")
16540
16550
  Rules[:_AtxInline] = rule_info("AtxInline", "!@Newline !(@Sp /\#*/ @Sp @Newline) Inline")
16541
16551
  Rules[:_AtxStart] = rule_info("AtxStart", "< /\\\#{1,6}/ > { text.length }")
16542
- Rules[:_AtxHeading] = rule_info("AtxHeading", "AtxStart:s @Sp AtxInline+:a (@Sp /\#*/ @Sp)? @Newline { RDoc::Markup::Heading.new(s, a.join) }")
16552
+ Rules[:_AtxHeading] = rule_info("AtxHeading", "AtxStart:s @Spacechar+ AtxInline+:a (@Sp /\#*/ @Sp)? @Newline { RDoc::Markup::Heading.new(s, a.join) }")
16543
16553
  Rules[:_SetextHeading] = rule_info("SetextHeading", "(SetextHeading1 | SetextHeading2)")
16544
16554
  Rules[:_SetextBottom1] = rule_info("SetextBottom1", "/={1,}/ @Newline")
16545
16555
  Rules[:_SetextBottom2] = rule_info("SetextBottom2", "/-{1,}/ @Newline")
@@ -260,7 +260,7 @@ class RDoc::Markup::AttributeManager
260
260
 
261
261
  def add_word_pair(start, stop, name, exclusive = false)
262
262
  raise ArgumentError, "Word flags may not start with '<'" if
263
- start[0,1] == '<'
263
+ start[0, 1] == '<'
264
264
 
265
265
  bitmap = @attributes.bitmap_for name
266
266
 
@@ -271,7 +271,7 @@ class RDoc::Markup::AttributeManager
271
271
  @word_pair_map[pattern] = bitmap
272
272
  end
273
273
 
274
- @protectable << start[0,1]
274
+ @protectable << start[0, 1]
275
275
  @protectable.uniq!
276
276
 
277
277
  @exclusive_bitmap |= bitmap if exclusive
@@ -195,18 +195,20 @@ class RDoc::Markup::Formatter
195
195
  @in_tt > 0
196
196
  end
197
197
 
198
+ def tt_tag? attr_mask, reverse = false
199
+ each_attr_tag(attr_mask, reverse) do |tag|
200
+ return true if tt? tag
201
+ end
202
+ false
203
+ end
204
+
198
205
  ##
199
206
  # Turns on tags for +item+ on +res+
200
207
 
201
208
  def on_tags res, item
202
- attr_mask = item.turn_on
203
- return if attr_mask.zero?
204
-
205
- @attr_tags.each do |tag|
206
- if attr_mask & tag.bit != 0 then
207
- res << annotate(tag.on)
208
- @in_tt += 1 if tt? tag
209
- end
209
+ each_attr_tag(item.turn_on) do |tag|
210
+ res << annotate(tag.on)
211
+ @in_tt += 1 if tt? tag
210
212
  end
211
213
  end
212
214
 
@@ -214,13 +216,18 @@ class RDoc::Markup::Formatter
214
216
  # Turns off tags for +item+ on +res+
215
217
 
216
218
  def off_tags res, item
217
- attr_mask = item.turn_off
219
+ each_attr_tag(item.turn_off, true) do |tag|
220
+ @in_tt -= 1 if tt? tag
221
+ res << annotate(tag.off)
222
+ end
223
+ end
224
+
225
+ def each_attr_tag attr_mask, reverse = false
218
226
  return if attr_mask.zero?
219
227
 
220
- @attr_tags.reverse_each do |tag|
228
+ @attr_tags.public_send(reverse ? :reverse_each : :each) do |tag|
221
229
  if attr_mask & tag.bit != 0 then
222
- @in_tt -= 1 if tt? tag
223
- res << annotate(tag.off)
230
+ yield tag
224
231
  end
225
232
  end
226
233
  end
@@ -97,15 +97,18 @@ class RDoc::Markup::PreProcess
97
97
  # RDoc::CodeObject#metadata for details.
98
98
 
99
99
  def handle text, code_object = nil, &block
100
+ first_line = 1
100
101
  if RDoc::Comment === text then
101
102
  comment = text
102
103
  text = text.text
104
+ first_line = comment.line || 1
103
105
  end
104
106
 
105
107
  # regexp helper (square brackets for optional)
106
108
  # $1 $2 $3 $4 $5
107
109
  # [prefix][\]:directive:[spaces][param]newline
108
- text = text.gsub(/^([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):(\w+):([ \t]*)(.+)?(\r?\n|$)/) do
110
+ text = text.lines.map.with_index(first_line) do |line, num|
111
+ next line unless line =~ /\A([ \t]*(?:#|\/?\*)?[ \t]*)(\\?):([\w-]+):([ \t]*)(.+)?(\r?\n|$)/
109
112
  # skip something like ':toto::'
110
113
  next $& if $4.empty? and $5 and $5[0, 1] == ':'
111
114
 
@@ -120,8 +123,8 @@ class RDoc::Markup::PreProcess
120
123
  next "#{$1.strip}\n"
121
124
  end
122
125
 
123
- handle_directive $1, $3, $5, code_object, text.encoding, &block
124
- end
126
+ handle_directive $1, $3, $5, code_object, text.encoding, num, &block
127
+ end.join
125
128
 
126
129
  if comment then
127
130
  comment.text = text
@@ -148,7 +151,7 @@ class RDoc::Markup::PreProcess
148
151
  # When 1.8.7 support is ditched prefix can be defaulted to ''
149
152
 
150
153
  def handle_directive prefix, directive, param, code_object = nil,
151
- encoding = nil
154
+ encoding = nil, line = nil
152
155
  blankline = "#{prefix.strip}\n"
153
156
  directive = directive.downcase
154
157
 
@@ -184,6 +187,14 @@ class RDoc::Markup::PreProcess
184
187
  include_file filename, prefix, encoding
185
188
  when 'main' then
186
189
  @options.main_page = param if @options.respond_to? :main_page
190
+ warn <<~MSG
191
+ The :main: directive is deprecated and will be removed in RDoc 7.
192
+
193
+ You can use these options to specify the initial page displayed instead:
194
+ - `--main=#{param}` via the command line
195
+ - `rdoc.main = "#{param}"` if you use `RDoc::Task`
196
+ - `main_page: #{param}` in your `.rdoc_options` file
197
+ MSG
187
198
 
188
199
  blankline
189
200
  when 'nodoc' then
@@ -214,17 +225,26 @@ class RDoc::Markup::PreProcess
214
225
  when 'title' then
215
226
  @options.default_title = param if @options.respond_to? :default_title=
216
227
 
228
+ warn <<~MSG
229
+ The :title: directive is deprecated and will be removed in RDoc 7.
230
+
231
+ You can use these options to specify the title displayed instead:
232
+ - `--title=#{param}` via the command line
233
+ - `rdoc.title = "#{param}"` if you use `RDoc::Task`
234
+ - `title: #{param}` in your `.rdoc_options` file
235
+ MSG
236
+
217
237
  blankline
218
238
  when 'yield', 'yields' then
219
239
  return blankline unless code_object
220
240
  # remove parameter &block
221
241
  code_object.params = code_object.params.sub(/,?\s*&\w+/, '') if code_object.params
222
242
 
223
- code_object.block_params = param
243
+ code_object.block_params = param || ''
224
244
 
225
245
  blankline
226
246
  else
227
- result = yield directive, param if block_given?
247
+ result = yield directive, param, line if block_given?
228
248
 
229
249
  case result
230
250
  when nil then
@@ -24,7 +24,7 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
24
24
  def init_tags
25
25
  add_tag :BOLD, '+b', '-b'
26
26
  add_tag :EM, '+_', '-_'
27
- add_tag :TT, '' , '' # we need in_tt information maintained
27
+ add_tag :TT, '', '' # we need in_tt information maintained
28
28
  end
29
29
 
30
30
  ##
@@ -407,7 +407,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
407
407
  "<li>"
408
408
  when :LABEL, :NOTE then
409
409
  Array(list_item.label).map do |label|
410
- "<dt>#{to_html label}\n"
410
+ "<dt>#{to_html label}</dt>\n"
411
411
  end.join << "<dd>"
412
412
  else
413
413
  raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
@@ -58,7 +58,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
58
58
  # Creates a link to the reference +name+ if the name exists. If +text+ is
59
59
  # given it is used as the link text, otherwise +name+ is used.
60
60
 
61
- def cross_reference name, text = nil, code = true
61
+ def cross_reference name, text = nil, code = true, rdoc_ref: false
62
62
  lookup = name
63
63
 
64
64
  name = name[1..-1] unless @show_hash if name[0, 1] == '#'
@@ -70,7 +70,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
70
70
  text ||= name
71
71
  end
72
72
 
73
- link lookup, text, code
73
+ link lookup, text, code, rdoc_ref: rdoc_ref
74
74
  end
75
75
 
76
76
  ##
@@ -83,6 +83,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
83
83
  def handle_regexp_CROSSREF(target)
84
84
  name = target.text
85
85
 
86
+ return name if @options.autolink_excluded_words&.include?(name)
87
+
86
88
  return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails
87
89
 
88
90
  unless @hyperlink_all then
@@ -92,7 +94,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
92
94
  return name if name =~ /\A[a-z]*\z/
93
95
  end
94
96
 
95
- cross_reference name
97
+ cross_reference name, rdoc_ref: false
96
98
  end
97
99
 
98
100
  ##
@@ -100,9 +102,14 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
100
102
  # handle other schemes.
101
103
 
102
104
  def handle_regexp_HYPERLINK target
103
- return cross_reference $' if target.text =~ /\Ardoc-ref:/
105
+ url = target.text
104
106
 
105
- super
107
+ case url
108
+ when /\Ardoc-ref:/
109
+ cross_reference $', rdoc_ref: true
110
+ else
111
+ super
112
+ end
106
113
  end
107
114
 
108
115
  ##
@@ -117,8 +124,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
117
124
  url = target.text
118
125
 
119
126
  case url
120
- when /\Ardoc-ref:/ then
121
- cross_reference $'
127
+ when /\Ardoc-ref:/
128
+ cross_reference $', rdoc_ref: true
122
129
  else
123
130
  super
124
131
  end
@@ -129,16 +136,18 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
129
136
  # RDoc::Markup::ToHtml to handle other schemes.
130
137
 
131
138
  def gen_url url, text
132
- return super unless url =~ /\Ardoc-ref:/
133
-
134
- name = $'
135
- cross_reference name, text, name == text
139
+ if url =~ /\Ardoc-ref:/
140
+ name = $'
141
+ cross_reference name, text, name == text, rdoc_ref: true
142
+ else
143
+ super
144
+ end
136
145
  end
137
146
 
138
147
  ##
139
148
  # Creates an HTML link to +name+ with the given +text+.
140
149
 
141
- def link name, text, code = true
150
+ def link name, text, code = true, rdoc_ref: false
142
151
  if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])?@/
143
152
  name = $1
144
153
  label = $'
@@ -148,6 +157,9 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
148
157
 
149
158
  case ref
150
159
  when String then
160
+ if rdoc_ref && @options.warn_missing_rdoc_ref
161
+ puts "#{@from_path}: `rdoc-ref:#{name}` can't be resolved for `#{text}`"
162
+ end
151
163
  ref
152
164
  else
153
165
  path = ref ? ref.as_href(@from_path) : +""
@@ -172,4 +184,43 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
172
184
  end
173
185
  end
174
186
 
187
+ def convert_flow(flow)
188
+ res = []
189
+
190
+ i = 0
191
+ while i < flow.size
192
+ item = flow[i]
193
+ i += 1
194
+ case item
195
+ when RDoc::Markup::AttrChanger then
196
+ # Make "+Class#method+" a cross reference
197
+ if tt_tag?(item.turn_on) and
198
+ String === (str = flow[i]) and
199
+ RDoc::Markup::AttrChanger === flow[i+1] and
200
+ tt_tag?(flow[i+1].turn_off, true) and
201
+ (@options.hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP).match?(str) and
202
+ (text = cross_reference str) != str
203
+ then
204
+ text = yield text, res if defined?(yield)
205
+ res << text
206
+ i += 2
207
+ next
208
+ end
209
+ off_tags res, item
210
+ on_tags res, item
211
+ when String then
212
+ text = convert_string(item)
213
+ text = yield text, res if defined?(yield)
214
+ res << text
215
+ when RDoc::Markup::RegexpHandling then
216
+ text = convert_regexp_handling(item)
217
+ text = yield text, res if defined?(yield)
218
+ res << text
219
+ else
220
+ raise "Unknown flow element: #{item.inspect}"
221
+ end
222
+ end
223
+
224
+ res.join('')
225
+ end
175
226
  end
@@ -249,12 +249,12 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
249
249
  # Adds +table+ to the output
250
250
 
251
251
  def accept_table header, body, aligns
252
- widths = header.zip(body) do |h, b|
253
- [h.size, b.size].max
252
+ widths = header.zip(*body).map do |cols|
253
+ cols.map(&:size).max
254
254
  end
255
255
  aligns = aligns.map do |a|
256
256
  case a
257
- when nil
257
+ when nil, :center
258
258
  :center
259
259
  when :left
260
260
  :ljust
@@ -262,12 +262,12 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
262
262
  :rjust
263
263
  end
264
264
  end
265
- @res << header.zip(widths, aligns) do |h, w, a|
265
+ @res << header.zip(widths, aligns).map do |h, w, a|
266
266
  h.__send__(a, w)
267
267
  end.join("|").rstrip << "\n"
268
268
  @res << widths.map {|w| "-" * w }.join("|") << "\n"
269
269
  body.each do |row|
270
- @res << row.zip(widths, aligns) do |t, w, a|
270
+ @res << row.zip(widths, aligns).map do |t, w, a|
271
271
  t.__send__(a, w)
272
272
  end.join("|").rstrip << "\n"
273
273
  end
data/lib/rdoc/markup.rb CHANGED
@@ -10,19 +10,24 @@
10
10
  # RDoc::Markup and other markup formats do no output formatting, this is
11
11
  # handled by the RDoc::Markup::Formatter subclasses.
12
12
  #
13
- # = Supported Formats
14
- #
15
- # Besides the RDoc::Markup format, the following formats are built in to RDoc:
16
- #
17
- # markdown::
18
- # The markdown format as described by
19
- # http://daringfireball.net/projects/markdown/. See RDoc::Markdown for
20
- # details on the parser and supported extensions.
21
- # rd::
22
- # The rdtool format. See RDoc::RD for details on the parser and format.
23
- # tomdoc::
24
- # The TomDoc format as described by http://tomdoc.org/. See RDoc::TomDoc
25
- # for details on the parser and supported extensions.
13
+ # = Markup Formats
14
+ #
15
+ # +RDoc+ supports these markup formats:
16
+ #
17
+ # - +rdoc+:
18
+ # the +RDoc+ markup format;
19
+ # see RDoc::MarkupReference.
20
+ # - +markdown+:
21
+ # The +markdown+ markup format as described in
22
+ # the {Markdown Guide}[https://www.markdownguide.org];
23
+ # see RDoc::Markdown.
24
+ # - +rd+:
25
+ # the +rd+ markup format format;
26
+ # see RDoc::RD.
27
+ # - +tomdoc+:
28
+ # the TomDoc format as described in
29
+ # {TomDoc for Ruby}[http://tomdoc.org];
30
+ # see RDoc::TomDoc.
26
31
  #
27
32
  # You can choose a markup format using the following methods:
28
33
  #