In Files

  • rdoc/ri/ri_formatter.rb

Files

Class/Module Index [+]

Quicksearch

RI::HtmlFormatter

This formatter uses HTML.

Constants

ATTR_MAP

Public Class Methods

new(*args) click to toggle source
 
               # File rdoc/ri/ri_formatter.rb, line 470
def initialize(*args)
  super
end
            

Public Instance Methods

blankline() click to toggle source
 
               # File rdoc/ri/ri_formatter.rb, line 498
def blankline()
  puts("<p>")
end
            
bold_print(txt) click to toggle source
 
               # File rdoc/ri/ri_formatter.rb, line 494
def bold_print(txt)
  tag("b") { txt }
end
            
break_to_newline() click to toggle source
 
               # File rdoc/ri/ri_formatter.rb, line 502
def break_to_newline
  puts("<br>")
end
            
display_heading(text, level, indent) click to toggle source
 
               # File rdoc/ri/ri_formatter.rb, line 506
def display_heading(text, level, indent)
  level = 4 if level > 4
  tag("h#{level}") { text }
  puts
end
            
display_list(list) click to toggle source
 
               # File rdoc/ri/ri_formatter.rb, line 514
def display_list(list)

  case list.type
  when SM::ListBase::BULLET 
    list_type = "ul"
    prefixer = proc { |ignored| "<li>" }

  when SM::ListBase::NUMBER,
  SM::ListBase::UPPERALPHA,
  SM::ListBase::LOWERALPHA
    list_type = "ol"
    prefixer = proc { |ignored| "<li>" }
    
  when SM::ListBase::LABELED
    list_type = "dl"
    prefixer = proc do |li|
      "<dt><b>" + escape(li.label) + "</b><dd>"
    end

  when SM::ListBase::NOTE
    list_type = "table"
    prefixer = proc do |li|
      %Q{<tr valign="top"><td>#{li.label.gsub(/ /, '&nbsp;')}</td><td>}
    end
  else
    fail "unknown list type"
  end

  print "<#{list_type}>"
  list.contents.each do |item|
    if item.kind_of? SM::Flow::LI
      prefix = prefixer.call(item)
      print prefix
      display_flow_item(item, prefix)
    else
      display_flow_item(item)
    end
  end
  print "</#{list_type}>"
end
            
display_verbatim_flow_item(item, prefix=@indent) click to toggle source
 
               # File rdoc/ri/ri_formatter.rb, line 555
def display_verbatim_flow_item(item, prefix=@indent)
    print("<pre>")
    puts item.body
    puts("</pre>")
end
            
draw_line(label=nil) click to toggle source
 
               # File rdoc/ri/ri_formatter.rb, line 487
def draw_line(label=nil)
  if label != nil
    bold_print(label)
  end
  puts("<hr>")
end
            
write_attribute_text(prefix, line) click to toggle source
 
               # File rdoc/ri/ri_formatter.rb, line 474
def write_attribute_text(prefix, line)
  curr_attr = 0
  line.each do |achar|
    attr = achar.attr
    if achar.attr != curr_attr
      update_attributes(curr_attr, achar.attr)
      curr_attr = achar.attr
    end
    print(escape(achar.char))
  end
  update_attributes(curr_attr, 0) unless curr_attr.zero?
end