Class: RDocF95::RI::HtmlFormatter

Inherits:
AttributeFormatter show all
Defined in:
lib/rdoc-f95/ri/formatter.rb

Overview

This formatter uses HTML.

Constant Summary

Constants inherited from AttributeFormatter

AttributeFormatter::BOLD, AttributeFormatter::CODE, AttributeFormatter::ITALIC

Constants inherited from Formatter

Formatter::FORMATTERS

Instance Attribute Summary

Attributes inherited from Formatter

#indent, #output

Instance Method Summary collapse

Methods inherited from AttributeFormatter

#wrap

Methods inherited from Formatter

#conv_html, #conv_markup, #display_flow, #display_flow_item, for, #initialize, list, #raw_print_line, #strip_attributes, #wrap

Constructor Details

This class inherits a constructor from RDocF95::RI::Formatter

Instance Method Details

#blanklineObject



457
458
459
# File 'lib/rdoc-f95/ri/formatter.rb', line 457

def blankline()
  @output.puts("<p>")
end

#bold_print(txt) ⇒ Object



453
454
455
# File 'lib/rdoc-f95/ri/formatter.rb', line 453

def bold_print(txt)
  tag("b") { txt }
end

#break_to_newlineObject



461
462
463
# File 'lib/rdoc-f95/ri/formatter.rb', line 461

def break_to_newline
  @output.puts("<br>")
end

#display_heading(text, level, indent) ⇒ Object



465
466
467
468
469
# File 'lib/rdoc-f95/ri/formatter.rb', line 465

def display_heading(text, level, indent)
  level = 4 if level > 4
  tag("h#{level}") { text }
  @output.puts
end

#display_list(list) ⇒ Object



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
# File 'lib/rdoc-f95/ri/formatter.rb', line 471

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? RDocF95::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) ⇒ Object



509
510
511
512
513
514
515
# File 'lib/rdoc-f95/ri/formatter.rb', line 509

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) ⇒ Object



446
447
448
449
450
451
# File 'lib/rdoc-f95/ri/formatter.rb', line 446

def draw_line(label=nil)
  if label != nil
    bold_print(label)
  end
  @output.puts("<hr>")
end

#write_attribute_text(prefix, line) ⇒ Object



433
434
435
436
437
438
439
440
441
442
443
444
# File 'lib/rdoc-f95/ri/formatter.rb', line 433

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