require "rexml/document" include REXML #so that we don't have to prefix with REXML every time class EclipseDoc def initialize(dir=nil) Dir.chdir(dir) if dir end def get_files Dir["*.xml"] end def process_file(file) doc = Document.new File.new(file) result = Array.[] doc.elements.each("templates/template") { |element| result << [element.attributes["name"],element.attributes["description"]]} result end def output_file(file,array) name = File.basename(file, ".xml") f = File.new(name + ".txt", "w+") f << "h2. " << name.capitalize << "\n" array.each do |entry| f << "* " << entry[0] << " - " << entry[1] << "\n" end f.close end e = EclipseDoc.new(Dir.getwd) a = e.get_files a.each do |file| rt = e.process_file(file) e.output_file(file,rt) end end