docster 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README +0 -0
- data/Rakefile +2 -0
- data/bin/docster +3 -0
- data/docster.gemspec +25 -0
- data/lib/docster.rb +1 -0
- data/lib/docster/cli.rb +18 -0
- data/lib/docster/doc_generator.rb +116 -0
- data/lib/docster/version.rb +3 -0
- metadata +96 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
data/bin/docster
ADDED
data/docster.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "docster/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "docster"
|
7
|
+
s.version = Docster::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Jim Ryan", "Chris Gunther"]
|
10
|
+
s.email = ["info@room118solutions.com"]
|
11
|
+
s.homepage = "http://github.com/room118solutions/docster"
|
12
|
+
s.summary = %q{Generates searchable documentation for your ruby project}
|
13
|
+
s.description = s.summary
|
14
|
+
|
15
|
+
s.rubyforge_project = "docster"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency "sdoc"
|
23
|
+
s.add_dependency "thor"
|
24
|
+
s.add_development_dependency "rake"
|
25
|
+
end
|
data/lib/docster.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
module Docster; end
|
data/lib/docster/cli.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'bundler'
|
3
|
+
require 'docster/doc_generator'
|
4
|
+
|
5
|
+
module Docster
|
6
|
+
class CLI < Thor
|
7
|
+
|
8
|
+
desc 'generate', "Generate merged sdoc documentation for all :default and :development gems in this project"
|
9
|
+
method_option :groups, :default => ['default', 'development'], :type => :array, :aliases => '-g'
|
10
|
+
method_option :name, :default => Bundler.default_gemfile.dirname.split.last.to_s, :type => :string, :aliases => '-n'
|
11
|
+
method_option :ruby_version, :default => "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}", :type => :string, :aliases => '-r', :desc => 'Ruby version to include (defaults to this Ruby)', :banner => '(VERSION)-p(PATCHLEVEL)'
|
12
|
+
method_option :without_ruby, :default => false, :type => :boolean, :desc => 'Generate documentation without Ruby docs'
|
13
|
+
def generate
|
14
|
+
DocGenerator.generate! options.name, options.groups, (options.without_ruby ? nil : options.ruby_version)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
|
3
|
+
module Docster
|
4
|
+
class RubyNotFound < StandardError; end
|
5
|
+
|
6
|
+
class DocGenerator
|
7
|
+
def self.generate!(project_name, groups, ruby_version)
|
8
|
+
begin
|
9
|
+
@@groups = groups
|
10
|
+
|
11
|
+
create_docs_directory! unless Dir.exists?(docs_dir)
|
12
|
+
create_projects_directory! unless Dir.exists?(projects_path)
|
13
|
+
|
14
|
+
changes = false
|
15
|
+
gems.each do |name, info|
|
16
|
+
unless Dir.exists?(doc_path_for name, info[:version])
|
17
|
+
generate_sdoc_for :type => :gem, :name => name, :version => info[:version], :path => info[:path]
|
18
|
+
changes = true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
unless ruby_version.nil? || Dir.exists?(doc_path_for 'ruby', ruby_version)
|
23
|
+
generate_sdoc_for :name => 'ruby', :version => ruby_version, :path => download_ruby(ruby_version)
|
24
|
+
changes = true
|
25
|
+
end
|
26
|
+
|
27
|
+
if changes || !File.exists?(File.join(project_path_for(project_name), 'index.html'))
|
28
|
+
FileUtils.rm_rf project_path_for project_name
|
29
|
+
sdoc_merge project_name, ruby_version
|
30
|
+
end
|
31
|
+
|
32
|
+
`open #{File.join project_path_for(project_name), 'index.html'}`
|
33
|
+
ensure
|
34
|
+
cleanup!
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def self.sdoc_merge(project_name, ruby_version)
|
40
|
+
names = ruby_version ? [gem_names, 'ruby'].join(',') : gem_names
|
41
|
+
paths = ruby_version ? doc_paths << %Q( "#{doc_path_for 'ruby', ruby_version}") : doc_paths
|
42
|
+
`sdoc-merge --title "#{project_name}" --op "#{project_path_for project_name}" --names "#{names}" #{paths}`
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.generate_sdoc_for(options = {})
|
46
|
+
`sdoc -o "#{doc_path_for options[:name], options[:version]}" "#{options[:path]}"`
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.gems
|
50
|
+
return @@gems if defined?(@@gems)
|
51
|
+
|
52
|
+
gem_paths = {}
|
53
|
+
Bundler.definition.specs_for(@@groups.map(&:to_sym)).each do |gem|
|
54
|
+
gem_paths[gem.name] = { :path => gem.full_gem_path, :version => gem.version.to_s }
|
55
|
+
end
|
56
|
+
@@gems = gem_paths
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.gem_names
|
60
|
+
gems.keys.join(',')
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.doc_paths
|
64
|
+
'"' << gems.map{ |name, info| "#{doc_path_for name, info[:version]}" }.join('" "') << '"'
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.user_docster_path
|
68
|
+
return @@user_docster_path if defined?(@@user_docster_path)
|
69
|
+
|
70
|
+
@@user_docster_path = File.join(Etc.getpwuid.dir, '.docster')
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.doc_path_for(name, version)
|
74
|
+
File.join user_docster_path, 'docs', name, version
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.create_docs_directory!
|
78
|
+
FileUtils.mkdir_p docs_dir
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.create_projects_directory!
|
82
|
+
FileUtils.mkdir_p projects_path
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.docs_dir
|
86
|
+
File.join(user_docster_path, 'docs')
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.tmp_path
|
90
|
+
path = File.join(user_docster_path, 'tmp')
|
91
|
+
FileUtils.mkdir_p path
|
92
|
+
path
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.cleanup!
|
96
|
+
FileUtils.rm_rf tmp_path
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.projects_path
|
100
|
+
File.join user_docster_path, 'projects'
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.project_path_for(project_name)
|
104
|
+
File.join projects_path, project_name
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.download_ruby(version)
|
108
|
+
ruby_archive = "ruby-#{version}.tar.bz2"
|
109
|
+
archive_path = File.join tmp_path, ruby_archive
|
110
|
+
`wget http://ftp.ruby-lang.org/pub/ruby/#{version.split('.')[0..1].join('.')}/#{ruby_archive} -O "#{archive_path}"`
|
111
|
+
raise RubyNotFound unless File.size?(archive_path)
|
112
|
+
`tar -xf "#{archive_path}" -C "#{tmp_path}"`
|
113
|
+
File.join tmp_path, "ruby-#{version}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: docster
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jim Ryan
|
9
|
+
- Chris Gunther
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2011-12-28 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: sdoc
|
17
|
+
requirement: &2164266320 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2164266320
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: thor
|
28
|
+
requirement: &2164265900 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *2164265900
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rake
|
39
|
+
requirement: &2164265400 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *2164265400
|
48
|
+
description: Generates searchable documentation for your ruby project
|
49
|
+
email:
|
50
|
+
- info@room118solutions.com
|
51
|
+
executables:
|
52
|
+
- docster
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- Gemfile
|
58
|
+
- README
|
59
|
+
- Rakefile
|
60
|
+
- bin/docster
|
61
|
+
- docster.gemspec
|
62
|
+
- lib/docster.rb
|
63
|
+
- lib/docster/cli.rb
|
64
|
+
- lib/docster/doc_generator.rb
|
65
|
+
- lib/docster/version.rb
|
66
|
+
homepage: http://github.com/room118solutions/docster
|
67
|
+
licenses: []
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
hash: 3265255303828275375
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
hash: 3265255303828275375
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project: docster
|
92
|
+
rubygems_version: 1.8.6
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: Generates searchable documentation for your ruby project
|
96
|
+
test_files: []
|