sdoc 0.2.14.1 → 0.2.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,7 @@
6
6
  - <tt>sdoc</tt> - command line tool to run rdoc with generator=shtml
7
7
 
8
8
  == Getting Started
9
- gem sources -a http://gems.github.com
10
- sudo gem install voloko-sdoc
9
+ sudo gem install sdoc
11
10
  sdoc -N projectdir
12
11
 
13
12
  == Command line sdoc
data/Rakefile CHANGED
@@ -21,17 +21,24 @@ end
21
21
 
22
22
  begin
23
23
  require 'jeweler'
24
- jewler = Jeweler::Tasks.new do |gem|
24
+
25
+ spec = Gem::Specification.new do |gem|
25
26
  gem.name = "sdoc"
26
27
  gem.summary = "rdoc html with javascript search index."
27
28
  gem.email = "voloko@gmail.com"
28
29
  gem.homepage = "http://github.com/voloko/sdoc"
29
30
  gem.authors = ["Volodya Kolesnikov"]
30
- gem.add_dependency("json", ">= 1.1.3")
31
31
  gem.add_dependency("rdoc", ">= 2.4.2")
32
-
33
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
32
+
33
+ if defined?(JRUBY_VERSION)
34
+ gem.platform = Gem::Platform.new(['universal', 'java', nil])
35
+ gem.add_dependency("json_pure", ">= 1.1.3")
36
+ else
37
+ gem.add_dependency("json", ">= 1.1.3")
38
+ end
34
39
  end
40
+
41
+ jewler = Jeweler::Tasks.new(spec)
35
42
 
36
43
  desc "Replace system gem with symlink to this folder"
37
44
  task 'ghost' do
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 14
4
+ :patch: 15
@@ -1,7 +1,7 @@
1
1
  require "rdoc/parser/c"
2
2
 
3
- # New RDoc somehow misses class comemnts.
4
- # copyied this function from "2.2.2"
3
+ # New RDoc somehow misses class comments.
4
+ # copied this function from "2.2.2"
5
5
  if ['2.4.2', '2.4.3'].include? RDoc::VERSION
6
6
 
7
7
  class RDoc::Parser::C
@@ -24,7 +24,7 @@ class RDoc::ClassModule
24
24
  def document_self_or_methods
25
25
  document_self || method_list.any?{ |m| m.document_self }
26
26
  end
27
-
27
+
28
28
  def with_documentation?
29
29
  document_self_or_methods || classes_and_modules.any?{ |c| c.with_documentation? }
30
30
  end
@@ -36,84 +36,84 @@ class RDoc::Generator::SHtml
36
36
  include SDoc::GitHub
37
37
  include SDoc::Templatable
38
38
  include SDoc::Helpers
39
-
39
+
40
40
  GENERATOR_DIRS = [File.join('sdoc', 'generator'), File.join('rdoc', 'generator')]
41
-
41
+
42
42
  # Used in js to reduce index sizes
43
43
  TYPE_CLASS = 1
44
44
  TYPE_METHOD = 2
45
45
  TYPE_FILE = 3
46
-
46
+
47
47
  TREE_FILE = File.join 'panel', 'tree.js'
48
48
  SEARCH_INDEX_FILE = File.join 'panel', 'search_index.js'
49
-
49
+
50
50
  FILE_DIR = 'files'
51
51
  CLASS_DIR = 'classes'
52
-
52
+
53
53
  RESOURCES_DIR = File.join('resources', '.')
54
-
54
+
55
55
  attr_reader :basedir
56
-
56
+
57
57
  def self.for(options)
58
58
  self.new(options)
59
59
  end
60
-
60
+
61
61
  def self.template_dir template
62
- $LOAD_PATH.map do |path|
63
- GENERATOR_DIRS.map do |dir|
64
- File.join path, dir, 'template', template
65
- end
66
- end.flatten.find do |dir|
67
- File.directory? dir
68
- end
62
+ $LOAD_PATH.map do |path|
63
+ GENERATOR_DIRS.map do |dir|
64
+ File.join path, dir, 'template', template
65
+ end
66
+ end.flatten.find do |dir|
67
+ File.directory? dir
68
+ end
69
69
  end
70
-
70
+
71
71
  def initialize(options)
72
- @options = options
73
- @options.diagram = false
72
+ @options = options
73
+ @options.diagram = false
74
74
  @github_url_cache = {}
75
-
76
- template = @options.template || 'direct'
77
75
 
78
- templ_dir = self.class.template_dir template
76
+ template = @options.template || 'direct'
79
77
 
80
- raise RDoc::Error, "could not find template #{template.inspect}" unless
81
- templ_dir
82
-
83
- @template_dir = Pathname.new File.expand_path(templ_dir)
84
- @basedir = Pathname.pwd.expand_path
78
+ templ_dir = self.class.template_dir template
79
+
80
+ raise RDoc::Error, "could not find template #{template.inspect}" unless
81
+ templ_dir
82
+
83
+ @template_dir = Pathname.new File.expand_path(templ_dir)
84
+ @basedir = Pathname.pwd.expand_path
85
85
  end
86
-
86
+
87
87
  def generate( top_levels )
88
- @outputdir = Pathname.new( @options.op_dir ).expand_path( @basedir )
89
- @files = top_levels.sort
90
- @classes = RDoc::TopLevel.all_classes_and_modules.sort
88
+ @outputdir = Pathname.new( @options.op_dir ).expand_path( @basedir )
89
+ @files = top_levels.sort
90
+ @classes = RDoc::TopLevel.all_classes_and_modules.sort
91
91
 
92
- # Now actually write the output
92
+ # Now actually write the output
93
93
  copy_resources
94
94
  generate_class_tree
95
95
  generate_search_index
96
- generate_file_files
97
- generate_class_files
98
- generate_index_file
96
+ generate_file_files
97
+ generate_class_files
98
+ generate_index_file
99
+ end
100
+
101
+ def class_dir
102
+ CLASS_DIR
103
+ end
104
+
105
+ def file_dir
106
+ FILE_DIR
99
107
  end
100
-
101
- def class_dir
102
- CLASS_DIR
103
- end
104
108
 
105
- def file_dir
106
- FILE_DIR
107
- end
108
109
 
109
-
110
110
  protected
111
- ### Output progress information if debugging is enabled
112
- def debug_msg( *msg )
113
- return unless $DEBUG_RDOC
114
- $stderr.puts( *msg )
115
- end
116
-
111
+ ### Output progress information if debugging is enabled
112
+ def debug_msg( *msg )
113
+ return unless $DEBUG_RDOC
114
+ $stderr.puts( *msg )
115
+ end
116
+
117
117
  ### Create class tree structure and write it as json
118
118
  def generate_class_tree
119
119
  debug_msg "Generating class tree"
@@ -124,7 +124,7 @@ class RDoc::Generator::SHtml
124
124
  f.write('var tree = '); f.write(tree.to_json)
125
125
  end unless $dryrun
126
126
  end
127
-
127
+
128
128
  ### Recursivly build class tree structure
129
129
  def generate_class_tree_level(classes)
130
130
  tree = []
@@ -139,22 +139,22 @@ class RDoc::Generator::SHtml
139
139
  end
140
140
  tree
141
141
  end
142
-
142
+
143
143
  ### Create search index for all classes, methods and files
144
144
  ### Wite it as json
145
145
  def generate_search_index
146
146
  debug_msg "Generating search index"
147
-
147
+
148
148
  index = {
149
149
  :searchIndex => [],
150
150
  :longSearchIndex => [],
151
151
  :info => []
152
152
  }
153
-
153
+
154
154
  add_class_search_index(index)
155
155
  add_method_search_index(index)
156
156
  add_file_search_index(index)
157
-
157
+
158
158
  debug_msg " writing search index to %s" % SEARCH_INDEX_FILE
159
159
  data = {
160
160
  :index => index
@@ -163,11 +163,11 @@ class RDoc::Generator::SHtml
163
163
  f.write('var search_data = '); f.write(data.to_json)
164
164
  end unless $dryrun
165
165
  end
166
-
166
+
167
167
  ### Add files to search +index+ array
168
168
  def add_file_search_index(index)
169
169
  debug_msg " generating file search index"
170
-
170
+
171
171
  @files.select { |file|
172
172
  file.document_self
173
173
  }.sort.each do |file|
@@ -183,20 +183,21 @@ class RDoc::Generator::SHtml
183
183
  ])
184
184
  end
185
185
  end
186
-
186
+
187
187
  ### Add classes to search +index+ array
188
188
  def add_class_search_index(index)
189
189
  debug_msg " generating class search index"
190
-
190
+
191
191
  @classes.select { |klass|
192
192
  klass.document_self_or_methods
193
193
  }.sort.each do |klass|
194
194
  modulename = klass.module? ? '' : (klass.superclass ? (String === klass.superclass ? klass.superclass : klass.superclass.full_name) : '')
195
195
  index[:searchIndex].push( search_string(klass.name) )
196
196
  index[:longSearchIndex].push( search_string(klass.parent.full_name) )
197
+ files = klass.in_files.map{ |file| file.absolute_name }
197
198
  index[:info].push([
198
199
  klass.name,
199
- klass.parent.full_name,
200
+ files.include?(klass.parent.full_name) ? files.first : klass.parent.full_name,
200
201
  klass.path,
201
202
  modulename ? " < #{modulename}" : '',
202
203
  snippet(klass.comment),
@@ -204,20 +205,20 @@ class RDoc::Generator::SHtml
204
205
  ])
205
206
  end
206
207
  end
207
-
208
+
208
209
  ### Add methods to search +index+ array
209
210
  def add_method_search_index(index)
210
211
  debug_msg " generating method search index"
211
-
212
+
212
213
  list = @classes.map { |klass|
213
214
  klass.method_list
214
215
  }.flatten.sort{ |a, b| a.name == b.name ? a.parent.full_name <=> b.parent.full_name : a.name <=> b.name }.select { |method|
215
216
  method.document_self
216
217
  }
217
218
  unless @options.show_all
218
- list = list.find_all {|m| m.visibility == :public || m.visibility == :protected || m.force_documentation }
219
+ list = list.find_all {|m| m.visibility == :public || m.visibility == :protected || m.force_documentation }
219
220
  end
220
-
221
+
221
222
  list.each do |method|
222
223
  index[:searchIndex].push( search_string(method.name) + '()' )
223
224
  index[:longSearchIndex].push( search_string(method.parent.full_name) )
@@ -231,37 +232,37 @@ class RDoc::Generator::SHtml
231
232
  ])
232
233
  end
233
234
  end
234
-
235
- ### Generate a documentation file for each class
236
- def generate_class_files
237
- debug_msg "Generating class documentation in #@outputdir"
235
+
236
+ ### Generate a documentation file for each class
237
+ def generate_class_files
238
+ debug_msg "Generating class documentation in #@outputdir"
238
239
  templatefile = @template_dir + 'class.rhtml'
239
240
 
240
- @classes.each do |klass|
241
- debug_msg " working on %s (%s)" % [ klass.full_name, klass.path ]
242
- outfile = @outputdir + klass.path
243
- rel_prefix = @outputdir.relative_path_from( outfile.dirname )
244
-
245
- debug_msg " rendering #{outfile}"
246
- self.render_template( templatefile, binding(), outfile )
247
- end
248
- end
249
-
250
- ### Generate a documentation file for each file
251
- def generate_file_files
252
- debug_msg "Generating file documentation in #@outputdir"
241
+ @classes.each do |klass|
242
+ debug_msg " working on %s (%s)" % [ klass.full_name, klass.path ]
243
+ outfile = @outputdir + klass.path
244
+ rel_prefix = @outputdir.relative_path_from( outfile.dirname )
245
+
246
+ debug_msg " rendering #{outfile}"
247
+ self.render_template( templatefile, binding(), outfile )
248
+ end
249
+ end
250
+
251
+ ### Generate a documentation file for each file
252
+ def generate_file_files
253
+ debug_msg "Generating file documentation in #@outputdir"
253
254
  templatefile = @template_dir + 'file.rhtml'
254
-
255
- @files.each do |file|
256
- outfile = @outputdir + file.path
257
- debug_msg " working on %s (%s)" % [ file.full_name, outfile ]
258
- rel_prefix = @outputdir.relative_path_from( outfile.dirname )
259
-
260
- debug_msg " rendering #{outfile}"
261
- self.render_template( templatefile, binding(), outfile )
262
- end
263
- end
264
-
255
+
256
+ @files.each do |file|
257
+ outfile = @outputdir + file.path
258
+ debug_msg " working on %s (%s)" % [ file.full_name, outfile ]
259
+ rel_prefix = @outputdir.relative_path_from( outfile.dirname )
260
+
261
+ debug_msg " rendering #{outfile}"
262
+ self.render_template( templatefile, binding(), outfile )
263
+ end
264
+ end
265
+
265
266
  def index_file
266
267
  if @options.main_page && file = @files.find { |f| f.full_name == @options.main_page }
267
268
  file
@@ -270,17 +271,17 @@ class RDoc::Generator::SHtml
270
271
  end
271
272
  end
272
273
 
273
- ### Create index.html with frameset
274
- def generate_index_file
275
- debug_msg "Generating index file in #@outputdir"
274
+ ### Create index.html with frameset
275
+ def generate_index_file
276
+ debug_msg "Generating index file in #@outputdir"
276
277
  templatefile = @template_dir + 'index.rhtml'
277
278
  outfile = @outputdir + 'index.html'
278
279
  index_path = index_file.path
279
-
280
- self.render_template( templatefile, binding(), outfile )
281
- end
282
-
283
- ### Strip comments on a space after 100 chars
280
+
281
+ self.render_template( templatefile, binding(), outfile )
282
+ end
283
+
284
+ ### Strip comments on a space after 100 chars
284
285
  def snippet(str)
285
286
  str ||= ''
286
287
  if str =~ /^(?>\s*)[^\#]/
@@ -288,9 +289,9 @@ class RDoc::Generator::SHtml
288
289
  else
289
290
  content = str.gsub(/^\s*(#+)\s*/, '')
290
291
  end
291
-
292
+
292
293
  content = content.sub(/^(.{100,}?)\s.*/m, "\\1").gsub(/\r?\n/m, ' ')
293
-
294
+
294
295
  begin
295
296
  content.to_json
296
297
  rescue # might fail on non-unicode string
@@ -309,11 +310,11 @@ class RDoc::Generator::SHtml
309
310
  string ||= ''
310
311
  string.downcase.gsub(/\s/,'')
311
312
  end
312
-
313
+
313
314
  ### Copy all the resource files to output dir
314
315
  def copy_resources
315
316
  resoureces_path = @template_dir + RESOURCES_DIR
316
- debug_msg "Copying #{resoureces_path}/** to #{@outputdir}/**"
317
+ debug_msg "Copying #{resoureces_path}/** to #{@outputdir}/**"
317
318
  FileUtils.cp_r resoureces_path.to_s, @outputdir.to_s, :preserve => true unless $dryrun
318
319
  end
319
320
 
@@ -47,6 +47,21 @@ h4 {
47
47
  font-size: 1em;
48
48
  }
49
49
 
50
+ table
51
+ {
52
+ margin-bottom: 1em;
53
+ }
54
+
55
+ td, th
56
+ {
57
+ padding: 0 0.7em 0.3em 0;
58
+ }
59
+
60
+ th
61
+ {
62
+ font-weight: bold;
63
+ }
64
+
50
65
  .clear
51
66
  {
52
67
  clear: both;
@@ -1,6 +1,8 @@
1
1
  require 'optparse'
2
2
  require 'pathname'
3
3
  require 'fileutils'
4
+
5
+ gem 'json_pure', '>= 1.1.3' if defined?(::JRUBY_VERSION)
4
6
  require 'json'
5
7
 
6
8
  require 'sdoc/templatable'
@@ -1,12 +1,11 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
1
  Gem::Specification.new do |s|
4
2
  s.name = %q{sdoc}
5
- s.version = "0.2.14.1"
3
+ s.version = "0.2.15"
4
+ s.platform = Gem::Platform.new(["universal", "java", nil]) if defined?(::JRUBY_VERSION)
6
5
 
7
6
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
7
  s.authors = ["Volodya Kolesnikov"]
9
- s.date = %q{2009-08-14}
8
+ s.date = %q{2009-12-12}
10
9
  s.email = %q{voloko@gmail.com}
11
10
  s.executables = ["sdoc", "sdoc-merge"]
12
11
  s.extra_rdoc_files = [
@@ -68,7 +67,7 @@ Gem::Specification.new do |s|
68
67
  s.homepage = %q{http://github.com/voloko/sdoc}
69
68
  s.rdoc_options = ["--charset=UTF-8"]
70
69
  s.require_paths = ["lib"]
71
- s.rubygems_version = %q{1.3.4}
70
+ s.rubygems_version = %q{1.3.5}
72
71
  s.summary = %q{rdoc html with javascript search index.}
73
72
 
74
73
  if s.respond_to? :specification_version then
@@ -76,14 +75,15 @@ Gem::Specification.new do |s|
76
75
  s.specification_version = 3
77
76
 
78
77
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
79
- s.add_runtime_dependency(%q<json>, [">= 1.1.3"])
80
78
  s.add_runtime_dependency(%q<rdoc>, [">= 2.4.2"])
79
+ s.add_runtime_dependency(defined?(::JRUBY_VERSION) ? %q<json_pure> : %q<json>, [">= 1.1.3"])
81
80
  else
82
- s.add_dependency(%q<json>, [">= 1.1.3"])
83
81
  s.add_dependency(%q<rdoc>, [">= 2.4.2"])
82
+ s.add_runtime_dependency(defined?(::JRUBY_VERSION) ? %q<json_pure> : %q<json>, [">= 1.1.3"])
84
83
  end
85
84
  else
86
- s.add_dependency(%q<json>, [">= 1.1.3"])
87
85
  s.add_dependency(%q<rdoc>, [">= 2.4.2"])
86
+ s.add_runtime_dependency(defined?(::JRUBY_VERSION) ? %q<json_pure> : %q<json>, [">= 1.1.3"])
88
87
  end
89
88
  end
89
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14.1
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodya Kolesnikov
@@ -9,28 +9,28 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-14 00:00:00 +04:00
12
+ date: 2009-12-12 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: json
16
+ name: rdoc
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.1.3
23
+ version: 2.4.2
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
- name: rdoc
26
+ name: json
27
27
  type: :runtime
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.4.2
33
+ version: 1.1.3
34
34
  version:
35
35
  description:
36
36
  email: voloko@gmail.com
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  requirements: []
118
118
 
119
119
  rubyforge_project:
120
- rubygems_version: 1.3.4
120
+ rubygems_version: 1.3.5
121
121
  signing_key:
122
122
  specification_version: 3
123
123
  summary: rdoc html with javascript search index.