require 'erb' require 'rdoc/template' require 'yaml' LSL_VERSION = '1.13' rdoc_trove = { 'SHILL_UPDATE_NOTICE' => "LSL keywords updated #{Time.new.strftime("%d %b %Y")} for LSL #{LSL_VERSION} by http://adammarker.org/shill" } functions, events, constants = [] # Load raw materials of keywords and function/event signatures keywords = YAML::load_file('keywords.yaml') signatures = YAML::load_file('signatures.yaml') # Fill the data stores needed for template resolution. keywords.each do |type, list| rdoc_trove[type] = list.collect {|keyword| {'name' => keyword} } case type when 'functions': functions = list when 'constants': constants = list when 'events': events = list end end # Pass the templates given on the command line through RDOC and ERB to # generate syntax files at the corresponding spot in the output folder. ARGV.each do |template_path| File.open(template_path) do |template_file| print "reading #{template_path}... " syntax_path = template_path.sub('template/', 'output/') syntax_folder = File.dirname(syntax_path) Dir::mkdir(syntax_folder) unless File::exists? syntax_folder File.open(syntax_path, 'w') do |syntax_file| rdoc_result = '' page = TemplatePage.new(template_file.read) page.write_html_on(rdoc_result, rdoc_trove) syntax_file << ERB.new(rdoc_result, 0, "-").result puts "writing: #{syntax_path}" end end end