Top Level Namespace

Defined Under Namespace

Classes: UberdocOptions

Constant Summary collapse

DOC_PREF_FILE_NAME =
"UberDocMe"
DOC_OUTPUT_DIR =
"Docs"
DOXYGEN_BIN =
"doxygen"
DOXYGEN_REDIRECT_KEY =
"OUTPUT_DIRECTORY"
BASE_UBERDOCME =
template_file_path("UberDocMe.Base")
BASE_DOXYFILE =
template_file_path("Doxyfile.Base")

Instance Method Summary collapse

Instance Method Details

#execute_command(command, verbose) ⇒ Object

Exectues the given command and optionally dumps the command and its output



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'bin/uberdoc', line 55

def execute_command(command, verbose)
    stdin, stdout, stderr, wait_thr = Open3.popen3(command)

    res = stdout.read

    if verbose
        puts ">>>>>>>>>>>>>>>>>>>>>>>>>"
        puts "Command '#{command}'"
        puts res
        puts "<<<<<<<<<<<<<<<<<<<<<<<<<"
    end
    
    stdin.close
    stdout.close
    stderr.close

    return res
end

#generate_base_manifest(verbose) ⇒ Object

Generate the base UberDocMe in the current directory



166
167
168
169
170
171
172
173
174
175
176
177
# File 'bin/uberdoc', line 166

def generate_base_manifest(verbose)

    file_path = File.join(Dir.pwd, "UberDocMe")

    if File.exists?(file_path)
        abort "There is already an UberDocMe file in this directory"
        return
    end

    base_uberdocme = File.open(BASE_UBERDOCME, 'rb') { |file| file.read }
    File.open(file_path, 'w') {|f| f.write(base_uberdocme) }
end

#generate_documentation(directory, verbose) ⇒ Object

Generates documentation for a single directory



152
153
154
155
156
157
158
159
160
161
# File 'bin/uberdoc', line 152

def generate_documentation(directory, verbose)
    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, verbose)
    end
end

#generate_project(docfile, verbose) ⇒ Object

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

FIXME: This needs a little DRYing and OOing up


92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'bin/uberdoc', line 92

def generate_project(docfile, verbose)
    project_name = File.basename(File.dirname(docfile))
    project_dir = File.dirname(docfile)

    puts "~~~~~~~~~~~~~~~~~~~~~"
    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) }

    puts "Generating docset for #{project_name}"

    # Change into the directory and invoke doxygen
    FileUtils.cd(project_dir) do
        execute_command("#{DOXYGEN_BIN} #{composite_doxyfile_path}", 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
        execute_command("make", 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

    # 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
        execute_command("#{DOXYGEN_BIN} #{composite_doxyfile_path}", verbose)
    end

end

#template_file_path(file) ⇒ Object

Returns the absolute path of a template



77
78
79
# File 'bin/uberdoc', line 77

def template_file_path(file)
    File.absolute_path("#{File.dirname(File.dirname(__FILE__))}/templates/#{file}") 
end