jsdoc-toolkit 0.1.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/.document +5 -0
- data/.gitignore +6 -0
- data/.gitmodules +3 -0
- data/LICENSE +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/jsdoc-toolkit.gemspec +60 -0
- data/lib/jsdoc-toolkit/doc_task.rb +30 -0
- data/lib/jsdoc-toolkit/generator.rb +30 -0
- data/lib/jsdoc-toolkit.rb +7 -0
- data/test/doc_task_test.rb +24 -0
- data/test/generator_test.rb +57 -0
- data/test/input/bar/foo.js +8 -0
- data/test/input/test.js +8 -0
- data/test/test_helper.rb +12 -0
- metadata +82 -0
data/.document
ADDED
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 ggironda
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= jsdoc-toolkit
|
2
|
+
|
3
|
+
Hi. I take no credit for this other than packaging it up as a RubyGem and adding some handy Rake tasks.
|
4
|
+
The JsDoc Toolkit homepage is here: http://code.google.com/p/jsdoc-toolkit/
|
5
|
+
|
6
|
+
== Note on Patches/Pull Requests
|
7
|
+
|
8
|
+
* Fork the project.
|
9
|
+
* Make your feature addition or bug fix.
|
10
|
+
* Add tests for it. This is important so I don't break it in a
|
11
|
+
future version unintentionally.
|
12
|
+
* Commit, do not mess with rakefile, version, or history.
|
13
|
+
(if you want to have your own version, that is fine but
|
14
|
+
bump version in a commit by itself I can ignore when I pull)
|
15
|
+
* Send me a pull request. Bonus points for topic branches.
|
16
|
+
|
17
|
+
== Copyright
|
18
|
+
|
19
|
+
Copyright (c) 2009 ggironda. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "jsdoc-toolkit"
|
8
|
+
gem.summary = %Q{RubyGem packaged version of jsdoc-toolkit with extra rake tasks for automating doc generation}
|
9
|
+
gem.description = %Q{RubyGem packaged version of jsdoc-toolkit with extra rake tasks for automating doc generation}
|
10
|
+
gem.email = "gabriel.gironda@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/gabrielg/jsdoc-toolkit"
|
12
|
+
gem.authors = ["ggironda"]
|
13
|
+
gem.add_development_dependency "riot"
|
14
|
+
end
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'rake/testtask'
|
21
|
+
Rake::TestTask.new(:test) do |test|
|
22
|
+
test.libs << 'lib' << 'test'
|
23
|
+
test.pattern = 'test/**/*_test.rb'
|
24
|
+
test.verbose = true
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'rcov/rcovtask'
|
29
|
+
Rcov::RcovTask.new do |test|
|
30
|
+
test.libs << 'test'
|
31
|
+
test.pattern = 'test/**/*_test.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
rescue LoadError
|
35
|
+
task :rcov do
|
36
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
task :test => :check_dependencies
|
41
|
+
|
42
|
+
task :default => :test
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
if File.exist?('VERSION')
|
47
|
+
version = File.read('VERSION')
|
48
|
+
else
|
49
|
+
version = ""
|
50
|
+
end
|
51
|
+
|
52
|
+
rdoc.rdoc_dir = 'rdoc'
|
53
|
+
rdoc.title = "jsdoc-toolkit #{version}"
|
54
|
+
rdoc.rdoc_files.include('README*')
|
55
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
56
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{jsdoc-toolkit}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["ggironda"]
|
12
|
+
s.date = %q{2009-10-06}
|
13
|
+
s.description = %q{RubyGem packaged version of jsdoc-toolkit with extra rake tasks for automating doc generation}
|
14
|
+
s.email = %q{gabriel.gironda@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
".gitmodules",
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"jsdoc-toolkit.gemspec",
|
28
|
+
"lib/jsdoc-toolkit.rb",
|
29
|
+
"lib/jsdoc-toolkit/doc_task.rb",
|
30
|
+
"lib/jsdoc-toolkit/generator.rb",
|
31
|
+
"test/doc_task_test.rb",
|
32
|
+
"test/generator_test.rb",
|
33
|
+
"test/input/bar/foo.js",
|
34
|
+
"test/input/test.js",
|
35
|
+
"test/test_helper.rb"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/gabrielg/jsdoc-toolkit}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.5}
|
41
|
+
s.summary = %q{RubyGem packaged version of jsdoc-toolkit with extra rake tasks for automating doc generation}
|
42
|
+
s.test_files = [
|
43
|
+
"test/doc_task_test.rb",
|
44
|
+
"test/generator_test.rb",
|
45
|
+
"test/test_helper.rb"
|
46
|
+
]
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_development_dependency(%q<riot>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<riot>, [">= 0"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<riot>, [">= 0"])
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'jsdoc-toolkit'
|
3
|
+
require 'jsdoc-toolkit/generator'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
module JsDocToolkit
|
7
|
+
class DocTask
|
8
|
+
|
9
|
+
def initialize(task_name)
|
10
|
+
yield(self)
|
11
|
+
task(task_name) { build }
|
12
|
+
end
|
13
|
+
|
14
|
+
def jsdoc_dir=(path)
|
15
|
+
@jsdoc_dir = Pathname(caller.first.sub(/:\d+$/, "")).expand_path.parent + path
|
16
|
+
end
|
17
|
+
|
18
|
+
def jsdoc_files=(path)
|
19
|
+
@jsdoc_files = Pathname(caller.first.sub(/:\d+$/, "")).expand_path.parent + path
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def build
|
25
|
+
generator = JsDocToolkit::Generator.new
|
26
|
+
generator.build(:src_dir => @jsdoc_files.expand_path.to_s, :doc_dir => @jsdoc_dir.expand_path.to_s)
|
27
|
+
end
|
28
|
+
|
29
|
+
end # DocTask
|
30
|
+
end # JsDocToolkit
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'jsdoc-toolkit'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module JsDocToolkit
|
5
|
+
class Generator
|
6
|
+
DefaultOptions = {:recurse => "-r", :all => "-a", :template => %Q[-t=#{JsDocTemplatePath + "jsdoc"}]}
|
7
|
+
|
8
|
+
def build(options)
|
9
|
+
raise RuntimeError, "java was not found in your PATH." if `which java 2>/dev/null`.strip.empty?
|
10
|
+
raise ArgumentError, ":src_dir was not specified" unless options[:src_dir]
|
11
|
+
raise ArgumentError, ":doc_dir was not specified" unless options[:doc_dir]
|
12
|
+
|
13
|
+
src_dir, doc_dir = Pathname(options[:src_dir]), Pathname(options[:doc_dir])
|
14
|
+
raise ArgumentError, ":src_dir does not exist" unless src_dir.exist?
|
15
|
+
raise ArgumentError, ":doc_dir does not exist" unless doc_dir.exist?
|
16
|
+
run_jsdoc(src_dir, doc_dir)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def run_jsdoc(src_dir, doc_dir)
|
22
|
+
system("java", "-jar", JsDocJarPath, JsDocJsPath, %Q[-d=#{doc_dir.expand_path}], *merge_defaults_with_src(src_dir))
|
23
|
+
end
|
24
|
+
|
25
|
+
def merge_defaults_with_src(src_dir)
|
26
|
+
DefaultOptions.values + [src_dir.expand_path.to_s]
|
27
|
+
end
|
28
|
+
|
29
|
+
end # Generator
|
30
|
+
end # JsDocToolkit
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'jsdoc-toolkit/doc_task'
|
3
|
+
|
4
|
+
context "a JsDocToolkit::DocTask" do
|
5
|
+
setup do
|
6
|
+
JsDocToolkit::DocTask.new("testing:doc_task") do |doc|
|
7
|
+
doc.jsdoc_dir = 'output'
|
8
|
+
doc.jsdoc_files = 'input'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
should "add a rake task to the task list with the given name" do
|
13
|
+
Rake::Task["testing:doc_task"].name
|
14
|
+
end.equals("testing:doc_task")
|
15
|
+
|
16
|
+
should "generate the docs when invoked" do
|
17
|
+
output_dir = Pathname(__FILE__).parent + "output"
|
18
|
+
output_dir.rmtree if output_dir.exist?
|
19
|
+
output_dir.mkdir
|
20
|
+
Rake::Task["testing:doc_task"].invoke
|
21
|
+
output_dir.entries.size > 2
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'jsdoc-toolkit/generator'
|
3
|
+
|
4
|
+
context "a JsDocToolkit::Generator" do
|
5
|
+
|
6
|
+
context "with valid arguments and generating docs" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
output_dir = Pathname(__FILE__).parent + "output"
|
10
|
+
output_dir.rmtree if output_dir.exist?
|
11
|
+
output_dir.mkdir
|
12
|
+
generator = JsDocToolkit::Generator.new
|
13
|
+
generator.build(:src_dir => Pathname(__FILE__).parent + "input", :doc_dir => output_dir)
|
14
|
+
output_dir
|
15
|
+
end
|
16
|
+
|
17
|
+
should "have created files in the output dir" do
|
18
|
+
topic.entries.size > 2
|
19
|
+
end
|
20
|
+
|
21
|
+
end # with valid arguments and generating docs
|
22
|
+
|
23
|
+
context "with various modes of build failure" do
|
24
|
+
setup do
|
25
|
+
generator = JsDocToolkit::Generator.new
|
26
|
+
end
|
27
|
+
|
28
|
+
should "fail without java in ENV['PATH']" do
|
29
|
+
begin
|
30
|
+
original_path = ENV['PATH']
|
31
|
+
ENV['PATH'] = ""
|
32
|
+
topic.build(:src_dir => Pathname("input"), :doc_dir => Pathname("output"))
|
33
|
+
ensure
|
34
|
+
ENV['PATH'] = original_path
|
35
|
+
end
|
36
|
+
end.raises(RuntimeError, /java was not found/)
|
37
|
+
|
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
|
+
should "fail if doc dir does not exist" do
|
43
|
+
topic.build(:src_dir => Pathname(__FILE__).parent + "input", :doc_dir => Pathname("bzzzzzzzt"))
|
44
|
+
end.raises(ArgumentError, /doc_dir does not exist/)
|
45
|
+
|
46
|
+
should "fail if src dir is not specified" do
|
47
|
+
topic.build(:doc_dir => Pathname("output"))
|
48
|
+
end.raises(ArgumentError, /src_dir was not specified/)
|
49
|
+
|
50
|
+
should "fail if doc dir is not specified" do
|
51
|
+
topic.build(:src_dir => Pathname("input"))
|
52
|
+
end.raises(ArgumentError, /doc_dir was not specified/)
|
53
|
+
|
54
|
+
end # with various modes of build failure
|
55
|
+
|
56
|
+
end
|
57
|
+
|
data/test/input/test.js
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'riot'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
|
+
require 'jsdoc-toolkit'
|
9
|
+
|
10
|
+
at_exit do
|
11
|
+
Riot.report
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jsdoc-toolkit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ggironda
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-06 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: riot
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: RubyGem packaged version of jsdoc-toolkit with extra rake tasks for automating doc generation
|
26
|
+
email: gabriel.gironda@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
37
|
+
- .gitmodules
|
38
|
+
- LICENSE
|
39
|
+
- README.rdoc
|
40
|
+
- Rakefile
|
41
|
+
- VERSION
|
42
|
+
- jsdoc-toolkit.gemspec
|
43
|
+
- lib/jsdoc-toolkit.rb
|
44
|
+
- lib/jsdoc-toolkit/doc_task.rb
|
45
|
+
- lib/jsdoc-toolkit/generator.rb
|
46
|
+
- test/doc_task_test.rb
|
47
|
+
- test/generator_test.rb
|
48
|
+
- test/input/bar/foo.js
|
49
|
+
- test/input/test.js
|
50
|
+
- test/test_helper.rb
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: http://github.com/gabrielg/jsdoc-toolkit
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options:
|
57
|
+
- --charset=UTF-8
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.3.5
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: RubyGem packaged version of jsdoc-toolkit with extra rake tasks for automating doc generation
|
79
|
+
test_files:
|
80
|
+
- test/doc_task_test.rb
|
81
|
+
- test/generator_test.rb
|
82
|
+
- test/test_helper.rb
|