sdoc_all 0.2.0.11 → 0.2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -32,6 +32,9 @@ time to skip updates (for now ruby and plugins are updated)
32
32
  days, hours, minutes, seconds accepted
33
33
  min_update_interval: 1 hour
34
34
 
35
+ title of resulting page
36
+ title: "full reference"
37
+
35
38
  list of things you want to document
36
39
  carefully watch indent - 4 spaces for options
37
40
  sdoc:
@@ -45,6 +48,11 @@ if you don't want updates use this
45
48
  version: 1.8.6
46
49
  update: false
47
50
 
51
+ also as ruby has no index page, you can create folder with index.html in it (also there can be stylesheets, images or whatever you want but they should be linked relatively; I choose http://www.zenspider.com/Languages/Ruby/QuickRef.html :) ) and put path to it in config like
52
+ - ruby:
53
+ version: 1.8.6
54
+ index: ruby_quick_ref
55
+
48
56
  === rails
49
57
  choose rails version
50
58
  - rails: 2.3.2
data/VERSION.yml CHANGED
@@ -1 +1 @@
1
- [0, 2, 0, 11]
1
+ [0, 2, 1, 0]
data/lib/sdoc_all/ruby.rb CHANGED
@@ -9,6 +9,7 @@ class SdocAll
9
9
  @config = {
10
10
  :update => config.delete(:update) != false,
11
11
  :version => config.delete(:version),
12
+ :index => config.delete(:index),
12
13
  }
13
14
 
14
15
  version = @config[:version]
@@ -17,6 +18,13 @@ class SdocAll
17
18
  end
18
19
  self.class.find_or_download_matching_archive(version)
19
20
 
21
+ if @config[:index]
22
+ index = Pathname(@config[:index])
23
+ unless index.directory? && (index + 'index.html').file?
24
+ raise ConfigError.new("index should be a directory with index.html inside and all related files should be with relative links")
25
+ end
26
+ end
27
+
20
28
  raise_unknown_options_if_not_blank!(config)
21
29
  end
22
30
 
@@ -39,11 +47,13 @@ class SdocAll
39
47
  end
40
48
  self.class.used_sources << path
41
49
 
42
- Base.add_task(
50
+ task_options = {
43
51
  :src_path => path,
44
52
  :doc_path => "ruby-#{version}",
45
53
  :title => "ruby-#{version}"
46
- )
54
+ }
55
+ task_options[:index] = config[:index] if config[:index]
56
+ Base.add_task(task_options)
47
57
  end
48
58
 
49
59
  private
data/lib/sdoc_all/task.rb CHANGED
@@ -2,13 +2,14 @@ require 'digest'
2
2
 
3
3
  class SdocAll
4
4
  class Task
5
- attr_reader :src_path, :doc_path, :paths, :main, :title
5
+ attr_reader :src_path, :doc_path, :paths, :main, :title, :index
6
6
  def initialize(options = {})
7
7
  @src_path = Pathname.new(options[:src_path]).expand_path
8
8
  @doc_path = options[:doc_path]
9
9
  @paths = options[:paths]
10
10
  @main = options[:main]
11
11
  @title = options[:title]
12
+ @index = options[:index]
12
13
  end
13
14
 
14
15
  def run(options = {})
@@ -25,6 +26,14 @@ class SdocAll
25
26
  cmd << '-m' << main if main
26
27
  Base.system(*cmd + paths)
27
28
  end
29
+ if index
30
+ custom_index_dir_name = 'custom_index'
31
+ custom_index_path = Base.docs_path + doc_path + custom_index_dir_name
32
+ Base.remove_if_present(custom_index_path)
33
+ FileUtils.cp_r(index, custom_index_path)
34
+ index_html = Base.docs_path + doc_path + 'index.html'
35
+ index_html.write index_html.read.sub(/(<frame src=")[^"]+(" name="docwin" \/>)/, "\\1#{custom_index_dir_name}/index.html\\2")
36
+ end
28
37
  else
29
38
  Base.system(*cmd + [src_path])
30
39
  end
@@ -38,7 +47,9 @@ class SdocAll
38
47
  end
39
48
 
40
49
  def hash
41
- Digest::SHA1.hexdigest([src_path.to_s, doc_path.to_s, paths, main, title, last_build_time].inspect)
50
+ for_hash = [src_path.to_s, doc_path.to_s, paths, main, title, last_build_time]
51
+ for_hash << index if index
52
+ Digest::SHA1.hexdigest(for_hash.inspect)
42
53
  end
43
54
 
44
55
  def config_hash_path
data/lib/sdoc_all.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
+ require 'pathname'
3
4
  require 'fileutils'
4
5
  require 'find'
5
6
  require 'digest'
@@ -18,6 +19,14 @@ class Array
18
19
  end
19
20
  end
20
21
 
22
+ class Pathname
23
+ def write(s)
24
+ open('w') do |f|
25
+ f.write(s)
26
+ end
27
+ end
28
+ end
29
+
21
30
  class SdocAll
22
31
  module ClassMethods
23
32
  def update?
@@ -25,7 +34,7 @@ class SdocAll
25
34
  end
26
35
 
27
36
  def title
28
- @title
37
+ @title.present? ? @title : 'ruby related reference'
29
38
  end
30
39
 
31
40
  def last_build_sdoc_version_path
@@ -67,7 +76,7 @@ class SdocAll
67
76
  task.run(options)
68
77
  end
69
78
 
70
- hash = Digest::SHA1.hexdigest(tasks.map(&:hash).inspect + title)
79
+ hash = Digest::SHA1.hexdigest(tasks.map(&:hash).inspect + title.to_s)
71
80
  created_hash = config_hash_path.read rescue nil
72
81
 
73
82
  if hash != created_hash
@@ -134,7 +143,7 @@ class SdocAll
134
143
  created = last_build_sdoc_version_path.mtime rescue nil
135
144
  @update = created.nil? || created < min_update_interval.ago
136
145
 
137
- @title = config[:title].present? ? config[:title] : 'ruby related reference'
146
+ @title = config[:title]
138
147
 
139
148
  if config[:sdoc] && config[:sdoc].is_a?(Array) && config[:sdoc].length > 0
140
149
  errors = []
data/sdoc_all.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{sdoc_all}
5
- s.version = "0.2.0.11"
5
+ s.version = "0.2.1.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["toy"]
@@ -33,7 +33,7 @@ describe SdocAll do
33
33
 
34
34
  SdocAll.should_receive(:read_config)
35
35
  SdocAll::Base.should_receive(:tasks).and_return(@tasks)
36
- SdocAll::Base.should_receive(:system).with('sdoc-merge', '-o', Pathname.new('/public'), '-t', 'all', '-n', '<a>,<b>,<c>', '-u', '/docs/a /docs/b /docs/c', 'a', 'b', 'c')
36
+ SdocAll::Base.should_receive(:system).with('sdoc-merge', '-o', Pathname.new('/public'), '-t', 'ruby related reference', '-n', '<a>,<b>,<c>', '-u', 'docs/a docs/b docs/c', 'a', 'b', 'c')
37
37
  SdocAll.run
38
38
  end
39
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdoc_all
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.11
4
+ version: 0.2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - toy