require './docset.rb'
verbose(true)


task :default => :all
#task :all => [:guides, :docset]
#task :all => [:guides] # no docset in the main distribution...
task :all do
end

task :guides do
  Dir.glob('*.txt').each do |src|
    dest = (File.basename(src, '.txt') + '.html')
    if !File.exist?(dest) or File.mtime(src) > File.mtime(dest) or File.mtime(__FILE__) > File.mtime(dest)
      sh "mizuho -a max-width=55em \"#{src}\" -o \"#{dest}\""
    end 
  end
end

DOCSET_PATHS = %w{
  /Library/Developer/Documentation/DocSets/com.apple.adc.documentation.AppleiOS4_3.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference
  /Library/Developer/Documentation/DocSets/com.apple.adc.documentation.AppleiOS4_3.iOSLibrary.docset/Contents/Resources/Documents/documentation/Cocoa/Reference  
}
task :docset do
  if !File.exist?('docset')
    DocsetGenerator.new('docset', DOCSET_PATHS).run
  end
end

task :clean do
  rm_rf 'docset'
  Dir.glob('*.html').each { |x| rm_rf x }
end
