sdoc 0.3.9 → 0.3.10
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/bin/sdoc-merge +0 -1
- data/lib/rdoc/generator/template/merge/index.rhtml +1 -1
- data/lib/rdoc/generator/template/rails/index.rhtml +1 -1
- data/lib/rdoc/generator/template/rails/resources/css/panel.css +1 -0
- data/lib/rdoc/generator/template/sdoc/index.rhtml +1 -1
- data/lib/rdoc/generator/template/sdoc/resources/css/panel.css +1 -0
- data/lib/sdoc/merge.rb +39 -40
- data/sdoc.gemspec +1 -1
- metadata +3 -3
data/bin/sdoc-merge
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
<title><%= @title %></title>
|
9
9
|
</head>
|
10
|
-
<frameset cols="300,*" frameborder="1" border="1" bordercolor="#
|
10
|
+
<frameset cols="300,*" frameborder="1" border="1" bordercolor="#999999" framespacing="1">
|
11
11
|
<frame src="panel/index.html" title="Search" name="panel" />
|
12
12
|
<frame src="<%= index_path %>" name="docwin" />
|
13
13
|
</frameset>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<meta http-equiv="Content-Type" content="text/html; charset=<%= @options.charset %>" />
|
7
7
|
<title><%= @options.title %></title>
|
8
8
|
</head>
|
9
|
-
<frameset cols="300,*" frameborder="1" border="1" bordercolor="#
|
9
|
+
<frameset cols="300,*" frameborder="1" border="1" bordercolor="#999999" framespacing="1">
|
10
10
|
<frame src="panel/index.html" title="Search" name="panel" />
|
11
11
|
<frame src="<%= index_path %>" name="docwin" />
|
12
12
|
</frameset>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<meta http-equiv="Content-Type" content="text/html; charset=<%= @options.charset %>" />
|
7
7
|
<title><%= @options.title %></title>
|
8
8
|
</head>
|
9
|
-
<frameset cols="300,*" frameborder="1" border="1" bordercolor="#
|
9
|
+
<frameset cols="300,*" frameborder="1" border="1" bordercolor="#999999" framespacing="1">
|
10
10
|
<frame src="panel/index.html" title="Search" name="panel" />
|
11
11
|
<frame src="<%= index_path %>" name="docwin" />
|
12
12
|
</frameset>
|
data/lib/sdoc/merge.rb
CHANGED
@@ -13,24 +13,22 @@ require 'sdoc/templatable'
|
|
13
13
|
|
14
14
|
class SDoc::Merge
|
15
15
|
include SDoc::Templatable
|
16
|
-
|
16
|
+
|
17
17
|
FLAG_FILE = "created.rid"
|
18
|
-
|
18
|
+
|
19
19
|
def initialize()
|
20
20
|
@names = []
|
21
21
|
@urls = []
|
22
22
|
@op_dir = 'doc'
|
23
23
|
@title = ''
|
24
24
|
@directories = []
|
25
|
-
template_dir = RDoc::Generator::SDoc.template_dir_for('merge')
|
26
|
-
@template_dir = Pathname.new File.expand_path(template_dir)
|
27
25
|
end
|
28
|
-
|
26
|
+
|
29
27
|
def merge(options)
|
30
28
|
parse_options options
|
31
|
-
|
29
|
+
|
32
30
|
@outputdir = Pathname.new( @op_dir )
|
33
|
-
|
31
|
+
|
34
32
|
check_directories
|
35
33
|
setup_output_dir
|
36
34
|
setup_names
|
@@ -40,23 +38,23 @@ class SDoc::Merge
|
|
40
38
|
merge_tree
|
41
39
|
generate_index_file
|
42
40
|
end
|
43
|
-
|
41
|
+
|
44
42
|
def parse_options(options)
|
45
|
-
opts = OptionParser.new do |opt|
|
43
|
+
opts = OptionParser.new do |opt|
|
46
44
|
opt.banner = "Usage: sdoc-merge [options] directories"
|
47
|
-
|
45
|
+
|
48
46
|
opt.on("-n", "--names [NAMES]", "Names of merged repositories. Comma separated") do |v|
|
49
47
|
@names = v.split(',').map{|name| name.strip }
|
50
48
|
end
|
51
|
-
|
49
|
+
|
52
50
|
opt.on("-o", "--op [DIRECTORY]", "Set the output directory") do |v|
|
53
51
|
@op_dir = v
|
54
52
|
end
|
55
|
-
|
53
|
+
|
56
54
|
opt.on("-t", "--title [TITLE]", "Set the title of merged file") do |v|
|
57
55
|
@title = v
|
58
56
|
end
|
59
|
-
|
57
|
+
|
60
58
|
opt.on("-u", "--urls [URLS]", "Paths to merged docs. If you",
|
61
59
|
"set this files and classes won't be actualy",
|
62
60
|
"copied to merged build") do |v|
|
@@ -64,15 +62,16 @@ class SDoc::Merge
|
|
64
62
|
end
|
65
63
|
end
|
66
64
|
opts.parse! options
|
65
|
+
@template_dir = Pathname.new(RDoc::Options.new.template_dir_for 'merge')
|
67
66
|
@directories = options.dup
|
68
67
|
end
|
69
|
-
|
68
|
+
|
70
69
|
def merge_tree
|
71
70
|
tree = []
|
72
71
|
@directories.each_with_index do |dir, i|
|
73
72
|
name = @names[i]
|
74
73
|
url = @urls.empty? ? name : @urls[i]
|
75
|
-
filename = File.join dir, RDoc::Generator::
|
74
|
+
filename = File.join dir, RDoc::Generator::SDoc::TREE_FILE
|
76
75
|
data = open(filename).read.sub(/var tree =\s*/, '')
|
77
76
|
subtree = JSON.parse(data, :max_nesting => 0)
|
78
77
|
item = [
|
@@ -83,14 +82,14 @@ class SDoc::Merge
|
|
83
82
|
]
|
84
83
|
tree << item
|
85
84
|
end
|
86
|
-
|
87
|
-
dst = File.join @op_dir, RDoc::Generator::
|
85
|
+
|
86
|
+
dst = File.join @op_dir, RDoc::Generator::SDoc::TREE_FILE
|
88
87
|
FileUtils.mkdir_p File.dirname(dst)
|
89
88
|
File.open(dst, "w", 0644) do |f|
|
90
89
|
f.write('var tree = '); f.write(tree.to_json(:max_nesting => 0))
|
91
90
|
end
|
92
91
|
end
|
93
|
-
|
92
|
+
|
94
93
|
def append_path subtree, path
|
95
94
|
subtree.map do |item|
|
96
95
|
item[1] = path + '/' + item[1] unless item[1].empty?
|
@@ -98,18 +97,18 @@ class SDoc::Merge
|
|
98
97
|
item
|
99
98
|
end
|
100
99
|
end
|
101
|
-
|
100
|
+
|
102
101
|
def merge_search_index
|
103
102
|
items = []
|
104
103
|
@indexes = {}
|
105
104
|
@directories.each_with_index do |dir, i|
|
106
105
|
name = @names[i]
|
107
106
|
url = @urls.empty? ? name : @urls[i]
|
108
|
-
filename = File.join dir, RDoc::Generator::
|
107
|
+
filename = File.join dir, RDoc::Generator::SDoc::SEARCH_INDEX_FILE
|
109
108
|
data = open(filename).read.sub(/var search_data =\s*/, '')
|
110
109
|
subindex = JSON.parse(data, :max_nesting => 0)
|
111
110
|
@indexes[name] = subindex
|
112
|
-
|
111
|
+
|
113
112
|
searchIndex = subindex["index"]["searchIndex"]
|
114
113
|
longSearchIndex = subindex["index"]["longSearchIndex"]
|
115
114
|
subindex["index"]["info"].each_with_index do |info, j|
|
@@ -126,7 +125,7 @@ class SDoc::Merge
|
|
126
125
|
# type (class/method/file) or name or doc part or namespace
|
127
126
|
[a[:info][5], a[:info][0], a[:info][6], a[:info][1]] <=> [b[:info][5], b[:info][0], b[:info][6], b[:info][1]]
|
128
127
|
end
|
129
|
-
|
128
|
+
|
130
129
|
index = {
|
131
130
|
:searchIndex => items.map{|item| item[:searchIndex]},
|
132
131
|
:longSearchIndex => items.map{|item| item[:longSearchIndex]},
|
@@ -136,14 +135,14 @@ class SDoc::Merge
|
|
136
135
|
:index => index,
|
137
136
|
:badges => @names
|
138
137
|
}
|
139
|
-
|
140
|
-
dst = File.join @op_dir, RDoc::Generator::
|
138
|
+
|
139
|
+
dst = File.join @op_dir, RDoc::Generator::SDoc::SEARCH_INDEX_FILE
|
141
140
|
FileUtils.mkdir_p File.dirname(dst)
|
142
141
|
File.open(dst, "w", 0644) do |f|
|
143
142
|
f.write('var search_data = '); f.write(search_data.to_json(:max_nesting => 0))
|
144
143
|
end
|
145
144
|
end
|
146
|
-
|
145
|
+
|
147
146
|
def extract_index_path dir
|
148
147
|
filename = File.join dir, 'index.html'
|
149
148
|
content = File.open(filename) { |f| f.read }
|
@@ -154,16 +153,16 @@ class SDoc::Merge
|
|
154
153
|
''
|
155
154
|
end
|
156
155
|
end
|
157
|
-
|
156
|
+
|
158
157
|
def generate_index_file
|
159
158
|
templatefile = @template_dir + 'index.rhtml'
|
160
159
|
outfile = @outputdir + 'index.html'
|
161
160
|
url = @urls.empty? ? @names[0] : @urls[0]
|
162
161
|
index_path = url + '/' + extract_index_path(@directories[0])
|
163
|
-
|
162
|
+
|
164
163
|
render_template templatefile, binding(), outfile
|
165
164
|
end
|
166
|
-
|
165
|
+
|
167
166
|
def setup_names
|
168
167
|
unless @names.size > 0
|
169
168
|
@directories.each do |dir|
|
@@ -173,13 +172,13 @@ class SDoc::Merge
|
|
173
172
|
end
|
174
173
|
end
|
175
174
|
end
|
176
|
-
|
175
|
+
|
177
176
|
def copy_docs
|
178
177
|
@directories.each_with_index do |dir, i|
|
179
178
|
name = @names[i]
|
180
|
-
index_dir = File.dirname(RDoc::Generator::
|
179
|
+
index_dir = File.dirname(RDoc::Generator::SDoc::TREE_FILE)
|
181
180
|
FileUtils.mkdir_p(File.join(@op_dir, name))
|
182
|
-
|
181
|
+
|
183
182
|
Dir.new(dir).each do |item|
|
184
183
|
if File.directory?(File.join(dir, item)) && item != '.' && item != '..' && item != index_dir
|
185
184
|
FileUtils.cp_r File.join(dir, item), File.join(@op_dir, name, item), :preserve => true
|
@@ -187,38 +186,38 @@ class SDoc::Merge
|
|
187
186
|
end
|
188
187
|
end
|
189
188
|
end
|
190
|
-
|
189
|
+
|
191
190
|
def copy_files
|
192
191
|
dir = @directories.first
|
193
192
|
Dir.new(dir).each do |item|
|
194
|
-
if item != '.' && item != '..' && item != RDoc::Generator::
|
193
|
+
if item != '.' && item != '..' && item != RDoc::Generator::SDoc::FILE_DIR && item != RDoc::Generator::SDoc::CLASS_DIR
|
195
194
|
FileUtils.cp_r File.join(dir, item), @op_dir, :preserve => true
|
196
195
|
end
|
197
196
|
end
|
198
197
|
end
|
199
|
-
|
198
|
+
|
200
199
|
def setup_output_dir
|
201
200
|
if File.exists? @op_dir
|
202
201
|
error "#{@op_dir} allready exists"
|
203
202
|
end
|
204
203
|
FileUtils.mkdir_p @op_dir
|
205
204
|
end
|
206
|
-
|
205
|
+
|
207
206
|
def check_directories
|
208
207
|
@directories.each do |dir|
|
209
|
-
unless File.exists?(File.join(dir, FLAG_FILE)) &&
|
210
|
-
File.exists?(File.join(dir, RDoc::Generator::
|
211
|
-
File.exists?(File.join(dir, RDoc::Generator::
|
208
|
+
unless File.exists?(File.join(dir, FLAG_FILE)) &&
|
209
|
+
File.exists?(File.join(dir, RDoc::Generator::SDoc::TREE_FILE)) &&
|
210
|
+
File.exists?(File.join(dir, RDoc::Generator::SDoc::SEARCH_INDEX_FILE))
|
212
211
|
error "#{dir} does not seem to be an sdoc directory"
|
213
212
|
end
|
214
213
|
end
|
215
214
|
end
|
216
|
-
|
215
|
+
|
217
216
|
##
|
218
217
|
# Report an error message and exit
|
219
218
|
|
220
219
|
def error(msg)
|
221
220
|
raise RDoc::Error, msg
|
222
221
|
end
|
223
|
-
|
222
|
+
|
224
223
|
end
|
data/sdoc.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 10
|
10
|
+
version: 0.3.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Vladimir Kolesnikov
|