rdoc 6.6.3.1 → 6.8.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.rdoc +1 -1
  3. data/ExampleMarkdown.md +2 -0
  4. data/ExampleRDoc.rdoc +2 -0
  5. data/History.rdoc +64 -62
  6. data/LICENSE.rdoc +2 -0
  7. data/README.rdoc +13 -0
  8. data/RI.md +842 -0
  9. data/TODO.rdoc +8 -7
  10. data/lib/rdoc/{alias.rb → code_object/alias.rb} +1 -1
  11. data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +54 -0
  12. data/lib/rdoc/{context.rb → code_object/context.rb} +1 -1
  13. data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +3 -3
  14. data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +4 -4
  15. data/lib/rdoc/code_object.rb +6 -0
  16. data/lib/rdoc/generator/darkfish.rb +45 -3
  17. data/lib/rdoc/generator/pot/message_extractor.rb +1 -1
  18. data/lib/rdoc/generator/pot/po_entry.rb +1 -1
  19. data/lib/rdoc/generator/template/darkfish/_head.rhtml +23 -0
  20. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +20 -11
  21. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +3 -8
  22. data/lib/rdoc/generator/template/darkfish/class.rhtml +69 -43
  23. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +367 -392
  24. data/lib/rdoc/generator/template/darkfish/index.rhtml +7 -6
  25. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +18 -1
  26. data/lib/rdoc/generator/template/darkfish/page.rhtml +5 -5
  27. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +10 -8
  28. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +5 -2
  29. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +11 -0
  30. data/lib/rdoc/markdown.kpeg +3 -3
  31. data/lib/rdoc/markdown.rb +25 -15
  32. data/lib/rdoc/markup/attribute_manager.rb +2 -2
  33. data/lib/rdoc/markup/pre_process.rb +9 -6
  34. data/lib/rdoc/markup/to_bs.rb +26 -1
  35. data/lib/rdoc/markup/to_html_crossref.rb +12 -13
  36. data/lib/rdoc/markup/to_markdown.rb +4 -4
  37. data/lib/rdoc/markup/to_rdoc.rb +15 -7
  38. data/lib/rdoc/markup.rb +18 -13
  39. data/lib/rdoc/options.rb +23 -5
  40. data/lib/rdoc/parser/c.rb +19 -9
  41. data/lib/rdoc/parser/changelog.rb +2 -2
  42. data/lib/rdoc/parser/ripper_state_lex.rb +7 -305
  43. data/lib/rdoc/parser/ruby.rb +26 -8
  44. data/lib/rdoc/parser.rb +6 -3
  45. data/lib/rdoc/rd/block_parser.rb +3 -7
  46. data/lib/rdoc/rd/inline_parser.rb +3 -7
  47. data/lib/rdoc/rdoc.rb +3 -2
  48. data/lib/rdoc/ri/driver.rb +11 -7
  49. data/lib/rdoc/task.rb +2 -3
  50. data/lib/rdoc/tom_doc.rb +1 -7
  51. data/lib/rdoc/version.rb +1 -1
  52. data/lib/rdoc.rb +23 -23
  53. metadata +27 -24
  54. data/RI.rdoc +0 -57
  55. /data/lib/rdoc/{anon_class.rb → code_object/anon_class.rb} +0 -0
  56. /data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +0 -0
  57. /data/lib/rdoc/{attr.rb → code_object/attr.rb} +0 -0
  58. /data/lib/rdoc/{constant.rb → code_object/constant.rb} +0 -0
  59. /data/lib/rdoc/{context → code_object/context}/section.rb +0 -0
  60. /data/lib/rdoc/{extend.rb → code_object/extend.rb} +0 -0
  61. /data/lib/rdoc/{ghost_method.rb → code_object/ghost_method.rb} +0 -0
  62. /data/lib/rdoc/{include.rb → code_object/include.rb} +0 -0
  63. /data/lib/rdoc/{meta_method.rb → code_object/meta_method.rb} +0 -0
  64. /data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +0 -0
  65. /data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +0 -0
  66. /data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +0 -0
  67. /data/lib/rdoc/{require.rb → code_object/require.rb} +0 -0
  68. /data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +0 -0
@@ -1,15 +1,16 @@
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_pages.rhtml' %>
11
+ <%= render '_sidebar_classes.rhtml' %>
12
+
13
+ <%= render '_footer.rhtml' %>
13
14
  </nav>
14
15
 
15
16
  <main role="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,25 @@ 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: 1024px)").matches;
103
+ if (isSmallViewport) {
104
+ navigation.hidden = true;
105
+ navigationToggle.ariaExpanded = false;
106
+ }
107
+ }
108
+
93
109
  document.addEventListener('DOMContentLoaded', function() {
94
110
  hookSourceViews();
95
111
  hookSearch();
96
112
  hookFocus();
113
+ hookSidebar();
97
114
  });
@@ -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
 
@@ -9,7 +9,7 @@
9
9
  # RDoc::Markdown as described by the [markdown syntax][syntax].
10
10
  #
11
11
  # To choose Markdown as your only default format see
12
- # RDoc::Options@Saved+Options for instructions on setting up a `.doc_options`
12
+ # RDoc::Options@Saved+Options for instructions on setting up a `.rdoc_options`
13
13
  # file to store your project default.
14
14
  #
15
15
  # ## Usage
@@ -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
@@ -1237,7 +1237,7 @@ DefinitionListItem = ( DefinitionListLabel+ ):label
1237
1237
  list_items
1238
1238
  }
1239
1239
 
1240
- DefinitionListLabel = StrChunk:label @Sp @Newline
1240
+ DefinitionListLabel = Inline:label @Sp @Newline
1241
1241
  { label }
1242
1242
 
1243
1243
  DefinitionListDefinition = @NonindentSpace ":" @Space Inlines:a @BlankLine+
data/lib/rdoc/markdown.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  # RDoc::Markdown as described by the [markdown syntax][syntax].
7
7
  #
8
8
  # To choose Markdown as your only default format see
9
- # RDoc::Options@Saved+Options for instructions on setting up a `.doc_options`
9
+ # RDoc::Options@Saved+Options for instructions on setting up a `.rdoc_options`
10
10
  # file to store your project default.
11
11
  #
12
12
  # ## Usage
@@ -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
@@ -16445,12 +16455,12 @@ class RDoc::Markdown
16445
16455
  return _tmp
16446
16456
  end
16447
16457
 
16448
- # DefinitionListLabel = StrChunk:label @Sp @Newline { label }
16458
+ # DefinitionListLabel = Inline:label @Sp @Newline { label }
16449
16459
  def _DefinitionListLabel
16450
16460
 
16451
16461
  _save = self.pos
16452
16462
  while true # sequence
16453
- _tmp = apply(:_StrChunk)
16463
+ _tmp = apply(:_Inline)
16454
16464
  label = @result
16455
16465
  unless _tmp
16456
16466
  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")
@@ -16777,7 +16787,7 @@ class RDoc::Markdown
16777
16787
  Rules[:_TableAlign] = rule_info("TableAlign", "< /:?-+:?/ > @Sp { text.start_with?(\":\") ? (text.end_with?(\":\") ? :center : :left) : (text.end_with?(\":\") ? :right : nil) }")
16778
16788
  Rules[:_DefinitionList] = rule_info("DefinitionList", "&{ definition_lists? } DefinitionListItem+:list { RDoc::Markup::List.new :NOTE, *list.flatten }")
16779
16789
  Rules[:_DefinitionListItem] = rule_info("DefinitionListItem", "DefinitionListLabel+:label DefinitionListDefinition+:defns { list_items = [] list_items << RDoc::Markup::ListItem.new(label, defns.shift) list_items.concat defns.map { |defn| RDoc::Markup::ListItem.new nil, defn } unless list_items.empty? list_items }")
16780
- Rules[:_DefinitionListLabel] = rule_info("DefinitionListLabel", "StrChunk:label @Sp @Newline { label }")
16790
+ Rules[:_DefinitionListLabel] = rule_info("DefinitionListLabel", "Inline:label @Sp @Newline { label }")
16781
16791
  Rules[:_DefinitionListDefinition] = rule_info("DefinitionListDefinition", "@NonindentSpace \":\" @Space Inlines:a @BlankLine+ { paragraph a }")
16782
16792
  # :startdoc:
16783
16793
  end
@@ -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
@@ -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
 
@@ -220,11 +223,11 @@ class RDoc::Markup::PreProcess
220
223
  # remove parameter &block
221
224
  code_object.params = code_object.params.sub(/,?\s*&\w+/, '') if code_object.params
222
225
 
223
- code_object.block_params = param
226
+ code_object.block_params = param || ''
224
227
 
225
228
  blankline
226
229
  else
227
- result = yield directive, param if block_given?
230
+ result = yield directive, param, line if block_given?
228
231
 
229
232
  case result
230
233
  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
  ##
@@ -40,6 +40,31 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
40
40
  @res << "\n"
41
41
  end
42
42
 
43
+ ##
44
+ # Prepares the visitor for consuming +list_item+
45
+
46
+ def accept_list_item_start list_item
47
+ type = @list_type.last
48
+
49
+ case type
50
+ when :NOTE, :LABEL then
51
+ bullets = Array(list_item.label).map do |label|
52
+ attributes(label).strip
53
+ end.join "\n"
54
+
55
+ bullets << ":\n" unless bullets.empty?
56
+
57
+ @prefix = ' ' * @indent
58
+ @indent += 2
59
+ @prefix << bullets + (' ' * @indent)
60
+ else
61
+ bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
62
+ @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
63
+ width = bullet.length + 1
64
+ @indent += width
65
+ end
66
+ end
67
+
43
68
  ##
44
69
  # Turns on or off regexp handling for +convert_string+
45
70
 
@@ -63,8 +63,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
63
63
 
64
64
  name = name[1..-1] unless @show_hash if name[0, 1] == '#'
65
65
 
66
- if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])@/
67
- text ||= "#{CGI.unescape $'} at <code>#{$1}</code>"
66
+ if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])?@/
67
+ text ||= [CGI.unescape($'), (" at <code>#{$1}</code>" if $~.begin(1))].join("")
68
68
  code = false
69
69
  else
70
70
  text ||= name
@@ -139,35 +139,34 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
139
139
  # Creates an HTML link to +name+ with the given +text+.
140
140
 
141
141
  def link name, text, code = true
142
- if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])@/
142
+ if !(name.end_with?('+@', '-@')) and name =~ /(.*[^#:])?@/
143
143
  name = $1
144
144
  label = $'
145
145
  end
146
146
 
147
- ref = @cross_reference.resolve name, text
147
+ ref = @cross_reference.resolve name, text if name
148
148
 
149
149
  case ref
150
150
  when String then
151
151
  ref
152
152
  else
153
- path = ref.as_href @from_path
153
+ path = ref ? ref.as_href(@from_path) : +""
154
154
 
155
155
  if code and RDoc::CodeObject === ref and !(RDoc::TopLevel === ref)
156
156
  text = "<code>#{CGI.escapeHTML text}</code>"
157
157
  end
158
158
 
159
- if path =~ /#/ then
160
- path << "-label-#{label}"
161
- elsif ref.sections and
162
- ref.sections.any? { |section| label == section.title } then
163
- path << "##{label}"
164
- else
165
- if ref.respond_to?(:aref)
159
+ if label
160
+ if path =~ /#/
161
+ path << "-label-#{label}"
162
+ elsif ref&.sections&.any? { |section| label == section.title }
163
+ path << "##{label}"
164
+ elsif ref.respond_to?(:aref)
166
165
  path << "##{ref.aref}-label-#{label}"
167
166
  else
168
167
  path << "#label-#{label}"
169
168
  end
170
- end if label
169
+ end
171
170
 
172
171
  "<a href=\"#{path}\">#{text}</a>"
173
172
  end
@@ -45,8 +45,6 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
45
45
  # Finishes consumption of `list`
46
46
 
47
47
  def accept_list_end list
48
- @res << "\n"
49
-
50
48
  super
51
49
  end
52
50
 
@@ -60,6 +58,8 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
60
58
  when :NOTE, :LABEL then
61
59
  use_prefix
62
60
 
61
+ @res << "\n"
62
+
63
63
  4
64
64
  else
65
65
  @list_index[-1] = @list_index.last.succ
@@ -81,11 +81,11 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
81
81
  attributes(label).strip
82
82
  end.join "\n"
83
83
 
84
- bullets << "\n:"
84
+ bullets << "\n" unless bullets.empty?
85
85
 
86
86
  @prefix = ' ' * @indent
87
87
  @indent += 4
88
- @prefix << bullets + (' ' * (@indent - 1))
88
+ @prefix << bullets << ":" << (' ' * (@indent - 1))
89
89
  else
90
90
  bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
91
91
  @prefix = (' ' * @indent) + bullet.ljust(4)
@@ -145,11 +145,19 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
145
145
 
146
146
  case type
147
147
  when :NOTE, :LABEL then
148
- bullets = Array(list_item.label).map do |label|
148
+ stripped_labels = Array(list_item.label).map do |label|
149
149
  attributes(label).strip
150
- end.join "\n"
150
+ end
151
+
152
+ bullets = case type
153
+ when :NOTE
154
+ stripped_labels.map { |b| "#{b}::" }
155
+ when :LABEL
156
+ stripped_labels.map { |b| "[#{b}]" }
157
+ end
151
158
 
152
- bullets << ":\n" unless bullets.empty?
159
+ bullets = bullets.join("\n")
160
+ bullets << "\n" unless stripped_labels.empty?
153
161
 
154
162
  @prefix = ' ' * @indent
155
163
  @indent += 2
@@ -241,8 +249,8 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
241
249
  # Adds +table+ to the output
242
250
 
243
251
  def accept_table header, body, aligns
244
- widths = header.zip(body) do |h, b|
245
- [h.size, b.size].max
252
+ widths = header.zip(*body).map do |cols|
253
+ cols.map(&:size).max
246
254
  end
247
255
  aligns = aligns.map do |a|
248
256
  case a
@@ -254,12 +262,12 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
254
262
  :rjust
255
263
  end
256
264
  end
257
- @res << header.zip(widths, aligns) do |h, w, a|
265
+ @res << header.zip(widths, aligns).map do |h, w, a|
258
266
  h.__send__(a, w)
259
267
  end.join("|").rstrip << "\n"
260
268
  @res << widths.map {|w| "-" * w }.join("|") << "\n"
261
269
  body.each do |row|
262
- @res << row.zip(widths, aligns) do |t, w, a|
270
+ @res << row.zip(widths, aligns).map do |t, w, a|
263
271
  t.__send__(a, w)
264
272
  end.join("|").rstrip << "\n"
265
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
  #