voloko-sdoc 0.0.5 → 0.1.1

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.
Files changed (29) hide show
  1. data/README +1 -1
  2. data/bin/sdoc +0 -1
  3. data/bin/sdoc-merge +12 -0
  4. data/lib/sdoc.rb +15 -7
  5. data/lib/sdoc/generator/shtml.rb +671 -0
  6. data/lib/sdoc/generator/template/shtml/_context.rhtml +163 -0
  7. data/lib/sdoc/generator/template/shtml/class.rhtml +46 -0
  8. data/lib/sdoc/generator/template/shtml/file.rhtml +37 -0
  9. data/lib/sdoc/generator/template/shtml/index.rhtml +14 -0
  10. data/lib/sdoc/generator/template/shtml/resources/css/main.css +191 -0
  11. data/lib/sdoc/{generators/template/shtml/resources/css/master-frameset.css → generator/template/shtml/resources/css/panel.css} +83 -2
  12. data/lib/sdoc/{generators → generator}/template/shtml/resources/css/reset.css +0 -0
  13. data/lib/sdoc/{generators → generator}/template/shtml/resources/i/arrows.png +0 -0
  14. data/lib/sdoc/{generators → generator}/template/shtml/resources/i/results_bg.png +0 -0
  15. data/lib/sdoc/{generators → generator}/template/shtml/resources/i/tree_bg.png +0 -0
  16. data/lib/sdoc/{generators → generator}/template/shtml/resources/js/jquery-1.3.2.min.js +0 -0
  17. data/lib/sdoc/generator/template/shtml/resources/js/main.js +34 -0
  18. data/lib/sdoc/generator/template/shtml/resources/js/searchdoc.js +600 -0
  19. data/lib/sdoc/{generators/template/shtml/resources/panel.html → generator/template/shtml/resources/panel/index.html} +6 -6
  20. data/lib/sdoc/github.rb +64 -0
  21. data/lib/sdoc/merge.rb +166 -0
  22. metadata +117 -19
  23. data/lib/sdoc/code_objects.rb +0 -17
  24. data/lib/sdoc/generators/shtml_generator.rb +0 -354
  25. data/lib/sdoc/generators/template/shtml/resources/js/searchdoc.js +0 -595
  26. data/lib/sdoc/generators/template/shtml/shtml.rb +0 -615
  27. data/lib/sdoc/options.rb +0 -61
  28. data/test/options_test.rb +0 -33
  29. data/test/sdoc_test.rb +0 -7
data/README CHANGED
@@ -4,4 +4,4 @@ See online on railsapi.com
4
4
 
5
5
  == Usage
6
6
  sudo gem install voloko-sdoc --source http://gems.github.com
7
- sdoc --github_url http://github.com/yourname/yourproject -S projectdir
7
+ sdoc -N projectdir
data/bin/sdoc CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby -KU
2
2
 
3
- require 'rdoc/rdoc'
4
3
  require File.dirname(__FILE__) + '/../lib/sdoc' # add extensions
5
4
 
6
5
  begin
data/bin/sdoc-merge ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby -KU
2
+
3
+ require File.dirname(__FILE__) + '/../lib/sdoc' # add extensions
4
+ require 'sdoc/merge'
5
+
6
+ begin
7
+ m = SDoc::Merge.new
8
+ m.merge(ARGV)
9
+ rescue RDoc::RDocError => e
10
+ $stderr.puts e.message
11
+ exit(1)
12
+ end
data/lib/sdoc.rb CHANGED
@@ -1,10 +1,18 @@
1
- require "rdoc/rdoc"
2
1
  $:.unshift File.dirname(__FILE__)
3
- require "sdoc/options"
4
- require "sdoc/code_objects"
2
+ $:.unshift File.join File.dirname(__FILE__), '..', 'rdoc', 'lib'
3
+ require "rdoc/rdoc"
5
4
 
6
5
  module SDoc
7
- RDoc::RDoc::GENERATORS['shtml'] = RDoc::RDoc::Generator.new("sdoc/generators/shtml_generator.rb",
8
- "SHTMLGenerator".intern,
9
- 'shtml')
10
- end
6
+ end
7
+
8
+ require "sdoc/generator/shtml"
9
+
10
+ class RDoc::Options
11
+ alias_method :rdoc_initialize, :initialize
12
+
13
+ def initialize
14
+ rdoc_initialize
15
+ @generator = RDoc::Generator::SHtml
16
+ end
17
+ end
18
+
@@ -0,0 +1,671 @@
1
+ require 'rubygems'
2
+ require 'json'
3
+ require 'pathname'
4
+ require 'fileutils'
5
+ require 'erb'
6
+
7
+ require 'rdoc/rdoc'
8
+ require 'rdoc/generator'
9
+ require 'rdoc/generator/markup'
10
+
11
+ require 'sdoc/github'
12
+
13
+ class RDoc::ClassModule
14
+ def with_documentation?
15
+ document_self || classes_and_modules.any?{ |c| c.with_documentation? }
16
+ end
17
+ end
18
+
19
+ class RDoc::Generator::SHtml
20
+ RDoc::RDoc.add_generator( self )
21
+ include ERB::Util
22
+ include SDoc::GitHub
23
+
24
+ GENERATOR_DIRS = [File.join('sdoc', 'generator'), File.join('rdoc', 'generator')]
25
+
26
+ # Used in js to reduce index sizes
27
+ TYPE_CLASS = 1
28
+ TYPE_METHOD = 2
29
+ TYPE_FILE = 3
30
+
31
+ TREE_FILE = File.join 'panel', 'tree.js'
32
+ SEARCH_INDEX_FILE = File.join 'panel', 'search_index.js'
33
+
34
+ FILE_DIR = 'files'
35
+ CLASS_DIR = 'classes'
36
+
37
+ RESOURCES_DIR = File.join('resources', '.')
38
+
39
+ attr_reader :basedir
40
+
41
+ def self.for(options)
42
+ self.new(options)
43
+ end
44
+
45
+ def initialize(options)
46
+ @options = options
47
+ @options.diagram = false
48
+ @github_url_cache = {}
49
+
50
+ template = @options.template || 'shtml'
51
+
52
+ template_dir = $LOAD_PATH.map do |path|
53
+ GENERATOR_DIRS.map do |dir|
54
+ File.join path, dir, 'template', template
55
+ end
56
+ end.flatten.find do |dir|
57
+ File.directory? dir
58
+ end
59
+
60
+ raise RDoc::Error, "could not find template #{template.inspect}" unless
61
+ template_dir
62
+
63
+ @template_dir = Pathname.new File.expand_path(template_dir)
64
+ @basedir = Pathname.pwd.expand_path
65
+ end
66
+
67
+ def generate( top_levels )
68
+ @outputdir = Pathname.new( @options.op_dir ).expand_path( @basedir )
69
+ @files = top_levels.sort
70
+ @classes = RDoc::TopLevel.all_classes_and_modules.sort
71
+
72
+ # Now actually write the output
73
+ copy_resources
74
+ generate_class_tree
75
+ generate_search_index
76
+ generate_file_files
77
+ generate_class_files
78
+ generate_index_file
79
+ end
80
+
81
+ def class_dir
82
+ CLASS_DIR
83
+ end
84
+
85
+ def file_dir
86
+ FILE_DIR
87
+ end
88
+
89
+
90
+ protected
91
+ ### Output progress information if debugging is enabled
92
+ def debug_msg( *msg )
93
+ return unless $DEBUG_RDOC
94
+ $stderr.puts( *msg )
95
+ end
96
+
97
+ ### Create class tree structure and write it as json
98
+ def generate_class_tree
99
+ debug_msg "Generating class tree"
100
+ topclasses = @classes.select {|klass| !(RDoc::ClassModule === klass.parent) }
101
+ tree = generate_class_tree_level topclasses
102
+ debug_msg " writing class tree to %s" % TREE_FILE
103
+ File.open(TREE_FILE, "w") do |f|
104
+ f.write('var tree = '); f.write(tree.to_json)
105
+ end unless $dryrun
106
+ end
107
+
108
+ ### Recursivly build class tree structure
109
+ def generate_class_tree_level(classes)
110
+ tree = []
111
+ classes.select{|c| c.with_documentation? }.sort.each do |klass|
112
+ item = [
113
+ klass.name,
114
+ klass.document_self ? klass.path : '',
115
+ klass.module? ? '' : (klass.superclass ? " < #{String === klass.superclass ? klass.superclass : klass.superclass.full_name}" : ''),
116
+ generate_class_tree_level(klass.classes_and_modules)
117
+ ]
118
+ tree << item
119
+ end
120
+ tree
121
+ end
122
+
123
+ ### Create search index for all classes, methods and files
124
+ ### Wite it as json
125
+ def generate_search_index
126
+ debug_msg "Generating search index"
127
+
128
+ index = {
129
+ :searchIndex => [],
130
+ :longSearchIndex => [],
131
+ :info => []
132
+ }
133
+
134
+ add_class_search_index(index)
135
+ add_method_search_index(index)
136
+ add_file_search_index(index)
137
+
138
+ debug_msg " writing search index to %s" % SEARCH_INDEX_FILE
139
+ data = {
140
+ :index => index
141
+ }
142
+ File.open(SEARCH_INDEX_FILE, "w") do |f|
143
+ f.write('var search_data = '); f.write(data.to_json)
144
+ end unless $dryrun
145
+ end
146
+
147
+ ### Add files to search +index+ array
148
+ def add_file_search_index(index)
149
+ debug_msg " generating file search index"
150
+
151
+ @files.select { |method|
152
+ method.document_self
153
+ }.sort.each do |file|
154
+ index[:searchIndex].push( search_string(file.name) )
155
+ index[:longSearchIndex].push( search_string(file.path) )
156
+ index[:info].push([
157
+ file.name,
158
+ file.path,
159
+ file.path,
160
+ '',
161
+ snippet(file.comment),
162
+ TYPE_FILE
163
+ ])
164
+ end
165
+ end
166
+
167
+ ### Add classes to search +index+ array
168
+ def add_class_search_index(index)
169
+ debug_msg " generating class search index"
170
+
171
+ @classes.select { |method|
172
+ method.document_self
173
+ }.sort.each do |klass|
174
+ index[:searchIndex].push( search_string(klass.name) )
175
+ index[:longSearchIndex].push( search_string(klass.parent.name) )
176
+ index[:info].push([
177
+ klass.name,
178
+ klass.parent.full_name,
179
+ klass.path,
180
+ klass.module? ? '' : (klass.superclass ? " < #{String === klass.superclass ? klass.superclass : klass.superclass.full_name}" : ''),
181
+ snippet(klass.comment),
182
+ TYPE_CLASS
183
+ ])
184
+ end
185
+ end
186
+
187
+ ### Add methods to search +index+ array
188
+ def add_method_search_index(index)
189
+ debug_msg " generating method search index"
190
+
191
+ list = @classes.map { |klass|
192
+ klass.method_list
193
+ }.flatten.sort{ |a, b| a.name <=> b.name }.select { |method|
194
+ method.document_self
195
+ }
196
+ unless @options.show_all
197
+ list = list.find_all {|m| m.visibility == :public || m.visibility == :protected || m.force_documentation }
198
+ end
199
+
200
+ list.each do |method|
201
+ index[:searchIndex].push( search_string(method.name) )
202
+ index[:longSearchIndex].push( search_string(method.parent.name) )
203
+ index[:info].push([
204
+ method.name,
205
+ method.parent.full_name,
206
+ method.path,
207
+ method.params,
208
+ snippet(method.comment),
209
+ TYPE_METHOD
210
+ ])
211
+ end
212
+ end
213
+
214
+ ### Generate a documentation file for each class
215
+ def generate_class_files
216
+ debug_msg "Generating class documentation in #@outputdir"
217
+ templatefile = @template_dir + 'class.rhtml'
218
+
219
+ @classes.each do |klass|
220
+ debug_msg " working on %s (%s)" % [ klass.full_name, klass.path ]
221
+ outfile = @outputdir + klass.path
222
+ rel_prefix = @outputdir.relative_path_from( outfile.dirname )
223
+
224
+ debug_msg " rendering #{outfile}"
225
+ self.render_template( templatefile, binding(), outfile )
226
+ end
227
+ end
228
+
229
+ ### Generate a documentation file for each file
230
+ def generate_file_files
231
+ debug_msg "Generating file documentation in #@outputdir"
232
+ templatefile = @template_dir + 'file.rhtml'
233
+
234
+ @files.each do |file|
235
+ outfile = @outputdir + file.path
236
+ debug_msg " working on %s (%s)" % [ file.full_name, outfile ]
237
+ rel_prefix = @outputdir.relative_path_from( outfile.dirname )
238
+
239
+ debug_msg " rendering #{outfile}"
240
+ self.render_template( templatefile, binding(), outfile )
241
+ end
242
+ end
243
+
244
+ ### Create index.html with frameset
245
+ def generate_index_file
246
+ debug_msg "Generating index file in #@outputdir"
247
+ templatefile = @template_dir + 'index.rhtml'
248
+ outfile = @outputdir + 'index.html'
249
+ index_path = @files.first.path
250
+
251
+ self.render_template( templatefile, binding(), outfile )
252
+ end
253
+
254
+ ### Strip comments on a space after 100 chars
255
+ def snippet(str)
256
+ str ||= ''
257
+ if str =~ /^(?>\s*)[^\#]/
258
+ content = str
259
+ else
260
+ content = str.gsub(/^\s*(#+)\s*/, '')
261
+ end
262
+ content.sub(/^(.{100,}?)\s.*/m, "\\1").gsub(/\r?\n/m, ' ')
263
+ end
264
+
265
+ ### Build search index key
266
+ def search_string(string)
267
+ string ||= ''
268
+ string.downcase.gsub(/\s/,'')
269
+ end
270
+
271
+ ### Copy all the resource files to output dir
272
+ def copy_resources
273
+ resoureces_path = @template_dir + RESOURCES_DIR
274
+ debug_msg "Copying #{resoureces_path}/** to #{@outputdir}/**"
275
+ FileUtils.cp_r resoureces_path.to_s, @outputdir.to_s unless $dryrun
276
+ end
277
+
278
+ ### Load and render the erb template in the given +templatefile+ within the
279
+ ### specified +context+ (a Binding object) and return output
280
+ ### Both +templatefile+ and +outfile+ should be Pathname-like objects.
281
+ def eval_template(templatefile, context)
282
+ template_src = templatefile.read
283
+ template = ERB.new( template_src, nil, '<>' )
284
+ template.filename = templatefile.to_s
285
+
286
+ begin
287
+ template.result( context )
288
+ rescue NoMethodError => err
289
+ raise RDoc::Error, "Error while evaluating %s: %s (at %p)" % [
290
+ templatefile.to_s,
291
+ err.message,
292
+ eval( "_erbout[-50,50]", context )
293
+ ], err.backtrace
294
+ end
295
+ end
296
+
297
+ ### Load and render the erb template with the given +template_name+ within
298
+ ### current context. Adds all +local_assigns+ to context
299
+ def include_template(template_name, local_assigns = {})
300
+ source = local_assigns.keys.map { |key| "#{key} = local_assigns[:#{key}];" }.join
301
+ eval(source)
302
+
303
+ templatefile = @template_dir + template_name
304
+ eval_template(templatefile, binding)
305
+ end
306
+
307
+ ### Load and render the erb template in the given +templatefile+ within the
308
+ ### specified +context+ (a Binding object) and write it out to +outfile+.
309
+ ### Both +templatefile+ and +outfile+ should be Pathname-like objects.
310
+ def render_template( templatefile, context, outfile )
311
+ output = eval_template(templatefile, context)
312
+ unless $dryrun
313
+ outfile.dirname.mkpath
314
+ outfile.open( 'w', 0644 ) do |ofh|
315
+ ofh.print( output )
316
+ end
317
+ else
318
+ debug_msg " would have written %d bytes to %s" %
319
+ [ output.length, outfile ]
320
+ end
321
+ end
322
+ end
323
+
324
+ # module Generators
325
+ # # SOURCE_DIR = 'source'
326
+ #
327
+ # module MarkUp
328
+ # def snippetize(str)
329
+ # if str =~ /^(?>\s*)[^\#]/
330
+ # content = str
331
+ # else
332
+ # content = str.gsub(/^\s*(#+)\s*/, '')
333
+ # end
334
+ # content.sub(/^(.{0,100}).*$/m, "\\1").gsub(/\r?\n/m, ' ')
335
+ # end
336
+ # end
337
+ #
338
+ # module CollectMethods
339
+ # def collect_methods
340
+ # list = @context.method_list
341
+ # unless @options.show_all
342
+ # list = list.find_all {|m| m.visibility == :public || m.visibility == :protected || m.force_documentation }
343
+ # end
344
+ # @methods = list.collect {|m| SHtmlMethod.new(m, self, @options) }
345
+ # end
346
+ # end
347
+ #
348
+ # #####################################################################
349
+ #
350
+ # class SHtmlClass < HtmlClass
351
+ # include CollectMethods
352
+ #
353
+ # attr_accessor :children
354
+ #
355
+ # def initialize(context, html_file, prefix, options)
356
+ # super(context, html_file, prefix, options)
357
+ # @children = []
358
+ # end
359
+ #
360
+ # def params
361
+ # @context.superclass ? " < #{@context.superclass}" : ''
362
+ # end
363
+ #
364
+ # def snippet
365
+ # @snippet ||= snippetize(@context.comment)
366
+ # end
367
+ #
368
+ # def namespace
369
+ # @context.parent ? @context.parent.name : ''
370
+ # end
371
+ #
372
+ # def title
373
+ # @context.name
374
+ # end
375
+ #
376
+ # def content?
377
+ # document_self || children.any?{ |c| c.content? }
378
+ # end
379
+ #
380
+ # def path_if_available
381
+ # document_self ? path : ''
382
+ # end
383
+ #
384
+ # def github_url
385
+ # @html_file.github_url
386
+ # end
387
+ # end
388
+ #
389
+ # #####################################################################
390
+ #
391
+ # class SHtmlFile < HtmlFile
392
+ # include CollectMethods
393
+ #
394
+ # attr_accessor :github_url
395
+ #
396
+ # def initialize(context, options, file_dir)
397
+ # super(context, options, file_dir)
398
+ # @github_url = SHTMLGenerator.github_url(@context.file_relative_name, @options) if (@options.github_url)
399
+ # end
400
+ #
401
+ # def params
402
+ # ''
403
+ # end
404
+ #
405
+ # def snippet
406
+ # @snippet ||= snippetize(@context.comment)
407
+ # end
408
+ #
409
+ # def namespace
410
+ # @context.file_absolute_name
411
+ # end
412
+ #
413
+ # def title
414
+ # File.basename(namespace)
415
+ # end
416
+ #
417
+ # def value_hash
418
+ # super
419
+ # @values["github_url"] = github_url if (@options.github_url)
420
+ # @values
421
+ # end
422
+ #
423
+ # def absolute_path
424
+ # @context.file_expanded_path
425
+ # end
426
+ #
427
+ # end
428
+ #
429
+ # #####################################################################
430
+ #
431
+ # class SHtmlMethod < HtmlMethod
432
+ # def snippet
433
+ # @snippet ||= snippetize(@context.comment)
434
+ # end
435
+ #
436
+ # def namespace
437
+ # @html_class.name
438
+ # end
439
+ #
440
+ # def title
441
+ # name
442
+ # end
443
+ #
444
+ # def github_url
445
+ # if @source_code =~ /File\s(\S+), line (\d+)/
446
+ # file = $1
447
+ # line = $2.to_i
448
+ # end
449
+ # url = SHTMLGenerator.github_url(file, @options)
450
+ # unless line.nil? || url.nil?
451
+ # url + "#L#{line}"
452
+ # else
453
+ # ''
454
+ # end
455
+ # end
456
+ # end
457
+ #
458
+ # #####################################################################
459
+ #
460
+ # class SHTMLGenerator < HTMLGenerator
461
+ #
462
+ # @@github_url_cache = {}
463
+ #
464
+ # def self.github_url(file_relative_name, options)
465
+ # unless @@github_url_cache.has_key? file_relative_name
466
+ # file = AllReferences[file_relative_name]
467
+ # if file.nil?
468
+ # return nil
469
+ # end
470
+ # path = file.absolute_path
471
+ # name = File.basename(file_relative_name)
472
+ #
473
+ # pwd = Dir.pwd
474
+ # Dir.chdir(File.dirname(path))
475
+ # s = `git log -1 --pretty=format:"commit %H" #{name}`
476
+ # Dir.chdir(pwd)
477
+ #
478
+ # m = s.match(/commit\s+(\S+)/)
479
+ # if m
480
+ # repository_path = path_relative_to_repository(path)
481
+ # @@github_url_cache[file_relative_name] = "#{options.github_url}/blob/#{m[1]}#{repository_path}"
482
+ # end
483
+ # end
484
+ # @@github_url_cache[file_relative_name]
485
+ # end
486
+ #
487
+ # def self.path_relative_to_repository(path)
488
+ # root = find_git_dir(path)
489
+ # path[root.size..path.size]
490
+ # end
491
+ #
492
+ # def self.find_git_dir(path)
493
+ # while !path.empty? && path != '.'
494
+ # if (File.exists? File.join(path, '.git'))
495
+ # return path
496
+ # end
497
+ # path = File.dirname(path)
498
+ # end
499
+ # ''
500
+ # end
501
+ #
502
+ #
503
+ # def SHTMLGenerator.for(options)
504
+ # AllReferences::reset
505
+ # HtmlMethod::reset
506
+ #
507
+ # SHTMLGenerator.new(options)
508
+ # end
509
+ #
510
+ # def load_html_template
511
+ # template = @options.template
512
+ # unless template =~ %r{/|\\}
513
+ # template = File.join("sdoc/generators/template",
514
+ # @options.generator.key, template)
515
+ # end
516
+ # require template
517
+ # extend RDoc::Page
518
+ # rescue LoadError
519
+ # $stderr.puts "Could not find HTML template '#{template}'"
520
+ # exit 99
521
+ # end
522
+ #
523
+ # def generate_html
524
+ # # the individual descriptions for files and classes
525
+ # gen_into(@files)
526
+ # gen_into(@classes)
527
+ # gen_search_index
528
+ # gen_tree_index
529
+ # gen_main_index
530
+ # copy_resources
531
+ #
532
+ # # this method is defined in the template file
533
+ # write_extra_pages if defined? write_extra_pages
534
+ # end
535
+ #
536
+ # def build_indices
537
+ # @toplevels.each do |toplevel|
538
+ # @files << SHtmlFile.new(toplevel, @options, FILE_DIR)
539
+ # end
540
+ # @topclasses = []
541
+ # RDoc::TopLevel.all_classes_and_modules.each do |cls|
542
+ # @topclasses << build_class_list(cls, @files[0], CLASS_DIR)
543
+ # end
544
+ # end
545
+ #
546
+ # def build_class_list(from, html_file, class_dir)
547
+ # klass = SHtmlClass.new(from, html_file, class_dir, @options)
548
+ # @classes << klass
549
+ # from.each_classmodule do |mod|
550
+ # klass.children << build_class_list(mod, html_file, class_dir)
551
+ # end
552
+ # klass
553
+ # end
554
+ #
555
+ # def copy_resources
556
+ # FileUtils.cp_r RDoc::Page::RESOURCES_PATH, '.'
557
+ # end
558
+ #
559
+ # def search_string(string)
560
+ # string.downcase.gsub(/\s/,'')
561
+ # end
562
+ #
563
+ # def gen_tree_index
564
+ # tree = gen_tree_level @topclasses
565
+ # File.open('tree.yaml', 'w') { |f| f.write(tree.to_yaml) }
566
+ # File.open('tree.js', "w") do |f|
567
+ # f.write('var tree = '); f.write(tree.to_json)
568
+ # end
569
+ # end
570
+ #
571
+ # def gen_tree_level(classes)
572
+ # tree = []
573
+ # classes.select{|c| c.content? }.sort.each do |item|
574
+ # item = [item.title, item.namespace, item.path_if_available, item.params, item.snippet, gen_tree_level(item.children)]
575
+ # tree << item
576
+ # end
577
+ # tree
578
+ # end
579
+ #
580
+ # def gen_search_index
581
+ # entries = HtmlMethod.all_methods.sort
582
+ # entries += @classes.sort
583
+ # entries += @files.sort
584
+ # entries = entries.select { |f| f.document_self }
585
+ #
586
+ # result = {
587
+ # :searchIndex => [],
588
+ # :longSearchIndex => [],
589
+ # :info => []
590
+ # }
591
+ #
592
+ # entries.each_with_index do |item, index|
593
+ # result[:searchIndex].push( search_string(item.title) )
594
+ # result[:longSearchIndex].push( search_string(item.namespace) )
595
+ # result[:info].push([item.title, item.namespace, item.path, item.params, item.snippet])
596
+ # end
597
+ #
598
+ # File.open('index.js', "w") do |f|
599
+ # f.write('var data = '); f.write(result.to_json)
600
+ # end
601
+ # File.open('index.yaml', 'w') { |f| f.write(result.to_yaml) }
602
+ # end
603
+ #
604
+ # end
605
+ #
606
+ # class ContextUser
607
+ # def build_method_detail_list(section)
608
+ # outer = []
609
+ #
610
+ # methods = @methods.sort
611
+ # for singleton in [true, false]
612
+ # for vis in [ :public, :protected, :private ]
613
+ # res = []
614
+ # methods.each do |m|
615
+ # if m.section == section and
616
+ # m.document_self and
617
+ # m.visibility == vis and
618
+ # m.singleton == singleton
619
+ # row = {}
620
+ # if m.call_seq
621
+ # row["callseq"] = m.call_seq.gsub(/->/, '&rarr;')
622
+ # else
623
+ # row["name"] = CGI.escapeHTML(m.name)
624
+ # row["params"] = m.params
625
+ # end
626
+ # desc = m.description.strip
627
+ # row["m_desc"] = desc unless desc.empty?
628
+ # row["aref"] = m.aref
629
+ # row["visibility"] = m.visibility.to_s
630
+ #
631
+ # alias_names = []
632
+ # m.aliases.each do |other|
633
+ # if other.viewer # won't be if the alias is private
634
+ # alias_names << {
635
+ # 'name' => other.name,
636
+ # 'aref' => other.viewer.as_href(path)
637
+ # }
638
+ # end
639
+ # end
640
+ # unless alias_names.empty?
641
+ # row["aka"] = alias_names
642
+ # end
643
+ #
644
+ # if @options.inline_source
645
+ # code = m.source_code
646
+ # row["sourcecode"] = code if code
647
+ # row["github_url"] = m.github_url if @options.github_url
648
+ # else
649
+ # code = m.src_url
650
+ # if code
651
+ # row["codeurl"] = code
652
+ # row["imgurl"] = m.img_url
653
+ # row["github_url"] = m.github_url if @options.github_url
654
+ # end
655
+ # end
656
+ # res << row
657
+ # end
658
+ # end
659
+ # if res.size > 0
660
+ # outer << {
661
+ # "type" => vis.to_s.capitalize,
662
+ # "category" => singleton ? "Class" : "Instance",
663
+ # "methods" => res
664
+ # }
665
+ # end
666
+ # end
667
+ # end
668
+ # outer
669
+ # end
670
+ # end
671
+ # end