rdoc 2.4.3 → 2.5

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 (139) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +3 -1
  3. data/History.txt +68 -0
  4. data/LICENSE.txt +57 -0
  5. data/Manifest.txt +37 -19
  6. data/README.txt +2 -12
  7. data/Rakefile +12 -12
  8. data/bin/rdoc +4 -4
  9. data/lib/rdoc.rb +32 -9
  10. data/lib/rdoc/alias.rb +2 -2
  11. data/lib/rdoc/any_method.rb +108 -16
  12. data/lib/rdoc/attr.rb +87 -1
  13. data/lib/rdoc/class_module.rb +131 -5
  14. data/lib/rdoc/code_object.rb +28 -5
  15. data/lib/rdoc/constant.rb +22 -0
  16. data/lib/rdoc/context.rb +80 -37
  17. data/lib/rdoc/gauntlet.rb +48 -0
  18. data/lib/rdoc/generator/darkfish.rb +25 -23
  19. data/lib/rdoc/generator/markup.rb +6 -29
  20. data/lib/rdoc/generator/ri.rb +39 -189
  21. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +17 -1
  22. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +10 -0
  23. data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  24. data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  25. data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  26. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  27. data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  28. data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  29. data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  30. data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  31. data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  32. data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  33. data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  34. data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  35. data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  36. data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  37. data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  38. data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  39. data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  40. data/lib/rdoc/generator/template/darkfish/index.rhtml +2 -2
  41. data/lib/rdoc/generator/template/darkfish/rdoc.css +38 -33
  42. data/lib/rdoc/include.rb +22 -0
  43. data/lib/rdoc/markup.rb +10 -262
  44. data/lib/rdoc/markup/attribute_manager.rb +57 -50
  45. data/lib/rdoc/markup/blank_line.rb +19 -0
  46. data/lib/rdoc/markup/document.rb +72 -0
  47. data/lib/rdoc/markup/formatter.rb +118 -0
  48. data/lib/rdoc/markup/formatter_test_case.rb +341 -0
  49. data/lib/rdoc/markup/heading.rb +17 -0
  50. data/lib/rdoc/markup/inline.rb +6 -5
  51. data/lib/rdoc/markup/list.rb +78 -0
  52. data/lib/rdoc/markup/list_item.rb +83 -0
  53. data/lib/rdoc/markup/paragraph.rb +66 -0
  54. data/lib/rdoc/markup/parser.rb +528 -0
  55. data/lib/rdoc/markup/rule.rb +17 -0
  56. data/lib/rdoc/markup/to_ansi.rb +72 -0
  57. data/lib/rdoc/markup/to_bs.rb +74 -0
  58. data/lib/rdoc/markup/to_html.rb +106 -172
  59. data/lib/rdoc/markup/to_html_crossref.rb +10 -4
  60. data/lib/rdoc/markup/to_rdoc.rb +243 -0
  61. data/lib/rdoc/markup/to_test.rb +27 -16
  62. data/lib/rdoc/markup/verbatim.rb +42 -0
  63. data/lib/rdoc/normal_class.rb +38 -1
  64. data/lib/rdoc/normal_module.rb +38 -8
  65. data/lib/rdoc/options.rb +39 -151
  66. data/lib/rdoc/parser.rb +36 -18
  67. data/lib/rdoc/parser/c.rb +102 -109
  68. data/lib/rdoc/parser/ruby.rb +359 -1662
  69. data/lib/rdoc/parser/ruby_tools.rb +157 -0
  70. data/lib/rdoc/parser/simple.rb +0 -2
  71. data/lib/rdoc/rdoc.rb +142 -82
  72. data/lib/rdoc/ri.rb +10 -0
  73. data/lib/rdoc/ri/driver.rb +674 -444
  74. data/lib/rdoc/ri/formatter.rb +2 -651
  75. data/lib/rdoc/ri/paths.rb +70 -45
  76. data/lib/rdoc/ri/store.rb +248 -0
  77. data/lib/rdoc/ruby_lex.rb +1284 -0
  78. data/lib/rdoc/ruby_token.rb +416 -0
  79. data/lib/rdoc/single_class.rb +5 -0
  80. data/lib/rdoc/stats.rb +152 -83
  81. data/lib/rdoc/task.rb +27 -49
  82. data/lib/rdoc/text.rb +130 -0
  83. data/lib/rdoc/tokenstream.rb +28 -9
  84. data/lib/rdoc/top_level.rb +49 -43
  85. data/test/hidden.zip.txt +1 -0
  86. data/test/test_attribute_manager.rb +9 -16
  87. data/test/test_rdoc_any_method.rb +23 -0
  88. data/test/test_rdoc_attr.rb +40 -0
  89. data/test/test_rdoc_class_module.rb +100 -0
  90. data/test/test_rdoc_code_object.rb +18 -2
  91. data/test/test_rdoc_context.rb +41 -0
  92. data/test/test_rdoc_generator_ri.rb +56 -0
  93. data/test/test_rdoc_markup.rb +21 -610
  94. data/test/test_rdoc_markup_attribute_manager.rb +14 -17
  95. data/test/test_rdoc_markup_document.rb +51 -0
  96. data/test/test_rdoc_markup_paragraph.rb +27 -0
  97. data/test/test_rdoc_markup_parser.rb +1327 -0
  98. data/test/test_rdoc_markup_to_ansi.rb +426 -0
  99. data/test/test_rdoc_markup_to_bs.rb +443 -0
  100. data/test/test_rdoc_markup_to_html.rb +183 -18
  101. data/test/test_rdoc_markup_to_html_crossref.rb +1 -3
  102. data/test/test_rdoc_markup_to_rdoc.rb +426 -0
  103. data/test/test_rdoc_normal_class.rb +17 -0
  104. data/test/test_rdoc_normal_module.rb +6 -6
  105. data/test/test_rdoc_options.rb +41 -0
  106. data/test/test_rdoc_parser.rb +66 -13
  107. data/test/test_rdoc_parser_c.rb +93 -38
  108. data/test/test_rdoc_parser_perl.rb +2 -3
  109. data/test/test_rdoc_parser_ruby.rb +291 -28
  110. data/test/test_rdoc_parser_simple.rb +48 -0
  111. data/test/test_rdoc_rdoc.rb +66 -0
  112. data/test/test_rdoc_ri_driver.rb +752 -38
  113. data/test/test_rdoc_ri_paths.rb +39 -0
  114. data/test/test_rdoc_ri_store.rb +309 -0
  115. data/test/test_rdoc_text.rb +157 -0
  116. data/test/test_rdoc_top_level.rb +35 -9
  117. data/test/xref_data.rb +9 -1
  118. data/test/xref_test_case.rb +8 -3
  119. metadata +110 -38
  120. metadata.gz.sig +0 -0
  121. data/lib/rdoc/cache.rb +0 -41
  122. data/lib/rdoc/diagram.rb +0 -340
  123. data/lib/rdoc/dot.rb +0 -249
  124. data/lib/rdoc/markup/fragments.rb +0 -377
  125. data/lib/rdoc/markup/lines.rb +0 -156
  126. data/lib/rdoc/markup/to_flow.rb +0 -211
  127. data/lib/rdoc/markup/to_latex.rb +0 -328
  128. data/lib/rdoc/markup/to_texinfo.rb +0 -73
  129. data/lib/rdoc/ri/cache.rb +0 -187
  130. data/lib/rdoc/ri/descriptions.rb +0 -156
  131. data/lib/rdoc/ri/display.rb +0 -340
  132. data/lib/rdoc/ri/reader.rb +0 -106
  133. data/lib/rdoc/ri/util.rb +0 -79
  134. data/lib/rdoc/ri/writer.rb +0 -68
  135. data/test/test_rdoc_ri_attribute_formatter.rb +0 -44
  136. data/test/test_rdoc_ri_default_display.rb +0 -302
  137. data/test/test_rdoc_ri_formatter.rb +0 -320
  138. data/test/test_rdoc_ri_html_formatter.rb +0 -141
  139. data/test/test_rdoc_ri_overstrike_formatter.rb +0 -71
@@ -0,0 +1,17 @@
1
+ ##
2
+ # A horizontal rule with a weight
3
+
4
+ class RDoc::Markup::Rule < Struct.new :weight
5
+
6
+ def accept visitor
7
+ visitor.accept_rule self
8
+ end
9
+
10
+ def pretty_print q # :nodoc:
11
+ q.group 2, '[rule:', ']' do
12
+ q.pp weight
13
+ end
14
+ end
15
+
16
+ end
17
+
@@ -0,0 +1,72 @@
1
+ require 'rdoc/markup/inline'
2
+
3
+ ##
4
+ # Outputs RDoc markup with vibrant ANSI color!
5
+
6
+ class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc
7
+
8
+ def initialize
9
+ super
10
+
11
+ @headings.clear
12
+ @headings[1] = ["\e[1;32m", "\e[m"]
13
+ @headings[2] = ["\e[4;32m", "\e[m"]
14
+ @headings[3] = ["\e[32m", "\e[m"]
15
+ end
16
+
17
+ ##
18
+ # Maps attributes to ANSI sequences
19
+
20
+ def init_tags
21
+ add_tag :BOLD, "\e[1m", "\e[m"
22
+ add_tag :TT, "\e[7m", "\e[m"
23
+ add_tag :EM, "\e[4m", "\e[m"
24
+ end
25
+
26
+ def accept_list_item_end list_item
27
+ width = case @list_type.last
28
+ when :BULLET then
29
+ 2
30
+ when :NOTE, :LABEL then
31
+ @res << "\n"
32
+ 2
33
+ else
34
+ bullet = @list_index.last.to_s
35
+ @list_index[-1] = @list_index.last.succ
36
+ bullet.length + 2
37
+ end
38
+
39
+ @indent -= width
40
+ end
41
+
42
+ def accept_list_item_start list_item
43
+ bullet = case @list_type.last
44
+ when :BULLET then
45
+ '*'
46
+ when :NOTE, :LABEL then
47
+ attributes(list_item.label) + ":\n"
48
+ else
49
+ @list_index.last.to_s + '.'
50
+ end
51
+
52
+ case @list_type.last
53
+ when :NOTE, :LABEL then
54
+ @indent += 2
55
+ @prefix = bullet + (' ' * @indent)
56
+ else
57
+ @prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
58
+
59
+ width = bullet.gsub(/\e\[[\d;]*m/, '').length + 1
60
+
61
+ @indent += width
62
+ end
63
+ end
64
+
65
+ def start_accepting
66
+ super
67
+
68
+ @res = ["\e[0m"]
69
+ end
70
+
71
+ end
72
+
@@ -0,0 +1,74 @@
1
+ require 'rdoc/markup/inline'
2
+
3
+ ##
4
+ # Outputs RDoc markup with hot backspace action! You will probably need a
5
+ # pager to use this output format.
6
+ #
7
+ # This formatter won't work on 1.8.6 because it lacks String#chars.
8
+
9
+ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
10
+
11
+ def initialize
12
+ super
13
+
14
+ @in_b = false
15
+ @in_em = false
16
+ end
17
+
18
+ ##
19
+ # Sets a flag that is picked up by #annotate to do the right thing in
20
+ # #convert_string
21
+
22
+ def init_tags
23
+ add_tag :BOLD, '+b', '-b'
24
+ add_tag :EM, '+_', '-_'
25
+ end
26
+
27
+ def accept_heading heading
28
+ use_prefix or @res << ' ' * @indent
29
+ @res << @headings[heading.level][0]
30
+ @in_b = true
31
+ @res << attributes(heading.text)
32
+ @in_b = false
33
+ @res << @headings[heading.level][1]
34
+ @res << "\n"
35
+ end
36
+
37
+ ##
38
+ # Turns on or off special handling for +convert_string+
39
+
40
+ def annotate tag
41
+ case tag
42
+ when '+b' then @in_b = true
43
+ when '-b' then @in_b = false
44
+ when '+_' then @in_em = true
45
+ when '-_' then @in_em = false
46
+ end
47
+
48
+ ''
49
+ end
50
+
51
+ ##
52
+ # Calls convert_string on the result of convert_special
53
+
54
+ def convert_special special
55
+ convert_string super
56
+ end
57
+
58
+ ##
59
+ # Adds bold or underline mixed with backspaces
60
+
61
+ def convert_string string
62
+ return string unless string.respond_to? :chars # your ruby is lame
63
+ return string unless @in_b or @in_em
64
+ chars = if @in_b then
65
+ string.chars.map do |char| "#{char}\b#{char}" end
66
+ elsif @in_em then
67
+ string.chars.map do |char| "_\b#{char}" end
68
+ end
69
+
70
+ chars.join
71
+ end
72
+
73
+ end
74
+
@@ -1,38 +1,28 @@
1
1
  require 'rdoc/markup/formatter'
2
- require 'rdoc/markup/fragments'
3
2
  require 'rdoc/markup/inline'
4
3
 
5
4
  require 'cgi'
6
5
 
6
+ ##
7
+ # Outputs RDoc markup as HTML
8
+
7
9
  class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
8
10
 
11
+ ##
12
+ # Maps RDoc::Markup::Parser::LIST_TOKENS types to HTML tags
13
+
9
14
  LIST_TYPE_TO_HTML = {
10
- :BULLET => %w[<ul> </ul>],
11
- :NUMBER => %w[<ol> </ol>],
12
- :UPPERALPHA => %w[<ol> </ol>],
13
- :LOWERALPHA => %w[<ol> </ol>],
14
- :LABELED => %w[<dl> </dl>],
15
- :NOTE => %w[<table> </table>],
15
+ :BULLET => ['<ul>', '</ul>'],
16
+ :LABEL => ['<dl>', '</dl>'],
17
+ :LALPHA => ['<ol style="display: lower-alpha">', '</ol>'],
18
+ :NOTE => ['<table>', '</table>'],
19
+ :NUMBER => ['<ol>', '</ol>'],
20
+ :UALPHA => ['<ol style="display: upper-alpha">', '</ol>'],
16
21
  }
17
22
 
18
- InlineTag = Struct.new(:bit, :on, :off)
19
-
20
- def initialize
21
- super
22
-
23
- # @in_tt - tt nested levels count
24
- # @tt_bit - cache
25
- @in_tt = 0
26
- @tt_bit = RDoc::Markup::Attribute.bitmap_for :TT
27
-
28
- # external hyperlinks
29
- @markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK)
30
-
31
- # and links of the form <text>[<url>]
32
- @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK)
33
-
34
- init_tags
35
- end
23
+ attr_reader :res # :nodoc:
24
+ attr_reader :in_list_entry # :nodoc:
25
+ attr_reader :list # :nodoc:
36
26
 
37
27
  ##
38
28
  # Converts a target url to one that is relative to a given path
@@ -58,6 +48,31 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
58
48
  File.join(*from)
59
49
  end
60
50
 
51
+ def initialize
52
+ super
53
+
54
+ @th = nil
55
+ @in_list_entry = nil
56
+ @list = nil
57
+
58
+ # external hyperlinks
59
+ @markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK)
60
+
61
+ # and links of the form <text>[<url>]
62
+ @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK)
63
+
64
+ init_tags
65
+ end
66
+
67
+ ##
68
+ # Maps attributes to HTML tags
69
+
70
+ def init_tags
71
+ add_tag :BOLD, "<b>", "</b>"
72
+ add_tag :TT, "<tt>", "</tt>"
73
+ add_tag :EM, "<em>", "</em>"
74
+ end
75
+
61
76
  ##
62
77
  # Generate a hyperlink for url, labeled with text. Handle the
63
78
  # special cases for img: and link: described under handle_special_HYPERLINK
@@ -115,55 +130,14 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
115
130
  gen_url url, label
116
131
  end
117
132
 
118
- ##
119
- # are we currently inside tt tags?
120
-
121
- def in_tt?
122
- @in_tt > 0
123
- end
124
-
125
- ##
126
- # is +tag+ a tt tag?
127
-
128
- def tt?(tag)
129
- tag.bit == @tt_bit
130
- end
131
-
132
- ##
133
- # Set up the standard mapping of attributes to HTML tags
134
-
135
- def init_tags
136
- @attr_tags = [
137
- InlineTag.new(RDoc::Markup::Attribute.bitmap_for(:BOLD), "<b>", "</b>"),
138
- InlineTag.new(RDoc::Markup::Attribute.bitmap_for(:TT), "<tt>", "</tt>"),
139
- InlineTag.new(RDoc::Markup::Attribute.bitmap_for(:EM), "<em>", "</em>"),
140
- ]
141
- end
142
-
143
- ##
144
- # Add a new set of HTML tags for an attribute. We allow separate start and
145
- # end tags for flexibility.
146
-
147
- def add_tag(name, start, stop)
148
- @attr_tags << InlineTag.new(RDoc::Markup::Attribute.bitmap_for(name), start, stop)
149
- end
150
-
151
- ##
152
- # Given an HTML tag, decorate it with class information and the like if
153
- # required. This is a no-op in the base class, but is overridden in HTML
154
- # output classes that implement style sheets.
155
-
156
- def annotate(tag)
157
- tag
158
- end
159
-
160
133
  ##
161
134
  # This is a higher speed (if messier) version of wrap
162
135
 
163
136
  def wrap(txt, line_len = 76)
164
- res = ""
137
+ res = []
165
138
  sp = 0
166
139
  ep = txt.length
140
+
167
141
  while sp < ep
168
142
  # scan back for a space
169
143
  p = sp + line_len - 1
@@ -184,127 +158,94 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
184
158
  sp = p
185
159
  sp += 1 while sp < ep and txt[sp] == ?\s
186
160
  end
187
- res
161
+
162
+ res.join
188
163
  end
189
164
 
190
165
  ##
191
166
  # :section: Visitor
192
167
 
193
168
  def start_accepting
194
- @res = ""
169
+ @res = []
195
170
  @in_list_entry = []
171
+ @list = []
196
172
  end
197
173
 
198
174
  def end_accepting
199
- @res
175
+ @res.join
200
176
  end
201
177
 
202
- def accept_paragraph(am, fragment)
178
+ def accept_paragraph(paragraph)
203
179
  @res << annotate("<p>") + "\n"
204
- @res << wrap(convert_flow(am.flow(fragment.txt)))
180
+ @res << wrap(convert_flow(@am.flow(paragraph.text)))
205
181
  @res << annotate("</p>") + "\n"
206
182
  end
207
183
 
208
- def accept_verbatim(am, fragment)
209
- @res << annotate("<pre>") + "\n"
210
- @res << CGI.escapeHTML(fragment.txt)
184
+ def accept_verbatim(verbatim)
185
+ @res << annotate("<pre>") << "\n"
186
+ @res << CGI.escapeHTML(verbatim.text)
211
187
  @res << annotate("</pre>") << "\n"
212
188
  end
213
189
 
214
- def accept_rule(am, fragment)
215
- size = fragment.param
190
+ def accept_rule(rule)
191
+ size = rule.weight
216
192
  size = 10 if size > 10
217
- @res << "<hr size=\"#{size}\"></hr>"
193
+ @res << "<hr style=\"height: #{size}px\"></hr>"
218
194
  end
219
195
 
220
- def accept_list_start(am, fragment)
221
- @res << html_list_name(fragment.type, true) << "\n"
196
+ def accept_list_start(list)
197
+ @list << list.type
198
+ @res << html_list_name(list.type, true) << "\n"
222
199
  @in_list_entry.push false
223
200
  end
224
201
 
225
- def accept_list_end(am, fragment)
202
+ def accept_list_end(list)
203
+ @list.pop
226
204
  if tag = @in_list_entry.pop
227
205
  @res << annotate(tag) << "\n"
228
206
  end
229
- @res << html_list_name(fragment.type, false) << "\n"
207
+ @res << html_list_name(list.type, false) << "\n"
230
208
  end
231
209
 
232
- def accept_list_item(am, fragment)
210
+ def accept_list_item_start(list_item)
233
211
  if tag = @in_list_entry.last
234
212
  @res << annotate(tag) << "\n"
235
213
  end
236
214
 
237
- @res << list_item_start(am, fragment)
238
-
239
- @res << wrap(convert_flow(am.flow(fragment.txt))) << "\n"
215
+ @res << list_item_start(list_item, @list.last)
216
+ end
240
217
 
241
- @in_list_entry[-1] = list_end_for(fragment.type)
218
+ def accept_list_item_end(list_item)
219
+ @in_list_entry[-1] = list_end_for(@list.last)
242
220
  end
243
221
 
244
- def accept_blank_line(am, fragment)
222
+ def accept_blank_line(blank_line)
245
223
  # @res << annotate("<p />") << "\n"
246
224
  end
247
225
 
248
- def accept_heading(am, fragment)
249
- @res << convert_heading(fragment.head_level, am.flow(fragment.txt))
226
+ def accept_heading(heading)
227
+ @res << convert_heading(heading.level, @am.flow(heading.text))
250
228
  end
251
229
 
252
230
  private
253
231
 
254
- def on_tags(res, item)
255
- attr_mask = item.turn_on
256
- return if attr_mask.zero?
257
-
258
- @attr_tags.each do |tag|
259
- if attr_mask & tag.bit != 0
260
- res << annotate(tag.on)
261
- @in_tt += 1 if tt?(tag)
262
- end
263
- end
264
- end
265
-
266
- def off_tags(res, item)
267
- attr_mask = item.turn_off
268
- return if attr_mask.zero?
269
-
270
- @attr_tags.reverse_each do |tag|
271
- if attr_mask & tag.bit != 0
272
- @in_tt -= 1 if tt?(tag)
273
- res << annotate(tag.off)
274
- end
275
- end
276
- end
277
-
278
- def convert_flow(flow)
279
- res = ""
280
-
281
- flow.each do |item|
282
- case item
283
- when String
284
- res << convert_string(item)
285
- when RDoc::Markup::AttrChanger
286
- off_tags(res, item)
287
- on_tags(res, item)
288
- when RDoc::Markup::Special
289
- res << convert_special(item)
290
- else
291
- raise "Unknown flow element: #{item.inspect}"
292
- end
293
- end
294
-
295
- res
296
- end
232
+ ##
233
+ # Converts string +item+
297
234
 
298
235
  def convert_string(item)
299
236
  in_tt? ? convert_string_simple(item) : convert_string_fancy(item)
300
237
  end
301
238
 
239
+ ##
240
+ # Escapes HTML in +item+
241
+
302
242
  def convert_string_simple(item)
303
243
  CGI.escapeHTML item
304
244
  end
305
245
 
306
246
  ##
307
- # some of these patterns are taken from SmartyPants...
247
+ # Converts ampersand, dashes, elipsis, quotes, copyright and registered
248
+ # trademark symbols to HTML escaped Unicode.
308
249
 
309
250
  def convert_string_fancy(item)
310
251
  # convert ampersand before doing anything else
@@ -336,69 +277,62 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
336
277
  gsub(/\(r\)/, '&#174;')
337
278
  end
338
279
 
339
- def convert_special(special)
340
- handled = false
341
- RDoc::Markup::Attribute.each_name_of(special.type) do |name|
342
- method_name = "handle_special_#{name}"
343
- if self.respond_to? method_name
344
- special.text = send(method_name, special)
345
- handled = true
346
- end
347
- end
348
- raise "Unhandled special: #{special}" unless handled
349
- special.text
350
- end
280
+ ##
281
+ # Converts headings to hN elements
351
282
 
352
283
  def convert_heading(level, flow)
353
- res =
354
- annotate("<h#{level}>") +
355
- convert_flow(flow) +
356
- annotate("</h#{level}>\n")
284
+ [annotate("<h#{level}>"),
285
+ convert_flow(flow),
286
+ annotate("</h#{level}>\n")].join
357
287
  end
358
288
 
359
- def html_list_name(list_type, is_open_tag)
360
- tags = LIST_TYPE_TO_HTML[list_type] || raise("Invalid list type: #{list_type.inspect}")
361
- annotate(tags[ is_open_tag ? 0 : 1])
362
- end
289
+ ##
290
+ # Determins the HTML list element for +list_type+ and +open_tag+
363
291
 
364
- def list_item_start(am, fragment)
365
- case fragment.type
366
- when :BULLET, :NUMBER then
367
- annotate("<li>")
292
+ def html_list_name(list_type, open_tag)
293
+ tags = LIST_TYPE_TO_HTML[list_type]
294
+ raise RDoc::Error, "Invalid list type: #{list_type.inspect}" unless tags
295
+ annotate tags[open_tag ? 0 : 1]
296
+ end
368
297
 
369
- when :UPPERALPHA then
370
- annotate("<li type=\"A\">")
298
+ ##
299
+ # Starts a list item
371
300
 
372
- when :LOWERALPHA then
373
- annotate("<li type=\"a\">")
301
+ def list_item_start(list_item, list_type)
302
+ case list_type
303
+ when :BULLET, :LALPHA, :NUMBER, :UALPHA then
304
+ annotate("<li>")
374
305
 
375
- when :LABELED then
306
+ when :LABEL then
376
307
  annotate("<dt>") +
377
- convert_flow(am.flow(fragment.param)) +
308
+ convert_flow(@am.flow(list_item.label)) +
378
309
  annotate("</dt>") +
379
310
  annotate("<dd>")
380
311
 
381
312
  when :NOTE then
382
313
  annotate("<tr>") +
383
314
  annotate("<td valign=\"top\">") +
384
- convert_flow(am.flow(fragment.param)) +
315
+ convert_flow(@am.flow(list_item.label)) +
385
316
  annotate("</td>") +
386
317
  annotate("<td>")
387
318
  else
388
- raise "Invalid list type"
319
+ raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
389
320
  end
390
321
  end
391
322
 
392
- def list_end_for(fragment_type)
393
- case fragment_type
394
- when :BULLET, :NUMBER, :UPPERALPHA, :LOWERALPHA then
323
+ ##
324
+ # Ends a list item
325
+
326
+ def list_end_for(list_type)
327
+ case list_type
328
+ when :BULLET, :LALPHA, :NUMBER, :UALPHA then
395
329
  "</li>"
396
- when :LABELED then
330
+ when :LABEL then
397
331
  "</dd>"
398
332
  when :NOTE then
399
333
  "</td></tr>"
400
334
  else
401
- raise "Invalid list type"
335
+ raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
402
336
  end
403
337
  end
404
338