Parent

RDoc::Markup::Formatter

Base class for RDoc markup formatters

Formatters use a visitor pattern to convert content into output.

Constants

InlineTag

Public Class Methods

new() click to toggle source

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

Public Instance Methods

add_tag(name, start, stop) click to toggle source

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
annotate(tag) click to toggle source

Allows tag to be decorated with additional information.

    # File lib/rdoc/markup/formatter.rb, line 36
36:   def annotate(tag)
37:     tag
38:   end
convert(content) click to toggle source

Marks up content

    # File lib/rdoc/markup/formatter.rb, line 43
43:   def convert(content)
44:     @markup.convert content, self
45:   end
convert_flow(flow) click to toggle source

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
convert_special(special) click to toggle source

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
convert_string(string) click to toggle source

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
in_tt?() click to toggle source

Are we currently inside tt tags?

     # File lib/rdoc/markup/formatter.rb, line 100
100:   def in_tt?
101:     @in_tt > 0
102:   end
off_tags(res, item) click to toggle source
     # File lib/rdoc/markup/formatter.rb, line 116
116:   def off_tags res, item
117:     attr_mask = item.turn_off
118:     return if attr_mask.zero?
119: 
120:     @attr_tags.reverse_each do |tag|
121:       if attr_mask & tag.bit != 0 then
122:         @in_tt -= 1 if tt? tag
123:         res << annotate(tag.off)
124:       end
125:     end
126:   end
on_tags(res, item) click to toggle source
     # File lib/rdoc/markup/formatter.rb, line 104
104:   def on_tags res, item
105:     attr_mask = item.turn_on
106:     return if attr_mask.zero?
107: 
108:     @attr_tags.each do |tag|
109:       if attr_mask & tag.bit != 0 then
110:         res << annotate(tag.on)
111:         @in_tt += 1 if tt? tag
112:       end
113:     end
114:   end
tt?(tag) click to toggle source

Is tag a tt tag?

     # File lib/rdoc/markup/formatter.rb, line 131
131:   def tt? tag
132:     tag.bit == @tt_bit
133:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.