Class: RI::ClassDescription

Inherits:
Object show all
Defined in:
lib/ihelp.rb

Instance Method Summary collapse

Instance Method Details

#to_html(container_tag = "div", header_tag = "h1", methods_header_tag = "h2", methods_tag = "p") ⇒ Object

Creates HTML element from the ClassDescription. Uses container_tag as the root node name and header_tag as the tag for the header element that contains the classes name. Uses methods_header_tag as the tag for the “Class/Instance Methods” method list headers. Uses methods_tag as the tag for the method lists.

Returns a REXML document with container_tag as the root element name.



516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/ihelp.rb', line 516

def to_html(container_tag="div", header_tag="h1",
            methods_header_tag="h2", methods_tag="p")
  doc = REXML::Document.new
  root = doc.add_element(container_tag)
  header = root.add_element(header_tag)
  header.add_text(full_name)
  comment.each{|c|
    tag = c.class.to_s.split("::").last
    tag = "PRE" if tag == "VERB"
    xmlstr = "<#{tag}>#{c.body}</#{tag}>"
    c_doc = REXML::Document.new(xmlstr)
    root.add_element( c_doc.root )
  }
  root.add_element(methods_header_tag).add_text("Class Methods")
  cmethods = root.add_element(methods_tag)
  class_methods[0...-1].each{|m|
    cmethods.add(m.to_html.root)
    cmethods.add_text(", ")
  }
  cmethods.add(class_methods.last.to_html.root)
  root.add_element(methods_header_tag).add_text("Instance Methods")
  imethods = root.add_element(methods_tag)
  instance_methods[0...-1].each{|m|
    imethods.add(m.to_html.root)
    imethods.add_text(", ")
  }
  imethods.add(instance_methods.last.to_html.root)
  doc
end