require "fileutils"


namespace :doc do

  desc "Generate HTML, LaTeX and man(3) documentation from codebase."
  task :doxygen => "doc:doxygen:generate"

  desc "Delete all generated documentation"
  task :clean => %w[doc:doxygen:clean]

  # TODO: rename task to :vm and make it a dependency for doc:build.
  namespace :doxygen do

    directory "doc/generated/vm"

      desc "Generate HTML, LaTeX and man(3) documentation from codebase."
      task :generate => %w[doc/generated/vm resources/doxygen.conf] do
        sh "doxygen resources/doxygen.conf"
      end

      desc "Delete all documentation generated by Doxygen"
      task :clean do
        if File.directory? "doc/generated/vm"
          FileUtils.rm_r "doc/generated/vm", :secure => true, :verbose => $verbose
        end
      end

  end

end
