voloko-sdoc 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/rdoc/History.txt +254 -0
  2. data/rdoc/Manifest.txt +126 -0
  3. data/rdoc/README.txt +47 -0
  4. data/rdoc/RI.txt +58 -0
  5. data/rdoc/Rakefile +70 -0
  6. data/rdoc/bin/rdoc +35 -0
  7. data/rdoc/bin/ri +5 -0
  8. data/rdoc/lib/rdoc/alias.rb +54 -0
  9. data/rdoc/lib/rdoc/anon_class.rb +10 -0
  10. data/rdoc/lib/rdoc/any_method.rb +190 -0
  11. data/rdoc/lib/rdoc/attr.rb +79 -0
  12. data/rdoc/lib/rdoc/cache.rb +41 -0
  13. data/rdoc/lib/rdoc/class_module.rb +87 -0
  14. data/rdoc/lib/rdoc/code_object.rb +152 -0
  15. data/rdoc/lib/rdoc/code_objects.rb +23 -0
  16. data/rdoc/lib/rdoc/constant.rb +36 -0
  17. data/rdoc/lib/rdoc/context.rb +712 -0
  18. data/rdoc/lib/rdoc/diagram.rb +340 -0
  19. data/rdoc/lib/rdoc/dot.rb +249 -0
  20. data/rdoc/lib/rdoc/generator/darkfish.rb +455 -0
  21. data/rdoc/lib/rdoc/generator/markup.rb +194 -0
  22. data/rdoc/lib/rdoc/generator/ri.rb +230 -0
  23. data/rdoc/lib/rdoc/generator/template/darkfish/classpage.rhtml +281 -0
  24. data/rdoc/lib/rdoc/generator/template/darkfish/filepage.rhtml +112 -0
  25. data/rdoc/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
  26. data/rdoc/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
  27. data/rdoc/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
  28. data/rdoc/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
  29. data/rdoc/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
  30. data/rdoc/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
  31. data/rdoc/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
  32. data/rdoc/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
  33. data/rdoc/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
  34. data/rdoc/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
  35. data/rdoc/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
  36. data/rdoc/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
  37. data/rdoc/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
  38. data/rdoc/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
  39. data/rdoc/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
  40. data/rdoc/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
  41. data/rdoc/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
  42. data/rdoc/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
  43. data/rdoc/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
  44. data/rdoc/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
  45. data/rdoc/lib/rdoc/generator/template/darkfish/index.rhtml +64 -0
  46. data/rdoc/lib/rdoc/generator/template/darkfish/js/darkfish.js +116 -0
  47. data/rdoc/lib/rdoc/generator/template/darkfish/js/jquery.js +32 -0
  48. data/rdoc/lib/rdoc/generator/template/darkfish/js/quicksearch.js +114 -0
  49. data/rdoc/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +10 -0
  50. data/rdoc/lib/rdoc/generator/template/darkfish/rdoc.css +696 -0
  51. data/rdoc/lib/rdoc/generator.rb +8 -0
  52. data/rdoc/lib/rdoc/ghost_method.rb +8 -0
  53. data/rdoc/lib/rdoc/include.rb +39 -0
  54. data/rdoc/lib/rdoc/known_classes.rb +68 -0
  55. data/rdoc/lib/rdoc/markup/attribute_manager.rb +311 -0
  56. data/rdoc/lib/rdoc/markup/formatter.rb +25 -0
  57. data/rdoc/lib/rdoc/markup/fragments.rb +377 -0
  58. data/rdoc/lib/rdoc/markup/inline.rb +126 -0
  59. data/rdoc/lib/rdoc/markup/lines.rb +156 -0
  60. data/rdoc/lib/rdoc/markup/preprocess.rb +80 -0
  61. data/rdoc/lib/rdoc/markup/to_flow.rb +211 -0
  62. data/rdoc/lib/rdoc/markup/to_html.rb +406 -0
  63. data/rdoc/lib/rdoc/markup/to_html_crossref.rb +140 -0
  64. data/rdoc/lib/rdoc/markup/to_latex.rb +328 -0
  65. data/rdoc/lib/rdoc/markup/to_test.rb +53 -0
  66. data/rdoc/lib/rdoc/markup/to_texinfo.rb +73 -0
  67. data/rdoc/lib/rdoc/markup.rb +378 -0
  68. data/rdoc/lib/rdoc/meta_method.rb +8 -0
  69. data/rdoc/lib/rdoc/normal_class.rb +18 -0
  70. data/rdoc/lib/rdoc/normal_module.rb +34 -0
  71. data/rdoc/lib/rdoc/options.rb +542 -0
  72. data/rdoc/lib/rdoc/parser/c.rb +678 -0
  73. data/rdoc/lib/rdoc/parser/perl.rb +165 -0
  74. data/rdoc/lib/rdoc/parser/ruby.rb +2904 -0
  75. data/rdoc/lib/rdoc/parser/simple.rb +39 -0
  76. data/rdoc/lib/rdoc/parser.rb +138 -0
  77. data/rdoc/lib/rdoc/rdoc.rb +375 -0
  78. data/rdoc/lib/rdoc/require.rb +32 -0
  79. data/rdoc/lib/rdoc/ri/cache.rb +187 -0
  80. data/rdoc/lib/rdoc/ri/descriptions.rb +156 -0
  81. data/rdoc/lib/rdoc/ri/display.rb +340 -0
  82. data/rdoc/lib/rdoc/ri/driver.rb +828 -0
  83. data/rdoc/lib/rdoc/ri/formatter.rb +654 -0
  84. data/rdoc/lib/rdoc/ri/paths.rb +93 -0
  85. data/rdoc/lib/rdoc/ri/reader.rb +106 -0
  86. data/rdoc/lib/rdoc/ri/util.rb +79 -0
  87. data/rdoc/lib/rdoc/ri/writer.rb +68 -0
  88. data/rdoc/lib/rdoc/ri.rb +8 -0
  89. data/rdoc/lib/rdoc/single_class.rb +8 -0
  90. data/rdoc/lib/rdoc/stats.rb +178 -0
  91. data/rdoc/lib/rdoc/task.rb +276 -0
  92. data/rdoc/lib/rdoc/tokenstream.rb +33 -0
  93. data/rdoc/lib/rdoc/top_level.rb +242 -0
  94. data/rdoc/lib/rdoc.rb +398 -0
  95. metadata +1 -1
@@ -0,0 +1,654 @@
1
+ require 'rdoc/ri'
2
+ require 'rdoc/markup'
3
+
4
+ class RDoc::RI::Formatter
5
+
6
+ attr_writer :indent
7
+ attr_accessor :output
8
+
9
+ FORMATTERS = { }
10
+
11
+ def self.for(name)
12
+ FORMATTERS[name.downcase]
13
+ end
14
+
15
+ def self.list
16
+ FORMATTERS.keys.sort.join ", "
17
+ end
18
+
19
+ def initialize(output, width, indent)
20
+ @output = output
21
+ @width = width
22
+ @indent = indent
23
+ @original_indent = indent.dup
24
+ end
25
+
26
+ def draw_line(label=nil)
27
+ len = @width
28
+ len -= (label.size + 1) if label
29
+
30
+ if len > 0 then
31
+ @output.print '-' * len
32
+ if label
33
+ @output.print ' '
34
+ bold_print label
35
+ end
36
+
37
+ @output.puts
38
+ else
39
+ @output.print '-' * @width
40
+ @output.puts
41
+
42
+ @output.puts label
43
+ end
44
+ end
45
+
46
+ def indent
47
+ return @indent unless block_given?
48
+
49
+ begin
50
+ indent = @indent.dup
51
+ @indent += @original_indent
52
+ yield
53
+ ensure
54
+ @indent = indent
55
+ end
56
+ end
57
+
58
+ def wrap(txt, prefix=@indent, linelen=@width)
59
+ return unless txt && !txt.empty?
60
+
61
+ work = conv_markup(txt)
62
+ textLen = linelen - prefix.length
63
+ patt = Regexp.new("^(.{0,#{textLen}})[ \n]")
64
+ next_prefix = prefix.tr("^ ", " ")
65
+
66
+ res = []
67
+
68
+ while work.length > textLen
69
+ if work =~ patt
70
+ res << $1
71
+ work.slice!(0, $&.length)
72
+ else
73
+ res << work.slice!(0, textLen)
74
+ end
75
+ end
76
+ res << work if work.length.nonzero?
77
+ @output.puts(prefix + res.join("\n" + next_prefix))
78
+ end
79
+
80
+ def blankline
81
+ @output.puts
82
+ end
83
+
84
+ ##
85
+ # Called when we want to ensure a new 'wrap' starts on a newline. Only
86
+ # needed for HtmlFormatter, because the rest do their own line breaking.
87
+
88
+ def break_to_newline
89
+ end
90
+
91
+ def bold_print(txt)
92
+ @output.print txt
93
+ end
94
+
95
+ def raw_print_line(txt)
96
+ @output.print txt
97
+ end
98
+
99
+ ##
100
+ # Convert HTML entities back to ASCII
101
+
102
+ def conv_html(txt)
103
+ txt = txt.gsub(/&gt;/, '>')
104
+ txt.gsub!(/&lt;/, '<')
105
+ txt.gsub!(/&quot;/, '"')
106
+ txt.gsub!(/&amp;/, '&')
107
+ txt
108
+ end
109
+
110
+ ##
111
+ # Convert markup into display form
112
+
113
+ def conv_markup(txt)
114
+ txt = txt.gsub(%r{<tt>(.*?)</tt>}, '+\1+')
115
+ txt.gsub!(%r{<code>(.*?)</code>}, '+\1+')
116
+ txt.gsub!(%r{<b>(.*?)</b>}, '*\1*')
117
+ txt.gsub!(%r{<em>(.*?)</em>}, '_\1_')
118
+ txt
119
+ end
120
+
121
+ def display_list(list)
122
+ case list.type
123
+ when :BULLET
124
+ prefixer = proc { |ignored| @indent + "* " }
125
+
126
+ when :NUMBER, :UPPERALPHA, :LOWERALPHA then
127
+ start = case list.type
128
+ when :NUMBER then 1
129
+ when :UPPERALPHA then 'A'
130
+ when :LOWERALPHA then 'a'
131
+ end
132
+
133
+ prefixer = proc do |ignored|
134
+ res = @indent + "#{start}.".ljust(4)
135
+ start = start.succ
136
+ res
137
+ end
138
+
139
+ when :LABELED, :NOTE then
140
+ longest = 0
141
+
142
+ list.contents.each do |item|
143
+ if RDoc::Markup::Flow::LI === item and item.label.length > longest then
144
+ longest = item.label.length
145
+ end
146
+ end
147
+
148
+ longest += 1
149
+
150
+ prefixer = proc { |li| @indent + li.label.ljust(longest) }
151
+
152
+ else
153
+ raise ArgumentError, "unknown list type #{list.type}"
154
+ end
155
+
156
+ list.contents.each do |item|
157
+ if RDoc::Markup::Flow::LI === item then
158
+ prefix = prefixer.call item
159
+ display_flow_item item, prefix
160
+ else
161
+ display_flow_item item
162
+ end
163
+ end
164
+ end
165
+
166
+ def display_flow_item(item, prefix = @indent)
167
+ case item
168
+ when RDoc::Markup::Flow::P, RDoc::Markup::Flow::LI
169
+ wrap(conv_html(item.body), prefix)
170
+ blankline
171
+
172
+ when RDoc::Markup::Flow::LIST
173
+ display_list(item)
174
+
175
+ when RDoc::Markup::Flow::VERB
176
+ display_verbatim_flow_item(item, @indent)
177
+
178
+ when RDoc::Markup::Flow::H
179
+ display_heading(conv_html(item.text), item.level, @indent)
180
+
181
+ when RDoc::Markup::Flow::RULE
182
+ draw_line
183
+
184
+ else
185
+ raise RDoc::Error, "Unknown flow element: #{item.class}"
186
+ end
187
+ end
188
+
189
+ def display_verbatim_flow_item(item, prefix=@indent)
190
+ item.body.split(/\n/).each do |line|
191
+ @output.print @indent, conv_html(line), "\n"
192
+ end
193
+ blankline
194
+ end
195
+
196
+ def display_heading(text, level, indent)
197
+ text = strip_attributes text
198
+
199
+ case level
200
+ when 1 then
201
+ ul = "=" * text.length
202
+ @output.puts
203
+ @output.puts text.upcase
204
+ @output.puts ul
205
+
206
+ when 2 then
207
+ ul = "-" * text.length
208
+ @output.puts
209
+ @output.puts text
210
+ @output.puts ul
211
+ else
212
+ @output.print indent, text, "\n"
213
+ end
214
+
215
+ @output.puts
216
+ end
217
+
218
+ def display_flow(flow)
219
+ flow.each do |f|
220
+ display_flow_item(f)
221
+ end
222
+ end
223
+
224
+ def strip_attributes(text)
225
+ text.gsub(/(<\/?(?:b|code|em|i|tt)>)/, '')
226
+ end
227
+
228
+ end
229
+
230
+ ##
231
+ # Handle text with attributes. We're a base class: there are different
232
+ # presentation classes (one, for example, uses overstrikes to handle bold and
233
+ # underlining, while another using ANSI escape sequences.
234
+
235
+ class RDoc::RI::AttributeFormatter < RDoc::RI::Formatter
236
+
237
+ BOLD = 1
238
+ ITALIC = 2
239
+ CODE = 4
240
+
241
+ ATTR_MAP = {
242
+ "b" => BOLD,
243
+ "code" => CODE,
244
+ "em" => ITALIC,
245
+ "i" => ITALIC,
246
+ "tt" => CODE
247
+ }
248
+
249
+ AttrChar = Struct.new :char, :attr
250
+
251
+ class AttributeString
252
+ attr_reader :txt
253
+
254
+ def initialize
255
+ @txt = []
256
+ @optr = 0
257
+ end
258
+
259
+ def <<(char)
260
+ @txt << char
261
+ end
262
+
263
+ def empty?
264
+ @optr >= @txt.length
265
+ end
266
+
267
+ # accept non space, then all following spaces
268
+ def next_word
269
+ start = @optr
270
+ len = @txt.length
271
+
272
+ while @optr < len && @txt[@optr].char != " "
273
+ @optr += 1
274
+ end
275
+
276
+ while @optr < len && @txt[@optr].char == " "
277
+ @optr += 1
278
+ end
279
+
280
+ @txt[start...@optr]
281
+ end
282
+ end
283
+
284
+ ##
285
+ # Overrides base class. Looks for <tt>...</tt> etc sequences and generates
286
+ # an array of AttrChars. This array is then used as the basis for the
287
+ # split.
288
+
289
+ def wrap(txt, prefix=@indent, linelen=@width)
290
+ return unless txt && !txt.empty?
291
+
292
+ txt = add_attributes_to(txt)
293
+ next_prefix = prefix.tr("^ ", " ")
294
+ linelen -= prefix.size
295
+
296
+ line = []
297
+
298
+ until txt.empty?
299
+ word = txt.next_word
300
+ if word.size + line.size > linelen
301
+ write_attribute_text(prefix, line)
302
+ prefix = next_prefix
303
+ line = []
304
+ end
305
+ line.concat(word)
306
+ end
307
+
308
+ write_attribute_text(prefix, line) if line.length > 0
309
+ end
310
+
311
+ protected
312
+
313
+ def write_attribute_text(prefix, line)
314
+ @output.print prefix
315
+ line.each do |achar|
316
+ @output.print achar.char
317
+ end
318
+ @output.puts
319
+ end
320
+
321
+ def bold_print(txt)
322
+ @output.print txt
323
+ end
324
+
325
+ private
326
+
327
+ def add_attributes_to(txt)
328
+ tokens = txt.split(%r{(</?(?:b|code|em|i|tt)>)})
329
+ text = AttributeString.new
330
+ attributes = 0
331
+ tokens.each do |tok|
332
+ case tok
333
+ when %r{^</(\w+)>$} then attributes &= ~(ATTR_MAP[$1]||0)
334
+ when %r{^<(\w+)>$} then attributes |= (ATTR_MAP[$1]||0)
335
+ else
336
+ tok.split(//).each {|ch| text << AttrChar.new(ch, attributes)}
337
+ end
338
+ end
339
+ text
340
+ end
341
+
342
+ end
343
+
344
+ ##
345
+ # This formatter generates overstrike-style formatting, which works with
346
+ # pagers such as man and less.
347
+
348
+ class RDoc::RI::OverstrikeFormatter < RDoc::RI::AttributeFormatter
349
+
350
+ BS = "\C-h"
351
+
352
+ def write_attribute_text(prefix, line)
353
+ @output.print prefix
354
+
355
+ line.each do |achar|
356
+ attr = achar.attr
357
+ @output.print "_", BS if (attr & (ITALIC + CODE)) != 0
358
+ @output.print achar.char, BS if (attr & BOLD) != 0
359
+ @output.print achar.char
360
+ end
361
+
362
+ @output.puts
363
+ end
364
+
365
+ ##
366
+ # Draw a string in bold
367
+
368
+ def bold_print(text)
369
+ text.split(//).each do |ch|
370
+ @output.print ch, BS, ch
371
+ end
372
+ end
373
+
374
+ end
375
+
376
+ ##
377
+ # This formatter uses ANSI escape sequences to colorize stuff works with
378
+ # pagers such as man and less.
379
+
380
+ class RDoc::RI::AnsiFormatter < RDoc::RI::AttributeFormatter
381
+
382
+ def initialize(*args)
383
+ super
384
+ @output.print "\033[0m"
385
+ end
386
+
387
+ def write_attribute_text(prefix, line)
388
+ @output.print prefix
389
+ curr_attr = 0
390
+ line.each do |achar|
391
+ attr = achar.attr
392
+ if achar.attr != curr_attr
393
+ update_attributes(achar.attr)
394
+ curr_attr = achar.attr
395
+ end
396
+ @output.print achar.char
397
+ end
398
+ update_attributes(0) unless curr_attr.zero?
399
+ @output.puts
400
+ end
401
+
402
+ def bold_print(txt)
403
+ @output.print "\033[1m#{txt}\033[m"
404
+ end
405
+
406
+ HEADINGS = {
407
+ 1 => ["\033[1;32m", "\033[m"],
408
+ 2 => ["\033[4;32m", "\033[m"],
409
+ 3 => ["\033[32m", "\033[m"],
410
+ }
411
+
412
+ def display_heading(text, level, indent)
413
+ level = 3 if level > 3
414
+ heading = HEADINGS[level]
415
+ @output.print indent
416
+ @output.print heading[0]
417
+ @output.print strip_attributes(text)
418
+ @output.puts heading[1]
419
+ end
420
+
421
+ private
422
+
423
+ ATTR_MAP = {
424
+ BOLD => "1",
425
+ ITALIC => "33",
426
+ CODE => "36"
427
+ }
428
+
429
+ def update_attributes(attr)
430
+ str = "\033["
431
+ for quality in [ BOLD, ITALIC, CODE]
432
+ unless (attr & quality).zero?
433
+ str << ATTR_MAP[quality]
434
+ end
435
+ end
436
+ @output.print str, "m"
437
+ end
438
+
439
+ end
440
+
441
+ ##
442
+ # This formatter uses HTML.
443
+
444
+ class RDoc::RI::HtmlFormatter < RDoc::RI::AttributeFormatter
445
+
446
+ ##
447
+ # We depend on HTML4-conforming user agents to ignore an empty p element
448
+
449
+ def blankline
450
+ @output.puts '<p />'
451
+ end
452
+
453
+ ##
454
+ # Emboldens +text+
455
+
456
+ def bold_print(text)
457
+ tag("b") { text }
458
+ end
459
+
460
+ ##
461
+ # Outputs a forced line break element
462
+
463
+ def break_to_newline
464
+ @output.puts '<br />'
465
+ end
466
+
467
+ ##
468
+ # Outputs heading elements for +text+ with +level+ up to 4. Ignores
469
+ # +indent+.
470
+
471
+ def display_heading(text, level, indent)
472
+ level = 4 if level > 4
473
+ tag("h#{level}") { text }
474
+ @output.puts
475
+ end
476
+
477
+ ##
478
+ # Outputs +list+ which is displayed as follows:
479
+ #
480
+ # BULLET:: unordered list
481
+ # NUMBER:: ordered list
482
+ # LABELED:: definition list
483
+ # NOTE:: table
484
+
485
+ def display_list(list)
486
+ case list.type
487
+ when :BULLET then
488
+ list_type = "ul"
489
+ prefixer = proc { |ignored| '<li>' }
490
+ suffix = '</li>'
491
+
492
+ when :NUMBER, :UPPERALPHA, :LOWERALPHA then
493
+ list_type = "ol"
494
+ prefixer = proc { |ignored| '<li>' }
495
+ suffix = '</li>'
496
+
497
+ when :LABELED then
498
+ list_type = "dl"
499
+ prefixer = proc do |li|
500
+ "<dt><b>#{escape li.label}</b></dt><dd>"
501
+ end
502
+ suffix = '</dd>'
503
+
504
+ when :NOTE then
505
+ list_type = "table"
506
+ prefixer = proc do |li|
507
+ %{<tr valign="top"><td>#{li.label.gsub(/ /, '&nbsp;')}</td><td>}
508
+ end
509
+ suffix = '</td></tr>'
510
+ else
511
+ fail "unknown list type"
512
+ end
513
+
514
+ @output.print "<#{list_type}>"
515
+
516
+ list.contents.each do |item|
517
+ if item.kind_of? RDoc::Markup::Flow::LI
518
+ prefix = prefixer.call item
519
+ @output.print prefix
520
+ display_flow_item item, prefix
521
+ @output.print suffix
522
+ else
523
+ display_flow_item item
524
+ end
525
+ end
526
+
527
+ @output.print "</#{list_type}>"
528
+ end
529
+
530
+ ##
531
+ # Outputs a preformatted section for +item+. +prefix+ is ignored.
532
+
533
+ def display_verbatim_flow_item(item, prefix=@indent)
534
+ @output.print '<pre>'
535
+
536
+ item.body.split(/\n/).each do |line|
537
+ @output.puts escape(line)
538
+ end
539
+
540
+ @output.puts '</pre>'
541
+ end
542
+
543
+ ##
544
+ # Outputs a horizontal rule element, optionally labeled above with +label+ in
545
+ # bold.
546
+
547
+ def draw_line(label = nil)
548
+ bold_print label if label
549
+
550
+ @output.puts "<hr />"
551
+ end
552
+
553
+ def write_attribute_text(prefix, line)
554
+ curr_attr = 0
555
+
556
+ line.each do |achar|
557
+ attr = achar.attr
558
+ if achar.attr != curr_attr then
559
+ update_attributes curr_attr, achar.attr
560
+ curr_attr = achar.attr
561
+ end
562
+ @output.print escape(achar.char)
563
+ end
564
+
565
+ update_attributes curr_attr, 0 unless curr_attr.zero?
566
+ end
567
+
568
+ private
569
+
570
+ ATTR_MAP = {
571
+ BOLD => "b>",
572
+ ITALIC => "i>",
573
+ CODE => "tt>"
574
+ }
575
+
576
+ def update_attributes(current, wanted)
577
+ str = ""
578
+ # first turn off unwanted ones
579
+ off = current & ~wanted
580
+ for quality in [ BOLD, ITALIC, CODE]
581
+ if (off & quality) > 0
582
+ str << "</" + ATTR_MAP[quality]
583
+ end
584
+ end
585
+
586
+ # now turn on wanted
587
+ for quality in [ BOLD, ITALIC, CODE]
588
+ unless (wanted & quality).zero?
589
+ str << "<" << ATTR_MAP[quality]
590
+ end
591
+ end
592
+ @output.print str
593
+ end
594
+
595
+ def tag(code)
596
+ @output.print("<#{code}>")
597
+ @output.print(yield)
598
+ @output.print("</#{code}>")
599
+ end
600
+
601
+ def escape(str)
602
+ str = str.gsub(/&/n, '&amp;')
603
+ str.gsub!(/\"/n, '&quot;')
604
+ str.gsub!(/>/n, '&gt;')
605
+ str.gsub!(/</n, '&lt;')
606
+ str
607
+ end
608
+
609
+ end
610
+
611
+ ##
612
+ # This formatter reduces extra lines for a simpler output. It improves way
613
+ # output looks for tools like IRC bots.
614
+
615
+ class RDoc::RI::SimpleFormatter < RDoc::RI::Formatter
616
+
617
+ ##
618
+ # No extra blank lines
619
+
620
+ def blankline
621
+ end
622
+
623
+ ##
624
+ # Display labels only, no lines
625
+
626
+ def draw_line(label=nil)
627
+ unless label.nil? then
628
+ bold_print(label)
629
+ @output.puts
630
+ end
631
+ end
632
+
633
+ ##
634
+ # Place heading level indicators inline with heading.
635
+
636
+ def display_heading(text, level, indent)
637
+ text = strip_attributes(text)
638
+ case level
639
+ when 1
640
+ @output.puts "= " + text.upcase
641
+ when 2
642
+ @output.puts "-- " + text
643
+ else
644
+ @output.print indent, text, "\n"
645
+ end
646
+ end
647
+
648
+ end
649
+
650
+ RDoc::RI::Formatter::FORMATTERS['plain'] = RDoc::RI::Formatter
651
+ RDoc::RI::Formatter::FORMATTERS['simple'] = RDoc::RI::SimpleFormatter
652
+ RDoc::RI::Formatter::FORMATTERS['bs'] = RDoc::RI::OverstrikeFormatter
653
+ RDoc::RI::Formatter::FORMATTERS['ansi'] = RDoc::RI::AnsiFormatter
654
+ RDoc::RI::Formatter::FORMATTERS['html'] = RDoc::RI::HtmlFormatter