# 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
# 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
# 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
# File lib/rest_htmlprinter.rb, line 119 def print_body body @html.p "Body: " + body.name end
# File lib/rest_htmlprinter.rb, line 156 def print_contents contents @html.tag! "h#{contents.level}", "Table of Contents" @html.p do |p| p << create_contents_list( contents.root, 1 ) end end
# File lib/rest_htmlprinter.rb, line 111 def print_host host @html.p "Host: " + host.name end
# File lib/rest_htmlprinter.rb, line 108 def print_parameter parameter end
# File lib/rest_htmlprinter.rb, line 63 def print_request request @html.div( "class" => "request" ) do @html.p do @html.a( "name" => request.id ) do @html.b request.to_s end end if false host = request.host if ( host ) @html.p "Host: " + host.name end end if request.parameters.size > 0 @html.p "Arguments:" @html.ul do request.parameters.each do |p| @html.li p.to_s end end end request.print_children self end end
# File lib/rest_htmlprinter.rb, line 115 def print_result result @html.p "Result: " + result.name end
# File lib/rest_htmlprinter.rb, line 55 def print_section section if ( !section.root? ) tag = "h#{section.level}" @html.tag!( tag, section ) end section.print_children self end
# File lib/rest_htmlprinter.rb, line 99 def print_text text @html.p do |p| text.text.each do |t| replace_docbook_tags t p << t << "\n" end end end
# File lib/rest_htmlprinter.rb, line 187 def print_version version @html.p "Version: " + version.to_s end
# File lib/rest_htmlprinter.rb, line 131 def print_xml_links title, xmlname, schema example = xmlname + ".xml" if ( !schema || schema.empty? ) schema = xmlname + ".xsd" end @xml_examples[ example ] = true @xml_schemas[ schema ] = true @html.p do |p| p << title p << ": " has_example = XmlFile.exist? example has_schema = XmlFile.exist? schema if has_example @html.a( "Example", "href" => example ) end if has_schema p << " "; @html.a( "Schema", "href" => schema ) end if( !has_example && !has_schema ) p << xmlname end end end
Generated with the Darkfish Rdoc Generator 2.