jsdoc-toolkit 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/jsdoc-toolkit.gemspec +3 -2
- data/lib/jsdoc-toolkit/doc_task.rb +3 -5
- data/lib/jsdoc-toolkit/generator.rb +9 -11
- data/test/doc_task_test.rb +5 -2
- data/test/generator_test.rb +11 -12
- data/test/other_input/qhat.js +0 -0
- data/test/test_helper.rb +1 -5
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/jsdoc-toolkit.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jsdoc-toolkit}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ggironda"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-11}
|
13
13
|
s.description = %q{RubyGem packaged version of jsdoc-toolkit with extra rake tasks for automating doc generation}
|
14
14
|
s.email = %q{gabriel.gironda@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -139,6 +139,7 @@ Gem::Specification.new do |s|
|
|
139
139
|
"test/generator_test.rb",
|
140
140
|
"test/input/bar/foo.js",
|
141
141
|
"test/input/test.js",
|
142
|
+
"test/other_input/qhat.js",
|
142
143
|
"test/test_helper.rb"
|
143
144
|
]
|
144
145
|
s.homepage = %q{http://github.com/gabrielg/jsdoc-toolkit}
|
@@ -5,8 +5,10 @@ require 'pathname'
|
|
5
5
|
|
6
6
|
module JsDocToolkit
|
7
7
|
class DocTask
|
8
|
+
attr_reader :jsdoc_files
|
8
9
|
|
9
10
|
def initialize(task_name)
|
11
|
+
@jsdoc_files = []
|
10
12
|
yield(self)
|
11
13
|
task(task_name) { build }
|
12
14
|
end
|
@@ -14,16 +16,12 @@ module JsDocToolkit
|
|
14
16
|
def jsdoc_dir=(path)
|
15
17
|
@jsdoc_dir = Pathname(path)
|
16
18
|
end
|
17
|
-
|
18
|
-
def jsdoc_files=(path)
|
19
|
-
@jsdoc_files = Pathname(path)
|
20
|
-
end
|
21
19
|
|
22
20
|
private
|
23
21
|
|
24
22
|
def build
|
25
23
|
generator = JsDocToolkit::Generator.new
|
26
|
-
generator.build(:
|
24
|
+
generator.build(:src_files => @jsdoc_files, :doc_dir => @jsdoc_dir.to_s)
|
27
25
|
end
|
28
26
|
|
29
27
|
end # DocTask
|
@@ -7,24 +7,22 @@ module JsDocToolkit
|
|
7
7
|
:verbose => "-v", :unique => "-u"}
|
8
8
|
|
9
9
|
def build(options)
|
10
|
+
src_files, doc_dir = Array(options[:src_files]), Pathname(options[:doc_dir].to_s)
|
10
11
|
raise RuntimeError, "java was not found in your PATH." if `which java 2>/dev/null`.strip.empty?
|
11
|
-
raise ArgumentError, ":
|
12
|
-
raise ArgumentError, ":doc_dir was not specified" unless options[:doc_dir]
|
13
|
-
|
14
|
-
|
15
|
-
raise ArgumentError, ":src_dir does not exist" unless src_dir.exist?
|
16
|
-
raise ArgumentError, ":doc_dir does not exist" unless doc_dir.exist?
|
17
|
-
run_jsdoc(src_dir, doc_dir)
|
12
|
+
raise ArgumentError, ":src_files was not specified or was empty" if src_files.empty?
|
13
|
+
raise ArgumentError, ":doc_dir was not specified or does not exist" unless options[:doc_dir] && doc_dir.exist?
|
14
|
+
|
15
|
+
run_jsdoc(src_files, doc_dir)
|
18
16
|
end
|
19
17
|
|
20
18
|
private
|
21
19
|
|
22
|
-
def run_jsdoc(
|
23
|
-
system("java", "-jar", JsDocJarPath, JsDocJsPath, %Q[-d=#{doc_dir.expand_path}], *merge_defaults_with_src(
|
20
|
+
def run_jsdoc(src_files, doc_dir)
|
21
|
+
system("java", "-jar", JsDocJarPath, JsDocJsPath, %Q[-d=#{doc_dir.expand_path}], *merge_defaults_with_src(src_files))
|
24
22
|
end
|
25
23
|
|
26
|
-
def merge_defaults_with_src(
|
27
|
-
DefaultOptions.values +
|
24
|
+
def merge_defaults_with_src(src_files)
|
25
|
+
DefaultOptions.values + src_files
|
28
26
|
end
|
29
27
|
|
30
28
|
end # Generator
|
data/test/doc_task_test.rb
CHANGED
@@ -5,7 +5,7 @@ context "a JsDocToolkit::DocTask" do
|
|
5
5
|
setup do
|
6
6
|
JsDocToolkit::DocTask.new("testing:doc_task") do |doc|
|
7
7
|
doc.jsdoc_dir = 'output'
|
8
|
-
doc.jsdoc_files
|
8
|
+
doc.jsdoc_files << 'input'
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -14,10 +14,13 @@ context "a JsDocToolkit::DocTask" do
|
|
14
14
|
end.equals("testing:doc_task")
|
15
15
|
|
16
16
|
should "generate the docs when invoked" do
|
17
|
-
|
17
|
+
cur_dir = Dir.pwd
|
18
|
+
Dir.chdir(Pathname(__FILE__).parent)
|
19
|
+
output_dir = Pathname("output").expand_path
|
18
20
|
output_dir.rmtree if output_dir.exist?
|
19
21
|
output_dir.mkdir
|
20
22
|
Rake::Task["testing:doc_task"].invoke
|
23
|
+
Dir.chdir(cur_dir)
|
21
24
|
output_dir.entries.size > 2
|
22
25
|
end
|
23
26
|
|
data/test/generator_test.rb
CHANGED
@@ -6,11 +6,14 @@ context "a JsDocToolkit::Generator" do
|
|
6
6
|
context "with valid arguments and generating docs" do
|
7
7
|
|
8
8
|
setup do
|
9
|
-
|
9
|
+
cur_dir = Dir.pwd
|
10
|
+
Dir.chdir(Pathname(__FILE__).parent)
|
11
|
+
output_dir = Pathname("output").expand_path
|
10
12
|
output_dir.rmtree if output_dir.exist?
|
11
13
|
output_dir.mkdir
|
12
14
|
generator = JsDocToolkit::Generator.new
|
13
|
-
generator.build(:
|
15
|
+
generator.build(:src_files => [Pathname(__FILE__).parent + "input", Pathname(__FILE__).parent + "other_input"], :doc_dir => output_dir)
|
16
|
+
Dir.chdir(cur_dir)
|
14
17
|
output_dir
|
15
18
|
end
|
16
19
|
|
@@ -29,26 +32,22 @@ context "a JsDocToolkit::Generator" do
|
|
29
32
|
begin
|
30
33
|
original_path = ENV['PATH']
|
31
34
|
ENV['PATH'] = ""
|
32
|
-
topic.build(:
|
35
|
+
topic.build(:src_files => Pathname("input"), :doc_dir => Pathname("output"))
|
33
36
|
ensure
|
34
37
|
ENV['PATH'] = original_path
|
35
38
|
end
|
36
39
|
end.raises(RuntimeError, /java was not found/)
|
37
40
|
|
38
|
-
should "fail if src dir does not exist" do
|
39
|
-
topic.build(:src_dir => Pathname("bzzzzzzzzzzzt"), :doc_dir => Pathname("output"))
|
40
|
-
end.raises(ArgumentError, /src_dir does not exist/)
|
41
|
-
|
42
41
|
should "fail if doc dir does not exist" do
|
43
|
-
topic.build(:
|
44
|
-
end.raises(ArgumentError, /doc_dir does not exist/)
|
42
|
+
topic.build(:src_files => Pathname(__FILE__).parent + "input", :doc_dir => Pathname("bzzzzzzzt"))
|
43
|
+
end.raises(ArgumentError, /doc_dir was not specified or does not exist/)
|
45
44
|
|
46
|
-
should "fail if src
|
45
|
+
should "fail if src files is not specified" do
|
47
46
|
topic.build(:doc_dir => Pathname("output"))
|
48
|
-
end.raises(ArgumentError, /
|
47
|
+
end.raises(ArgumentError, /src_files was not specified/)
|
49
48
|
|
50
49
|
should "fail if doc dir is not specified" do
|
51
|
-
topic.build(:
|
50
|
+
topic.build(:src_files => Pathname("input"))
|
52
51
|
end.raises(ArgumentError, /doc_dir was not specified/)
|
53
52
|
|
54
53
|
end # with various modes of build failure
|
File without changes
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsdoc-toolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ggironda
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-11 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- test/generator_test.rb
|
155
155
|
- test/input/bar/foo.js
|
156
156
|
- test/input/test.js
|
157
|
+
- test/other_input/qhat.js
|
157
158
|
- test/test_helper.rb
|
158
159
|
has_rdoc: true
|
159
160
|
homepage: http://github.com/gabrielg/jsdoc-toolkit
|