Parent

HtmlPrinter

Attributes

output_dir[RW]

Public Class Methods

new() click to toggle source
# File lib/rest_htmlprinter.rb, line 10
def initialize
  super()
  @output_dir = "html"
  @xml_examples = Hash.new
  @xml_schemas = Hash.new

  @docbook_tag_mapping = {
    "command" => "tt",
    "filename" => "tt",
    "emphasis" => "em",
    "replaceable" => "em",
  }

end

Public Instance Methods

create_contents_list(section, min_level) click to toggle source
# File lib/rest_htmlprinter.rb, line 163
def create_contents_list section, min_level
  result = ""
  section.children.each do |s|
    if ( s.is_a? Section )
      result += create_contents_list s, min_level      
    end
    if ( s.is_a? Request )
      result += "<li><a href=\"##{s.id}\">" + h( s.to_s ) + "</a></li>\n"
    end
  end
  endresult = ""
  if ( !result.empty? )
    if ( section.level > min_level )
      endresult = "<li>" + h( section.to_s ) + "</li>\n"
    end
    if ( section.level >= min_level )
      endresult += "<ul>\n" + result + "</ul>\n"
    else
      endresult = result
    end
  end
  endresult 
end
do_finish() click to toggle source
# File lib/rest_htmlprinter.rb, line 34
def do_finish
  puts "Written #{@index.path}"
  
  @xml_examples.each do |f,b|
    if !XmlFile.exist?( f )
      STDERR.puts "XML Example '#{f}' is missing."
    else
      XmlFile.copy f, @output_dir
    end
  end
  @xml_schemas.each do |f,b|
    if !XmlFile.exist?( f )
      STDERR.puts "XML Schema '#{f}' is missing."
    else
      XmlFile.copy f, @output_dir
    end
  end
  
  @index.close
end
do_prepare() click to toggle source
# File lib/rest_htmlprinter.rb, line 25
def do_prepare
  unless File.exists? @output_dir
    Dir.mkdir @output_dir
  end
  @index = File.new( @output_dir + "/index.html", "w" )
  @html = Builder::XmlMarkup.new( :target => @index, :indent => 2 )
  @html.comment! "This file was generated by restility at #{Time.now}"
end
replace_docbook_tags(text) click to toggle source
# File lib/rest_htmlprinter.rb, line 92
def replace_docbook_tags text
  @docbook_tag_mapping.each do |docbook, html|
    text.gsub! "<#{docbook}>", "<#{html}>"
    text.gsub! "</#{docbook}>", "</#{html}>"
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.