Class: Wrongdoc::Merge

Inherits:
Object
  • Object
show all
Includes:
ParseXML
Defined in:
lib/wrongdoc/merge.rb

Instance Method Summary collapse

Methods included from ParseXML

#parse_xml

Constructor Details

#initialize(opts) ⇒ Merge

Returns a new instance of Merge.



4
5
6
# File 'lib/wrongdoc/merge.rb', line 4

def initialize(opts)
  @merge_html = opts[:merge_html] || {}
end

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/wrongdoc/merge.rb', line 8

def run
  @merge_html.each do |file, source|
    rdoc_html = "doc/#{file}.html"
    src = Nokogiri::XML.fragment(File.read(source))
    File.open(rdoc_html, "a+") { |fp|
      doc = parse_xml(fp.read)
      doc.search("div#documentation")[0].add_child(src)
      fp.truncate 0
      fp.write doc.to_xhtml
    }
  end
end