In Files

  • rdoc/ri/formatter.rb

Files

Class/Module Index [+]

Quicksearch

RDoc::RI::HtmlFormatter

This formatter uses HTML.

Constants

ATTR_MAP

Public Instance Methods

blankline() click to toggle source
 
               # File rdoc/ri/formatter.rb, line 470
def blankline()
  @output.puts("<p>")
end
            
bold_print(txt) click to toggle source
 
               # File rdoc/ri/formatter.rb, line 466
def bold_print(txt)
  tag("b") { txt }
end
            
break_to_newline() click to toggle source
 
               # File rdoc/ri/formatter.rb, line 474
def break_to_newline
  @output.puts("<br>")
end
            
display_heading(text, level, indent) click to toggle source
 
               # File rdoc/ri/formatter.rb, line 478
def display_heading(text, level, indent)
  level = 4 if level > 4
  tag("h#{level}") { text }
  @output.puts
end
            
display_list(list) click to toggle source
 
               # File rdoc/ri/formatter.rb, line 484
def display_list(list)
  case list.type
  when :BULLET then
    list_type = "ul"
    prefixer = proc { |ignored| "<li>" }

  when :NUMBER, :UPPERALPHA, :LOWERALPHA then
    list_type = "ol"
    prefixer = proc { |ignored| "<li>" }

  when :LABELED then
    list_type = "dl"
    prefixer = proc do |li|
      "<dt><b>" + escape(li.label) + "</b><dd>"
    end

  when :NOTE then
    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

  @output.print "<#{list_type}>"
  list.contents.each do |item|
    if item.kind_of? RDoc::Markup::Flow::LI
      prefix = prefixer.call(item)
      @output.print prefix
      display_flow_item(item, prefix)
    else
      display_flow_item(item)
    end
  end
  @output.print "</#{list_type}>"
end
            
display_verbatim_flow_item(item, prefix=@indent) click to toggle source
 
               # File rdoc/ri/formatter.rb, line 522
def display_verbatim_flow_item(item, prefix=@indent)
  @output.print("<pre>")
  item.body.split(/\n/).each do |line|
    @output.puts conv_html(line)
  end
  @output.puts("</pre>")
end
            
draw_line(label=nil) click to toggle source
 
               # File rdoc/ri/formatter.rb, line 459
def draw_line(label=nil)
  if label != nil
    bold_print(label)
  end
  @output.puts("<hr>")
end
            
write_attribute_text(prefix, line) click to toggle source
 
               # File rdoc/ri/formatter.rb, line 446
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
    @output.print(escape(achar.char))
  end
  update_attributes(curr_attr, 0) unless curr_attr.zero?
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus