voloko-sdoc 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -190,7 +190,7 @@ class RDoc::Generator::SHtml
190
190
 
191
191
  list = @classes.map { |klass|
192
192
  klass.method_list
193
- }.flatten.sort{ |a, b| a.name <=> b.name }.select { |method|
193
+ }.flatten.sort{ |a, b| a.name == b.name ? a.parent.full_name <=> b.parent.full_name : a.name <=> b.name }.select { |method|
194
194
  method.document_self
195
195
  }
196
196
  unless @options.show_all
@@ -319,353 +319,4 @@ class RDoc::Generator::SHtml
319
319
  [ output.length, outfile ]
320
320
  end
321
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
322
+ end
@@ -205,8 +205,9 @@ Searchdoc.Searcher.prototype = new function() {
205
205
  }
206
206
 
207
207
  function matchPassRegexp(index, longIndex, queries, regexps) {
208
- for (var i=0, l = regexps.length; i < l; i++) {
209
- if (!index.match(regexps[i]) && (i == 0 || !longIndex.indexOf(regexps[i]))) return false;
208
+ if (!index.match(regexps[0])) return false;
209
+ for (var i=1, l = regexps.length; i < l; i++) {
210
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
210
211
  };
211
212
  return true;
212
213
  }
@@ -267,7 +268,7 @@ Searchdoc.Searcher.prototype = new function() {
267
268
  matchFunc = matchPass1;
268
269
  hltFunc = highlightQuery;
269
270
  } else if (state.pass == 1) {
270
- matchFunc = matchPass1;
271
+ matchFunc = matchPass2;
271
272
  hltFunc = highlightQuery;
272
273
  } else if (state.pass == 2) {
273
274
  matchFunc = matchPassRegexp;
data/lib/sdoc/merge.rb CHANGED
@@ -79,12 +79,17 @@ class SDoc::Merge
79
79
  items << {
80
80
  :info => info,
81
81
  :searchIndex => searchIndex[j],
82
- :longSearchIndex => longSearchIndex[j]
82
+ :longSearchIndex => name + ' ' + longSearchIndex[j]
83
83
  }
84
84
  end
85
85
  end
86
86
  items.sort! do |a, b|
87
- a[:info][5] == b[:info][5] ? a[:info][0] <=> b[:info][0] : a[:info][5] <=> b[:info][5]
87
+ a[:info][5] == b[:info][5] ? # type (class/method/file)
88
+ (a[:info][0] == b[:info][0] ? # or name
89
+ a[:info][1] <=> b[:info][1] : # or namespace
90
+ a[:info][0] <=> b[:info][0]
91
+ ) :
92
+ a[:info][5] <=> b[:info][5]
88
93
  end
89
94
 
90
95
  index = {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voloko-sdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Kolesnikov
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-26 00:00:00 -07:00
12
+ date: 2009-03-29 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency