class UberDoc::DoxygenTask

Constants

BASE_DOXYFILE
DOC_OUTPUT_DIR
DOC_PREF_FILE_NAME
DOXYGEN_BIN
DOXYGEN_REDIRECT_KEY

Public Class Methods

should_run?(options) click to toggle source
# File lib/uberdoc/tasks/doxygen_task.rb, line 7
def self.should_run?(options)
    options.source_directories.count > 0
end

Public Instance Methods

generate_documentation(directory) click to toggle source

Generates documentation for a single directory

# File lib/uberdoc/tasks/doxygen_task.rb, line 81
def generate_documentation(directory)
    puts "Generating Documentation for '#{directory}'"

    FileUtils.rm_rf DOC_OUTPUT_DIR
    FileUtils.mkdir_p DOC_OUTPUT_DIR

    Dir["#{directory}/**/#{DOC_PREF_FILE_NAME}"].each do |file|
        generate_project(file)
    end
end
generate_project(docfile) click to toggle source

Generates Doxyfile variants from the template create the docset or HTML doc

# File lib/uberdoc/tasks/doxygen_task.rb, line 20
def generate_project(docfile)
    project_name = File.basename(File.dirname(docfile))
    project_dir = File.dirname(docfile)

    puts "Found #{project_name}"

    absolute_out_dir = File.join(File.absolute_path(DOC_OUTPUT_DIR), project_name)
    FileUtils.mkdir_p absolute_out_dir

    # Generate the composite Doxyfile

    base_doxyfile = File.open(BASE_DOXYFILE, 'rb') { |file| file.read }
    doxyfile_addition = File.open(docfile, 'rb') { |file| file.read }

    composite_doxyfile_contents = base_doxyfile + doxyfile_addition + "\n#{DOXYGEN_REDIRECT_KEY} = #{absolute_out_dir}\n"
    composite_doxyfile_path = File.join(absolute_out_dir, "Doxyfile")

    File.open(composite_doxyfile_path, 'w') {|f| f.write(composite_doxyfile_contents) }

    if @options.docset
        puts "Generating docset for #{project_name}"

        # Change into the directory and invoke doxygen
        FileUtils.cd(project_dir) do
            UberDoc::Util::execute_command("#{DOXYGEN_BIN} #{composite_doxyfile_path}", @options.verbose)
        end

        # Change into the HTML directory and make the docset
        html_output_directory = File.join(absolute_out_dir, "html")

        FileUtils.cd(html_output_directory) do
            UberDoc::Util::execute_command("make", @options.verbose)
        end

        # Find the docset file in the directory and move it one level up
        docset_directory = File.join(absolute_out_dir, "docset") 

        FileUtils.mkdir_p(docset_directory)

        Dir["#{html_output_directory}/**/*.docset"].each do |docset|
            FileUtils.mv(docset, docset_directory)
        end
    end

    # Generate the docset again but this time with treeview

    composite_doxyfile_contents += "\nGENERATE_TREEVIEW = YES\n"
    File.open(composite_doxyfile_path, 'w') {|f| f.write(composite_doxyfile_contents) }

    puts "Generating HTML Documentation for #{project_name}"

    # Change again into the directory and invoke doxygen
    FileUtils.cd(project_dir) do
        UberDoc::Util::execute_command("#{DOXYGEN_BIN} #{composite_doxyfile_path}", @options.verbose)
    end

end
perform() click to toggle source
# File lib/uberdoc/tasks/doxygen_task.rb, line 92
def perform
    @options.source_directories.each do |dir|
        generate_documentation(dir)
    end
end