Class RDoc::RI::HtmlFormatter

  1. lib/rdoc/ri/formatter.rb
ClassModule NormalModule AnonClass SingleClass NormalClass AnyMethod GhostMethod MetaMethod CodeObject Context Alias Attr Constant Require Include TopLevel RubyLex IRB RuntimeError Error Error Token TkUnknownChar TkVal TkNode TkOp TkId TkError TkOPASGN TkKW AttributeFormatter HtmlFormatter OverstrikeFormatter AnsiFormatter NamedThing AliasName IncludedModule Constant Attribute MethodSummary DefaultDisplay ClassEntry TopLevelEntry Formatter SimpleFormatter Description MethodDescription ModuleDescription ClassDescription HTML XML HTMLInOne CHM Method Context Class File Generator::MarkUp TEXINFO SimpleElement Port Element Node Subgraph Edge Digraph Stats Parser Options RDoc TemplatePage Markup Diagram NameDescriptor Cache Reader Writer Driver MethodEntry RI TexinfoTemplate AllReferences RubyToken Display Paths RI MarkUp Generator TokenStream DOT RDoc dot/f_5.png

This formatter uses HTML.

Constants

ATTR_MAP = { BOLD => "b>", ITALIC => "i>", CODE => "tt>" }

Public instance methods

blankline ()
[show source]
# File lib/rdoc/ri/formatter.rb, line 470
  def blankline()
    @output.puts("<p>")
  end
bold_print (txt)
[show source]
# File lib/rdoc/ri/formatter.rb, line 466
  def bold_print(txt)
    tag("b") { txt }
  end
break_to_newline ()
[show source]
# File lib/rdoc/ri/formatter.rb, line 474
  def break_to_newline
    @output.puts("<br>")
  end
display_heading (text, level, indent)
[show source]
# File lib/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)
[show source]
# File lib/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|
        %{<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)
[show source]
# File lib/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)
[show source]
# File lib/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)
[show source]
# File lib/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