#!/usr/bin/ruby # # rebuildGrooves # Vocalese # # Created by Matthias Neeracher on 2/5/07. # Copyright (c) 2007 __MyCompanyName__. All rights reserved. # require 'find' grooves = {} Find.find(ARGV[0]) do |f| if File.directory?(f) Find.prune if File.exist?("f/MMAIGNORE") elsif f =~ %r|.*/(\S+?).mma$| style = $1 g = {} doc = "" groove= "" File.open(f) do |file| inDoc = false inCont= false file.each do |line| if line =~ /^\s*Begin\s+Doc\s*$/ inDoc = true elsif inDoc if line =~ /^\s*End\s*$/ inDoc = false else doc = doc+" "+line.strip end elsif line =~ /^\s*DefGroove\s+(\S+)\s+(.+?)\s*$/ groove = $1 gdoc = $2 if gdoc =~ /(.*?)\s+\\\s*$/ gdoc = $1 inCont = true end g[groove] = gdoc elsif inCont if line =~ /^\s*(.*?)\s*(\\)?\s*$/ g[groove] = g[groove] + " " + $1 inCont = $2 != nil else inCont = false end end end end unless g.empty? g[".DESC"] = doc.lstrip grooves[style] = g end end end OUT = File.new(ARGV[1], "w") OUT.print <<'END_HEADER' END_HEADER def xmlesc(s) s.gsub('&', '&').gsub('<', '<').gsub('>', '&rt;') end grooves.each do |style,grooves| OUT.puts "\t#{xmlesc(style)}" OUT.puts "\t" grooves.each do |name,desc| OUT.puts "\t\t#{xmlesc(name)}" OUT.puts "\t\t#{xmlesc(desc)}" end OUT.puts "\t" end OUT.puts "" OUT.puts ""