uberdoc 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f500f42f8dfb03896ce8d69c911d0a0888dc7515
4
- data.tar.gz: 1c49cf88c27562c693a8b525451f03b2c7003c37
3
+ metadata.gz: a8e2f48319d33e62088a40fb92d43408e77aafe4
4
+ data.tar.gz: edbb98fc2d2e953d0eca33ecf5c644c75949da92
5
5
  SHA512:
6
- metadata.gz: 7697dbedef4d4d292c50ba2dc7c8680de83ca3608d8bf2eb6c68ed20507d9c0bca2dd32636758f48f49a31b7170639c34e6c1be23d4e9c1ef645268f5da735c7
7
- data.tar.gz: b271546ec78b1c9d6d0077f4764f4df04eb5b096468cc8c0e038afe24f3296cc13868f0f02463ed250be22fb198c3e496f0dd96bd06e24a77184af0ef87a8d2d
6
+ metadata.gz: f4e415cd02224b34f67364c75d43f972e71b593143386394c2061c509aab97eee5a3297f745358b17d9458135e4f19d9835f26a1cea6f25fe11cd8a2357d9c10
7
+ data.tar.gz: ccfa99de0981ff73e3f7cd76c2f49b79afe009278ac38ab641d22570820639fd9393c821407a508b022d79e6b65de7a811101d9d0878e4220ec956490a0a1738
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -1,193 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
- require 'open3'
5
- require 'fileutils'
6
- require 'optparse'
7
- require 'optparse/time'
8
- require 'ostruct'
9
- require 'pp'
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
5
 
6
+ require 'uberdoc'
11
7
 
12
- #
13
- # Parses command line options passed in to Uberdoc
14
- #
15
- class UberdocOptions
16
- def self.parse(args)
17
-
18
- options = OpenStruct.new
19
-
20
- options.source_directories = []
21
- options.verbose = false
22
- options.generate = false
23
-
24
- parser = OptionParser.new do |opts|
25
-
26
- opts.banner = "Usage: uberdoc [options]"
27
- opts.separator ""
28
- opts.separator "Available Options:"
29
-
30
- opts.on("-d", "--directory DIRECTORY", "Looks for all UberDocMe files in the specified directory") do |dir|
31
- options.source_directories << dir
32
- end
33
-
34
- opts.on("-v", "--verbose", "Verbosely print all commands and their output") do |verbose|
35
- options.verbose = true
36
- end
37
-
38
- opts.on("-g", "--generate", "Generate the base UberDocMe template file in the current directory") do |gen|
39
- options.generate = true
40
- end
41
-
42
- end # OptionParser
43
-
44
- parser.parse!(args)
45
-
46
- return options
47
-
48
- end # parse
49
-
50
- end # UberdocOptions
51
-
52
- #
53
- # Exectues the given command and optionally dumps the command and its output
54
- #
55
- def execute_command(command, verbose)
56
- stdin, stdout, stderr, wait_thr = Open3.popen3(command)
57
-
58
- res = stdout.read
59
-
60
- if verbose
61
- puts ">>>>>>>>>>>>>>>>>>>>>>>>>"
62
- puts "Command '#{command}'"
63
- puts res
64
- puts "<<<<<<<<<<<<<<<<<<<<<<<<<"
65
- end
66
-
67
- stdin.close
68
- stdout.close
69
- stderr.close
70
-
71
- return res
72
- end
73
-
74
- #
75
- # Returns the absolute path of a template
76
- #
77
- def template_file_path(file)
78
- File.absolute_path("#{File.dirname(File.dirname(__FILE__))}/templates/#{file}")
79
- end
80
-
81
- DOC_PREF_FILE_NAME = "UberDocMe"
82
- DOC_OUTPUT_DIR = "Docs"
83
- DOXYGEN_BIN = "doxygen"
84
- DOXYGEN_REDIRECT_KEY = "OUTPUT_DIRECTORY"
85
- BASE_UBERDOCME = template_file_path("UberDocMe.Base")
86
- BASE_DOXYFILE = template_file_path("Doxyfile.Base")
87
-
88
- #
89
- # Generates Doxyfile variants from the template create the docset or HTML doc
90
- # FIXME: This needs a little DRYing and OOing up
91
- #
92
- def generate_project(docfile, verbose)
93
- project_name = File.basename(File.dirname(docfile))
94
- project_dir = File.dirname(docfile)
95
-
96
- puts "~~~~~~~~~~~~~~~~~~~~~"
97
- puts "Found #{project_name}"
98
-
99
- absolute_out_dir = File.join(File.absolute_path(DOC_OUTPUT_DIR), project_name)
100
- FileUtils.mkdir_p absolute_out_dir
101
-
102
- # Generate the composite Doxyfile
103
-
104
- base_doxyfile = File.open(BASE_DOXYFILE, 'rb') { |file| file.read }
105
- doxyfile_addition = File.open(docfile, 'rb') { |file| file.read }
106
-
107
- composite_doxyfile_contents = base_doxyfile + doxyfile_addition + "\n#{DOXYGEN_REDIRECT_KEY} = #{absolute_out_dir}\n"
108
- composite_doxyfile_path = File.join(absolute_out_dir, "Doxyfile")
109
-
110
- File.open(composite_doxyfile_path, 'w') {|f| f.write(composite_doxyfile_contents) }
111
-
112
- puts "Generating docset for #{project_name}"
113
-
114
- # Change into the directory and invoke doxygen
115
- FileUtils.cd(project_dir) do
116
- execute_command("#{DOXYGEN_BIN} #{composite_doxyfile_path}", verbose)
117
- end
118
-
119
- # Change into the HTML directory and make the docset
120
- html_output_directory = File.join(absolute_out_dir, "html")
121
-
122
- FileUtils.cd(html_output_directory) do
123
- execute_command("make", verbose)
124
- end
125
-
126
- # Find the docset file in the directory and move it one level up
127
- docset_directory = File.join(absolute_out_dir, "docset")
128
-
129
- FileUtils.mkdir_p(docset_directory)
130
-
131
- Dir["#{html_output_directory}/**/*.docset"].each do |docset|
132
- FileUtils.mv(docset, docset_directory)
133
- end
134
-
135
- # Generate the docset again but this time with treeview
136
-
137
- composite_doxyfile_contents += "\nGENERATE_TREEVIEW = YES\n"
138
- File.open(composite_doxyfile_path, 'w') {|f| f.write(composite_doxyfile_contents) }
139
-
140
- puts "Generating HTML Documentation for #{project_name}"
141
-
142
- # Change again into the directory and invoke doxygen
143
- FileUtils.cd(project_dir) do
144
- execute_command("#{DOXYGEN_BIN} #{composite_doxyfile_path}", verbose)
145
- end
146
-
147
- end # generate_project
148
-
149
- #
150
- # Generates documentation for a single directory
151
- #
152
- def generate_documentation(directory, verbose)
153
- puts "Generating Documentation for '#{directory}'"
154
-
155
- FileUtils.rm_rf DOC_OUTPUT_DIR
156
- FileUtils.mkdir_p DOC_OUTPUT_DIR
157
-
158
- Dir["#{directory}/**/#{DOC_PREF_FILE_NAME}"].each do |file|
159
- generate_project(file, verbose)
160
- end
161
- end # generate_documentation
162
-
163
- #
164
- # Generate the base UberDocMe in the current directory
165
- #
166
- def generate_base_manifest(verbose)
167
-
168
- file_path = File.join(Dir.pwd, "UberDocMe")
169
-
170
- if File.exists?(file_path)
171
- abort "There is already an UberDocMe file in this directory"
172
- return
173
- end
174
-
175
- base_uberdocme = File.open(BASE_UBERDOCME, 'rb') { |file| file.read }
176
- File.open(file_path, 'w') {|f| f.write(base_uberdocme) }
177
- end
178
-
179
- options = UberdocOptions.parse(ARGV)
180
-
181
- if options.generate
182
- generate_base_manifest(options.verbose)
183
- end
184
-
185
- options.source_directories.each do |dir|
186
- file = File.absolute_path(dir)
187
-
188
- if File.exists?(file) and File.directory?(file)
189
- generate_documentation(file, options.verbose)
190
- else
191
- abort "#{dir} is not a directory. Skipping..."
192
- end
193
- end
8
+ UberDoc.find_and_perform_tasks(UberDoc::Options::parse(ARGV))
@@ -0,0 +1,4 @@
1
+
2
+ require 'uberdoc/options'
3
+ require 'uberdoc/task'
4
+ require 'uberdoc/utils'
@@ -0,0 +1,55 @@
1
+
2
+ require 'optparse'
3
+ require 'optparse/time'
4
+ require 'ostruct'
5
+
6
+ module UberDoc
7
+
8
+ module Options
9
+
10
+ def self.parse(args)
11
+
12
+ options = OpenStruct.new
13
+
14
+ options.source_directories = []
15
+ options.verbose = false
16
+ options.generate = false
17
+ options.doctor = false
18
+
19
+ parser = OptionParser.new do |opts|
20
+
21
+ opts.banner = "Usage: uberdoc [options]"
22
+ opts.separator ""
23
+ opts.separator "Available Options:"
24
+
25
+ opts.on("-d", "--directory DIRECTORY",
26
+ "Looks for all UberDocMe files in the specified directory") do |dir|
27
+ options.source_directories << dir
28
+ end
29
+
30
+ opts.on("-v", "--verbose",
31
+ "Verbosely print all commands and their output") do |verbose|
32
+ options.verbose = true
33
+ end
34
+
35
+ opts.on("-g", "--generate",
36
+ "Generate the base UberDocMe template file in the current directory") do |gen|
37
+ options.generate = true
38
+ end
39
+
40
+ opts.on("--doctor",
41
+ "Diagnoses the system to find missing dependencies") do |doc|
42
+ options.doctor = true
43
+ end
44
+
45
+ end # OptionParser
46
+
47
+ parser.parse!(args)
48
+
49
+ return options
50
+
51
+ end # parse
52
+
53
+ end # Options
54
+
55
+ end # UberDoc
@@ -0,0 +1,66 @@
1
+
2
+ require 'uberdoc'
3
+
4
+ module UberDoc
5
+
6
+ class Task
7
+
8
+ def initialize(options)
9
+ @options = options
10
+ end
11
+
12
+ #
13
+ # Indicates if this task needs to run based on the options
14
+ #
15
+ def self.should_run?(options)
16
+ true
17
+ end
18
+
19
+ #
20
+ # Performs the task
21
+ #
22
+ def perform
23
+ puts "Subclass Responsibility"
24
+ end # perform
25
+
26
+ def self.known_tasks
27
+ ObjectSpace.each_object(Class).select { |klass| klass < self }
28
+ end
29
+
30
+ end # Task
31
+
32
+ #
33
+ # Returns a list of all known tasks
34
+ #
35
+ def self.find_all_tasks
36
+
37
+
38
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'tasks'))
39
+ Dir["#{File.dirname(__FILE__)}/tasks/**/*_task.rb"].each do |task|
40
+ require task
41
+ end
42
+
43
+ Task.known_tasks
44
+
45
+ end # find_all_tasks
46
+
47
+ #
48
+ # Performs the specified tasks
49
+ #
50
+ def self.perform_tasks(tasks, options)
51
+ tasks.each do |task|
52
+ if task.should_run?(options)
53
+ new_task = task.new(options)
54
+ new_task.perform
55
+ end
56
+ end
57
+ end # perform_tasks
58
+
59
+ #
60
+ # Finds all appropriate tasks and performs them if necessary
61
+ #
62
+ def self.find_and_perform_tasks(options)
63
+ self.perform_tasks(self.find_all_tasks, options)
64
+ end
65
+
66
+ end # UberDoc
@@ -0,0 +1,33 @@
1
+
2
+ require 'uberdoc'
3
+
4
+ module UberDoc
5
+
6
+ class DoctorTask < Task
7
+
8
+ def self.should_run?(options)
9
+ options.doctor
10
+ end
11
+
12
+ def check_doxygen
13
+
14
+ out = UberDoc::Util::execute_command("which doxygen", @options.verbose)
15
+
16
+ if not out.match("doxygen")
17
+ puts "doxygen - Could not find doxygen on your system. Install it using your package manager or from doxygen.org"
18
+ end
19
+ end
20
+
21
+ def perform
22
+
23
+ check_doxygen
24
+
25
+ # Add mode here
26
+
27
+ puts "All checks performed"
28
+
29
+ end # perform
30
+
31
+ end # DoctorTask
32
+
33
+ end # UberDoc
@@ -0,0 +1,98 @@
1
+
2
+ require 'uberdoc'
3
+
4
+ module UberDoc
5
+ class DoxygenTask < Task
6
+
7
+ def self.should_run?(options)
8
+ options.source_directories.count > 0
9
+ end
10
+
11
+ DOC_PREF_FILE_NAME = "UberDocMe"
12
+ DOC_OUTPUT_DIR = "Docs"
13
+ DOXYGEN_BIN = "doxygen"
14
+ DOXYGEN_REDIRECT_KEY = "OUTPUT_DIRECTORY"
15
+ BASE_DOXYFILE = UberDoc::Util::template_file_path("Doxyfile.Base")
16
+
17
+ #
18
+ # Generates Doxyfile variants from the template create the docset or HTML doc
19
+ #
20
+ def generate_project(docfile)
21
+ project_name = File.basename(File.dirname(docfile))
22
+ project_dir = File.dirname(docfile)
23
+
24
+ puts "Found #{project_name}"
25
+
26
+ absolute_out_dir = File.join(File.absolute_path(DOC_OUTPUT_DIR), project_name)
27
+ FileUtils.mkdir_p absolute_out_dir
28
+
29
+ # Generate the composite Doxyfile
30
+
31
+ base_doxyfile = File.open(BASE_DOXYFILE, 'rb') { |file| file.read }
32
+ doxyfile_addition = File.open(docfile, 'rb') { |file| file.read }
33
+
34
+ composite_doxyfile_contents = base_doxyfile + doxyfile_addition + "\n#{DOXYGEN_REDIRECT_KEY} = #{absolute_out_dir}\n"
35
+ composite_doxyfile_path = File.join(absolute_out_dir, "Doxyfile")
36
+
37
+ File.open(composite_doxyfile_path, 'w') {|f| f.write(composite_doxyfile_contents) }
38
+
39
+ puts "Generating docset for #{project_name}"
40
+
41
+ # Change into the directory and invoke doxygen
42
+ FileUtils.cd(project_dir) do
43
+ UberDoc::Util::execute_command("#{DOXYGEN_BIN} #{composite_doxyfile_path}", @options.verbose)
44
+ end
45
+
46
+ # Change into the HTML directory and make the docset
47
+ html_output_directory = File.join(absolute_out_dir, "html")
48
+
49
+ FileUtils.cd(html_output_directory) do
50
+ UberDoc::Util::execute_command("make", @options.verbose)
51
+ end
52
+
53
+ # Find the docset file in the directory and move it one level up
54
+ docset_directory = File.join(absolute_out_dir, "docset")
55
+
56
+ FileUtils.mkdir_p(docset_directory)
57
+
58
+ Dir["#{html_output_directory}/**/*.docset"].each do |docset|
59
+ FileUtils.mv(docset, docset_directory)
60
+ end
61
+
62
+ # Generate the docset again but this time with treeview
63
+
64
+ composite_doxyfile_contents += "\nGENERATE_TREEVIEW = YES\n"
65
+ File.open(composite_doxyfile_path, 'w') {|f| f.write(composite_doxyfile_contents) }
66
+
67
+ puts "Generating HTML Documentation for #{project_name}"
68
+
69
+ # Change again into the directory and invoke doxygen
70
+ FileUtils.cd(project_dir) do
71
+ UberDoc::Util::execute_command("#{DOXYGEN_BIN} #{composite_doxyfile_path}", @options.verbose)
72
+ end
73
+
74
+ end # generate_project
75
+
76
+ #
77
+ # Generates documentation for a single directory
78
+ #
79
+ def generate_documentation(directory)
80
+ puts "Generating Documentation for '#{directory}'"
81
+
82
+ FileUtils.rm_rf DOC_OUTPUT_DIR
83
+ FileUtils.mkdir_p DOC_OUTPUT_DIR
84
+
85
+ Dir["#{directory}/**/#{DOC_PREF_FILE_NAME}"].each do |file|
86
+ generate_project(file)
87
+ end
88
+ end # generate_documentation
89
+
90
+ def perform
91
+ @options.source_directories.each do |dir|
92
+ generate_documentation(dir)
93
+ end
94
+ end
95
+
96
+ end # DoxygenTask
97
+
98
+ end # UberDoc
@@ -0,0 +1,29 @@
1
+
2
+ require 'uberdoc'
3
+
4
+ module UberDoc
5
+ class Generate < Task
6
+
7
+ def self.should_run?(options)
8
+ options.generate
9
+ end # should_run?
10
+
11
+ def perform
12
+
13
+ # Check if there already a doc file in this directory
14
+ file_path = File.join(Dir.pwd, "UberDocMe")
15
+
16
+ if File.exists?(file_path)
17
+ puts "There is already an UberDocMe file in this directory"
18
+ return
19
+ end
20
+
21
+ # Write the template file
22
+ base_uberdocme = File.open(UberDoc::Util::template_file_path('UberDocMe.Base'), 'rb') { |file| file.read }
23
+ File.open(file_path, 'w') {|f| f.write(base_uberdocme) }
24
+
25
+ end # perform
26
+
27
+ end # Generate
28
+
29
+ end # UberDoc
@@ -0,0 +1,35 @@
1
+
2
+ require 'open3'
3
+ require 'fileutils'
4
+ require 'pp'
5
+
6
+ module UberDoc
7
+ module Util
8
+ def self.template_file_path(file)
9
+ File.absolute_path("#{File.dirname(File.dirname(File.dirname(__FILE__)))}/templates/#{file}")
10
+ end
11
+
12
+ #
13
+ # Exectues the given command and optionally dumps the command and its output
14
+ #
15
+ def self.execute_command(command, verbose)
16
+ stdin, stdout, stderr, wait_thr = Open3.popen3(command)
17
+
18
+ res = stdout.read
19
+
20
+ if verbose
21
+ puts ">>>>>>>>>>>>>>>>>>>>>>>>>"
22
+ puts "Command '#{command}'"
23
+ puts res
24
+ puts "<<<<<<<<<<<<<<<<<<<<<<<<<"
25
+ end
26
+
27
+ stdin.close
28
+ stdout.close
29
+ stderr.close
30
+
31
+ return res
32
+ end
33
+ end
34
+
35
+ end
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: uberdoc 0.2.0 ruby lib
5
+ # stub: uberdoc 0.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "uberdoc"
9
- s.version = "0.2.0"
9
+ s.version = "0.3.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Chinmay Garde"]
14
- s.date = "2015-02-17"
14
+ s.date = "2015-02-18"
15
15
  s.description = "UberDoc Documentation Generator"
16
16
  s.email = "chinmay@apportable.com"
17
17
  s.executables = ["uberdoc"]
@@ -29,6 +29,12 @@ Gem::Specification.new do |s|
29
29
  "VERSION",
30
30
  "bin/uberdoc",
31
31
  "lib/uberdoc.rb",
32
+ "lib/uberdoc/options.rb",
33
+ "lib/uberdoc/task.rb",
34
+ "lib/uberdoc/tasks/doctor_task.rb",
35
+ "lib/uberdoc/tasks/doxygen_task.rb",
36
+ "lib/uberdoc/tasks/generate_task.rb",
37
+ "lib/uberdoc/utils.rb",
32
38
  "templates/Doxyfile.Base",
33
39
  "templates/UberDocMe.Base",
34
40
  "test/helper.rb",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uberdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chinmay Garde
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-17 00:00:00.000000000 Z
11
+ date: 2015-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda
@@ -98,6 +98,12 @@ files:
98
98
  - VERSION
99
99
  - bin/uberdoc
100
100
  - lib/uberdoc.rb
101
+ - lib/uberdoc/options.rb
102
+ - lib/uberdoc/task.rb
103
+ - lib/uberdoc/tasks/doctor_task.rb
104
+ - lib/uberdoc/tasks/doxygen_task.rb
105
+ - lib/uberdoc/tasks/generate_task.rb
106
+ - lib/uberdoc/utils.rb
101
107
  - templates/Doxyfile.Base
102
108
  - templates/UberDocMe.Base
103
109
  - test/helper.rb