Object
Base class for RDoc markup formatters
Formatters use a visitor pattern to convert content into output.
Creates a new Formatter
# File lib/rdoc/markup/formatter.rb, line 15
15: def initialize
16: @markup = RDoc::Markup.new
17: @am = @markup.attribute_manager
18: @attr_tags = []
19:
20: @in_tt = 0
21: @tt_bit = RDoc::Markup::Attribute.bitmap_for :TT
22: end
Add a new set of tags for an attribute. We allow separate start and end tags for flexibility
# File lib/rdoc/markup/formatter.rb, line 28
28: def add_tag(name, start, stop)
29: attr = RDoc::Markup::Attribute.bitmap_for name
30: @attr_tags << InlineTag.new(attr, start, stop)
31: end
Allows tag to be decorated with additional information.
# File lib/rdoc/markup/formatter.rb, line 36
36: def annotate(tag)
37: tag
38: end
Marks up content
# File lib/rdoc/markup/formatter.rb, line 43
43: def convert(content)
44: @markup.convert content, self
45: end
Converts flow items flow
# File lib/rdoc/markup/formatter.rb, line 50
50: def convert_flow(flow)
51: res = []
52:
53: flow.each do |item|
54: case item
55: when String then
56: res << convert_string(item)
57: when RDoc::Markup::AttrChanger then
58: off_tags res, item
59: on_tags res, item
60: when RDoc::Markup::Special then
61: res << convert_special(item)
62: else
63: raise "Unknown flow element: #{item.inspect}"
64: end
65: end
66:
67: res.join
68: end
Converts added specials. See RDoc::Markup#add_special
# File lib/rdoc/markup/formatter.rb, line 73
73: def convert_special(special)
74: handled = false
75:
76: RDoc::Markup::Attribute.each_name_of special.type do |name|
77: method_name = "handle_special_#{name}"
78:
79: if respond_to? method_name then
80: special.text = send method_name, special
81: handled = true
82: end
83: end
84:
85: raise "Unhandled special: #{special}" unless handled
86:
87: special.text
88: end
Converts a string to be fancier if desired
# File lib/rdoc/markup/formatter.rb, line 93
93: def convert_string string
94: string
95: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.