├── .gitignore ├── lib ├── rdoc │ ├── discover.rb │ └── generator │ │ └── template │ │ ├── sdoc │ │ ├── resources │ │ │ ├── favicon.ico │ │ │ ├── i │ │ │ │ ├── arrows.png │ │ │ │ ├── tree_bg.png │ │ │ │ └── results_bg.png │ │ │ ├── apple-touch-icon.png │ │ │ ├── js │ │ │ │ ├── main.js │ │ │ │ ├── highlight.pack.js │ │ │ │ ├── searchdoc.js │ │ │ │ └── jquery-effect.js │ │ │ ├── css │ │ │ │ ├── reset.css │ │ │ │ ├── github.css │ │ │ │ ├── main.css │ │ │ │ └── panel.css │ │ │ └── panel │ │ │ │ └── index.html │ │ ├── se_index.rhtml │ │ ├── index.rhtml │ │ ├── _head.rhtml │ │ ├── file.rhtml │ │ ├── class.rhtml │ │ └── _context.rhtml │ │ ├── rails │ │ ├── resources │ │ │ ├── favicon.ico │ │ │ ├── i │ │ │ │ ├── arrows.png │ │ │ │ ├── tree_bg.png │ │ │ │ └── results_bg.png │ │ │ ├── apple-touch-icon.png │ │ │ ├── js │ │ │ │ ├── main.js │ │ │ │ ├── highlight.pack.js │ │ │ │ ├── searchdoc.js │ │ │ │ └── jquery-effect.js │ │ │ ├── css │ │ │ │ ├── reset.css │ │ │ │ ├── github.css │ │ │ │ ├── main.css │ │ │ │ └── panel.css │ │ │ └── panel │ │ │ │ └── index.html │ │ ├── se_index.rhtml │ │ ├── index.rhtml │ │ ├── _head.rhtml │ │ ├── file.rhtml │ │ ├── class.rhtml │ │ └── _context.rhtml │ │ └── merge │ │ └── index.rhtml ├── sdoc.rb └── sdoc │ ├── helpers.rb │ ├── github.rb │ ├── templatable.rb │ ├── merge.rb │ └── generator.rb ├── Rakefile ├── .rake_tasks~ ├── bin ├── sdoc-merge └── sdoc ├── sdoc.gemspec ├── README.rdoc └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | pkg 2 | doc 3 | /test.rb -------------------------------------------------------------------------------- /lib/rdoc/discover.rb: -------------------------------------------------------------------------------- 1 | begin 2 | gem 'rdoc', '~> 3' 3 | require File.join(File.dirname(__FILE__), '/../sdoc') 4 | rescue Gem::LoadError 5 | end 6 | -------------------------------------------------------------------------------- /lib/sdoc.rb: -------------------------------------------------------------------------------- 1 | $:.unshift File.dirname(__FILE__) 2 | require "rubygems" 3 | gem 'rdoc', '~> 3' 4 | 5 | module SDoc end 6 | 7 | require 'sdoc/generator' 8 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/resources/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/sdoc/master/lib/rdoc/generator/template/sdoc/resources/favicon.ico -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/resources/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/sdoc/master/lib/rdoc/generator/template/rails/resources/favicon.ico -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/resources/i/arrows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/sdoc/master/lib/rdoc/generator/template/rails/resources/i/arrows.png -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/resources/i/tree_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/sdoc/master/lib/rdoc/generator/template/rails/resources/i/tree_bg.png -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/resources/i/arrows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/sdoc/master/lib/rdoc/generator/template/sdoc/resources/i/arrows.png -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/resources/i/tree_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/sdoc/master/lib/rdoc/generator/template/sdoc/resources/i/tree_bg.png -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/resources/i/results_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/sdoc/master/lib/rdoc/generator/template/sdoc/resources/i/results_bg.png -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/resources/i/results_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/sdoc/master/lib/rdoc/generator/template/rails/resources/i/results_bg.png -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/resources/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/sdoc/master/lib/rdoc/generator/template/rails/resources/apple-touch-icon.png -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/resources/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bloopletech/sdoc/master/lib/rdoc/generator/template/sdoc/resources/apple-touch-icon.png -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/se_index.rhtml: -------------------------------------------------------------------------------- 1 | 2 | File index 3 | 4 | <% @files.each do |file| %> 5 | <%= file.relative_name %> 6 | <% end %> 7 | 8 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/se_index.rhtml: -------------------------------------------------------------------------------- 1 | 2 | File index 3 | 4 | <% @files.each do |file| %> 5 | <%= file.relative_name %> 6 | <% end %> 7 | 8 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | 3 | require 'bundler' 4 | Bundler::GemHelper.install_tasks 5 | 6 | gem 'rspec', '>= 2.5.0' 7 | require 'rspec/core/rake_task' 8 | 9 | desc "Run all specs" 10 | RSpec::Core::RakeTask.new(:spec) 11 | task :default => :spec 12 | task :test => :spec 13 | -------------------------------------------------------------------------------- /.rake_tasks~: -------------------------------------------------------------------------------- 1 | build 2 | check_dependencies 3 | check_dependencies:development 4 | check_dependencies:runtime 5 | gem_file_list 6 | gemspec 7 | gemspec:debug 8 | gemspec:generate 9 | gemspec:validate 10 | ghost 11 | git:release 12 | github:release 13 | install 14 | release 15 | test 16 | version 17 | version:bump:major 18 | version:bump:minor 19 | version:bump:patch 20 | version:write -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/resources/js/main.js: -------------------------------------------------------------------------------- 1 | function toggleSource(id) 2 | { 3 | var src = $('#' + id).toggle(); 4 | var isVisible = src.is(':visible'); 5 | $('#l_' + id).html(isVisible ? 'hide' : 'show'); 6 | } 7 | 8 | window.highlight = function(url) { 9 | var hash = url.match(/#([^#]+)$/) 10 | if(hash) { 11 | $('a[name=' + hash[1] + ']').parent().effect('highlight', {}, 'slow') 12 | } 13 | } 14 | 15 | $(function() { 16 | highlight('#' + location.hash); 17 | $('.description pre').each(function() { 18 | hljs.highlightBlock(this); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /bin/sdoc-merge: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby -KU 2 | require File.dirname(__FILE__) + '/../lib/sdoc' # add extensions 3 | require 'sdoc/merge' 4 | 5 | begin 6 | m = SDoc::Merge.new 7 | m.merge(ARGV) 8 | rescue SystemExit 9 | raise 10 | rescue Exception => e 11 | if $DEBUG_RDOC then 12 | $stderr.puts e.message 13 | $stderr.puts "#{e.backtrace.join "\n\t"}" 14 | $stderr.puts 15 | elsif Interrupt === e then 16 | $stderr.puts 17 | $stderr.puts 'Interrupted' 18 | else 19 | $stderr.puts "uh-oh! SDoc merge had a problem:" 20 | $stderr.puts e.message 21 | end 22 | exit 1 23 | end 24 | 25 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/merge/index.rhtml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | <%= @title %> 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/index.rhtml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | <%= @options.title %> 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/index.rhtml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | <%= @options.title %> 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /bin/sdoc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby -KU 2 | require 'sdoc' 3 | 4 | begin 5 | ARGV.push('--format=sdoc') if ARGV.grep(/\A(-f|--fmt|--format|-r|-R|--ri|--ri-site)\b/).empty? 6 | r = RDoc::RDoc.new 7 | r.document ARGV 8 | rescue SystemExit 9 | raise 10 | rescue Exception => e 11 | if $DEBUG_RDOC then 12 | $stderr.puts e.message 13 | $stderr.puts "#{e.backtrace.join "\n\t"}" 14 | $stderr.puts 15 | elsif Interrupt === e then 16 | $stderr.puts 17 | $stderr.puts 'Interrupted' 18 | else 19 | $stderr.puts "uh-oh! RDoc had a problem:" 20 | $stderr.puts e.message 21 | $stderr.puts 22 | $stderr.puts "run with --debug for full backtrace" 23 | end 24 | 25 | exit 1 26 | end 27 | 28 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/resources/js/main.js: -------------------------------------------------------------------------------- 1 | function toggleSource(id) 2 | { 3 | var src = $('#' + id).toggle(); 4 | var isVisible = src.is(':visible'); 5 | $('#l_' + id).html(isVisible ? 'hide' : 'show'); 6 | if (!src.data('syntax-higlighted')) { 7 | src.data('syntax-higlighted', 1); 8 | hljs.highlightBlock(src[0]); 9 | } 10 | } 11 | 12 | window.highlight = function(url) { 13 | var hash = url.match(/#([^#]+)$/) 14 | if(hash) { 15 | $('a[name=' + hash[1] + ']').parent().effect('highlight', {}, 'slow') 16 | } 17 | } 18 | 19 | $(function() { 20 | highlight('#' + location.hash); 21 | $('.description pre').each(function() { 22 | hljs.highlightBlock(this); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /lib/sdoc/helpers.rb: -------------------------------------------------------------------------------- 1 | module SDoc::Helpers 2 | def each_letter_group(methods, &block) 3 | group = {:name => '', :methods => []} 4 | methods.sort{ |a, b| a.name <=> b.name }.each do |method| 5 | gname = group_name method.name 6 | if gname != group[:name] 7 | yield group unless group[:methods].size == 0 8 | group = { 9 | :name => gname, 10 | :methods => [] 11 | } 12 | end 13 | group[:methods].push(method) 14 | end 15 | yield group unless group[:methods].size == 0 16 | end 17 | 18 | protected 19 | def group_name name 20 | if match = name.match(/^([a-z])/i) 21 | match[1].upcase 22 | else 23 | '#' 24 | end 25 | end 26 | end -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/_head.rhtml: -------------------------------------------------------------------------------- 1 | " type="text/css" media="screen" /> 2 | " type="text/css" media="screen" /> 3 | " type="text/css" media="screen" /> 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/_head.rhtml: -------------------------------------------------------------------------------- 1 | " type="text/css" media="screen" /> 2 | " type="text/css" media="screen" /> 3 | " type="text/css" media="screen" /> 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /sdoc.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | 3 | Gem::Specification.new do |s| 4 | s.name = "sdoc" 5 | s.version = "0.3.15" 6 | 7 | s.authors = ["Vladimir Kolesnikov"] 8 | s.description = %q{rdoc generator html with javascript search index.} 9 | s.summary = %q{rdoc html with javascript search index.} 10 | s.homepage = %q{http://github.com/voloko/sdoc} 11 | s.email = %q{voloko@gmail.com} 12 | 13 | s.required_rubygems_version = Gem::Requirement.new(">= 1.3.6") if 14 | s.respond_to? :required_rubygems_version= 15 | 16 | s.rdoc_options = ["--charset=UTF-8"] 17 | s.extra_rdoc_files = ["README.rdoc"] 18 | 19 | s.add_runtime_dependency('rdoc', "~> 3.10") 20 | if defined?(JRUBY_VERSION) 21 | s.platform = Gem::Platform.new(['universal', 'java', nil]) 22 | s.add_runtime_dependency("json_pure", ">= 1.1.3") 23 | else 24 | s.add_runtime_dependency("json", ">= 1.1.3") 25 | end 26 | 27 | s.files = `git ls-files`.split("\n") 28 | s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 29 | s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } 30 | end 31 | 32 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/resources/css/reset.css: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ */ 2 | /* v1.0 | 20080212 */ 3 | 4 | html, body, div, span, applet, object, iframe, 5 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 6 | a, abbr, acronym, address, big, cite, code, 7 | del, dfn, em, font, img, ins, kbd, q, s, samp, 8 | small, strike, strong, sub, sup, tt, var, 9 | b, u, i, center, 10 | dl, dt, dd, ol, ul, li, 11 | fieldset, form, label, legend, 12 | table, caption, tbody, tfoot, thead, tr, th, td { 13 | margin: 0; 14 | padding: 0; 15 | border: 0; 16 | outline: 0; 17 | font-size: 100%; 18 | vertical-align: baseline; 19 | background: transparent; 20 | } 21 | body { 22 | line-height: 1; 23 | } 24 | ol, ul { 25 | list-style: none; 26 | } 27 | blockquote, q { 28 | quotes: none; 29 | } 30 | blockquote:before, blockquote:after, 31 | q:before, q:after { 32 | content: ''; 33 | content: none; 34 | } 35 | 36 | /* remember to highlight inserts somehow! */ 37 | ins { 38 | text-decoration: none; 39 | } 40 | del { 41 | text-decoration: line-through; 42 | } 43 | 44 | /* tables still need 'cellspacing="0"' in the markup */ 45 | table { 46 | border-collapse: collapse; 47 | border-spacing: 0; 48 | } -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/resources/css/reset.css: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ */ 2 | /* v1.0 | 20080212 */ 3 | 4 | html, body, div, span, applet, object, iframe, 5 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 6 | a, abbr, acronym, address, big, cite, code, 7 | del, dfn, em, font, img, ins, kbd, q, s, samp, 8 | small, strike, strong, sub, sup, tt, var, 9 | b, u, i, center, 10 | dl, dt, dd, ol, ul, li, 11 | fieldset, form, label, legend, 12 | table, caption, tbody, tfoot, thead, tr, th, td { 13 | margin: 0; 14 | padding: 0; 15 | border: 0; 16 | outline: 0; 17 | font-size: 100%; 18 | vertical-align: baseline; 19 | background: transparent; 20 | } 21 | body { 22 | line-height: 1; 23 | } 24 | ol, ul { 25 | list-style: none; 26 | } 27 | blockquote, q { 28 | quotes: none; 29 | } 30 | blockquote:before, blockquote:after, 31 | q:before, q:after { 32 | content: ''; 33 | content: none; 34 | } 35 | 36 | /* remember to highlight inserts somehow! */ 37 | ins { 38 | text-decoration: none; 39 | } 40 | del { 41 | text-decoration: line-through; 42 | } 43 | 44 | /* tables still need 'cellspacing="0"' in the markup */ 45 | table { 46 | border-collapse: collapse; 47 | border-spacing: 0; 48 | } -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/file.rhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | <%= h file.name %> 7 | 8 | <%= include_template '_head.rhtml', {:rel_prefix => rel_prefix} %> 9 | 10 | 11 | 12 | 24 | 25 |
26 | <%= include_template '_context.rhtml', {:context => file, :rel_prefix => rel_prefix} %> 27 |
28 | 29 | -------------------------------------------------------------------------------- /README.rdoc: -------------------------------------------------------------------------------- 1 | = SDoc 2 | == What's in? 3 | - shtml - RDoc's generator to build searchable documentation 4 | - sdoc-merge - comand line tool to build merge multiple sdoc documentations 5 | packages into a single one 6 | - sdoc - command line tool to run rdoc with generator=shtml 7 | 8 | == Getting Started 9 | sudo gem install sdoc 10 | sdoc -N projectdir 11 | 12 | == Command line sdoc 13 | sdoc is simply a wrapper to rdoc command line tool. see sdoc --help 14 | for more details. --fmt is set to shtml by default. 15 | Default template -T is shtml. You can also use 'direct' template. 16 | Example: 17 | sdoc -o doc/rails -T direct rails 18 | 19 | == Rake 20 | # Rakefile 21 | require 'sdoc' # and use your RDoc task the same way you used it before 22 | 23 | Rake::RDocTask.new do |rdoc| 24 | rdoc.rdoc_dir = 'doc/rdoc' 25 | rdoc.options << '--fmt' << 'shtml' # explictly set shtml generator 26 | rdoc.template = 'direct' # lighter template used on railsapi.com 27 | ... 28 | end 29 | 30 | == sdoc-merge 31 | Usage: sdoc-merge [options] directories 32 | -n, --names [NAMES] Names of merged repositories. Comma separated 33 | -o, --op [DIRECTORY] Set the output directory 34 | -t, --title [TITLE] Set the title of merged file 35 | 36 | Example: 37 | sdoc-merge --title "Ruby v1.9, Rails v2.3.2.1" --op merged --names "Ruby,Rails" ruby-v1.9 rails-v2.3.2.1 -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/file.rhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | <%= h file.name %> 7 | 8 | <%= include_template '_head.rhtml', {:rel_prefix => rel_prefix} %> 9 | 10 | 11 | 12 | 32 | 33 |
34 | <%= include_template '_context.rhtml', {:context => file, :rel_prefix => rel_prefix} %> 35 |
36 | 37 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/class.rhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | <%= h klass.full_name %> 7 | 8 | <%= include_template '_head.rhtml', {:rel_prefix => rel_prefix} %> 9 | 10 | 11 | 12 | 35 |
36 | <%= include_template '_context.rhtml', {:context => klass, :rel_prefix => rel_prefix} %> 37 |
38 | 39 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/class.rhtml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | <%= h klass.full_name %> 7 | 8 | <%= include_template '_head.rhtml', {:rel_prefix => rel_prefix} %> 9 | 10 | 11 | 12 | 35 |
36 | <%= include_template '_context.rhtml', {:context => klass, :rel_prefix => rel_prefix} %> 37 |
38 | 39 | -------------------------------------------------------------------------------- /lib/sdoc/github.rb: -------------------------------------------------------------------------------- 1 | module SDoc::GitHub 2 | def github_url(path) 3 | unless @github_url_cache.has_key? path 4 | @github_url_cache[path] = false 5 | file = RDoc::TopLevel.find_file_named(path) 6 | if file 7 | base_url = repository_url(path) 8 | if base_url 9 | sha1 = commit_sha1(path) 10 | if sha1 11 | relative_url = path_relative_to_repository(path) 12 | @github_url_cache[path] = "#{base_url}#{sha1}#{relative_url}" 13 | end 14 | end 15 | end 16 | end 17 | @github_url_cache[path] 18 | end 19 | 20 | protected 21 | 22 | def have_git? 23 | @have_git = system('git --version > /dev/null 2>&1') if @have_git.nil? 24 | @have_git 25 | end 26 | 27 | def commit_sha1(path) 28 | return false unless have_git? 29 | name = File.basename(path) 30 | s = Dir.chdir(File.join(basedir, File.dirname(path))) do 31 | `git log -1 --pretty=format:"commit %H" #{name}` 32 | end 33 | m = s.match(/commit\s+(\S+)/) 34 | m ? m[1] : false 35 | end 36 | 37 | def repository_url(path) 38 | return false unless have_git? 39 | s = Dir.chdir(File.join(basedir, File.dirname(path))) do 40 | `git config --get remote.origin.url` 41 | end 42 | m = s.match(%r{github.com[/:](.*)\.git$}) 43 | m ? "https://github.com/#{m[1]}/blob/" : false 44 | end 45 | 46 | def path_relative_to_repository(path) 47 | absolute_path = File.join(basedir, path) 48 | root = path_to_git_dir(File.dirname(absolute_path)) 49 | absolute_path[root.size..absolute_path.size] 50 | end 51 | 52 | def path_to_git_dir(path) 53 | while !path.empty? && path != '.' 54 | if (File.exists? File.join(path, '.git')) 55 | return path 56 | end 57 | path = File.dirname(path) 58 | end 59 | '' 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /lib/sdoc/templatable.rb: -------------------------------------------------------------------------------- 1 | require 'erb' 2 | require "sdoc" 3 | 4 | module SDoc::Templatable 5 | ### Load and render the erb template in the given +templatefile+ within the 6 | ### specified +context+ (a Binding object) and return output 7 | ### Both +templatefile+ and +outfile+ should be Pathname-like objects. 8 | def eval_template(templatefile, context) 9 | template_src = templatefile.read 10 | template = ERB.new( template_src, nil, '<>' ) 11 | template.filename = templatefile.to_s 12 | 13 | begin 14 | template.result( context ) 15 | rescue NoMethodError => err 16 | raise RDoc::Error, "Error while evaluating %s: %s (at %p)" % [ 17 | templatefile.to_s, 18 | err.message, 19 | eval( "_erbout[-50,50]", context ) 20 | ], err.backtrace 21 | end 22 | end 23 | 24 | ### Load and render the erb template with the given +template_name+ within 25 | ### current context. Adds all +local_assigns+ to context 26 | def include_template(template_name, local_assigns = {}) 27 | source = local_assigns.keys.map { |key| "#{key} = local_assigns[:#{key}];" }.join 28 | templatefile = @template_dir + template_name 29 | eval("#{source};eval_template(templatefile, binding)") 30 | end 31 | 32 | ### Load and render the erb template in the given +templatefile+ within the 33 | ### specified +context+ (a Binding object) and write it out to +outfile+. 34 | ### Both +templatefile+ and +outfile+ should be Pathname-like objects. 35 | def render_template( templatefile, context, outfile ) 36 | output = eval_template(templatefile, context) 37 | 38 | # TODO delete this dirty hack when documentation for example for GeneratorMethods will not be cutted off by 11 | 12 | 13 | 14 | 15 | 50 | 51 | 52 |
53 |
54 |
55 | 56 | 57 | 60 |
58 | 59 |
61 |
62 |
63 | 65 |
66 |
67 | 69 |
70 |
71 | index 72 | 73 | 74 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/resources/panel/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | search index 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 50 | 51 | 52 |
53 |
54 |
55 | 56 | 57 | 60 |
58 | 59 |
61 |
62 |
63 | 65 |
66 |
67 | 69 |
70 |
71 | index 72 | 73 | 74 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Vladimir Kolesnikov 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | 23 | 24 | Darkfish RDoc HTML Generator 25 | 26 | Copyright (c) 2007, 2008, Michael Granger. All rights reserved. 27 | 28 | Redistribution and use in source and binary forms, with or without 29 | modification, are permitted provided that the following conditions are met: 30 | 31 | * Redistributions of source code must retain the above copyright notice, 32 | this list of conditions and the following disclaimer. 33 | 34 | * Redistributions in binary form must reproduce the above copyright notice, 35 | this list of conditions and the following disclaimer in the documentation 36 | and/or other materials provided with the distribution. 37 | 38 | * Neither the name of the author/s, nor the names of the project's 39 | contributors may be used to endorse or promote products derived from this 40 | software without specific prior written permission. 41 | 42 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 43 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 44 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 45 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 46 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 47 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 48 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 49 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 50 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 51 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 52 | 53 | 54 | RDoc is copyrighted free software. 55 | 56 | You can redistribute it and/or modify it under either the terms of the GPL 57 | version 2 (see the file GPL), or the conditions below: 58 | 59 | 1. You may make and give away verbatim copies of the source form of the 60 | software without restriction, provided that you duplicate all of the 61 | original copyright notices and associated disclaimers. 62 | 63 | 2. You may modify your copy of the software in any way, provided that 64 | you do at least ONE of the following: 65 | 66 | a) place your modifications in the Public Domain or otherwise 67 | make them Freely Available, such as by posting said 68 | modifications to Usenet or an equivalent medium, or by allowing 69 | the author to include your modifications in the software. 70 | 71 | b) use the modified software only within your corporation or 72 | organization. 73 | 74 | c) give non-standard binaries non-standard names, with 75 | instructions on where to get the original software distribution. 76 | 77 | d) make other distribution arrangements with the author. 78 | 79 | 3. You may distribute the software in object code or binary form, 80 | provided that you do at least ONE of the following: 81 | 82 | a) distribute the binaries and library files of the software, 83 | together with instructions (in the manual page or equivalent) 84 | on where to get the original distribution. 85 | 86 | b) accompany the distribution with the machine-readable source of 87 | the software. 88 | 89 | c) give non-standard binaries non-standard names, with 90 | instructions on where to get the original software distribution. 91 | 92 | d) make other distribution arrangements with the author. 93 | 94 | 4. You may modify and include the part of the software into any other 95 | software (possibly commercial). But some files in the distribution 96 | are not written by the author, so that they are not under these terms. 97 | 98 | For the list of those files and their copying conditions, see the 99 | file LEGAL. 100 | 101 | 5. The scripts and library files supplied as input to or produced as 102 | output from the software do not automatically fall under the 103 | copyright of the software, but belong to whomever generated them, 104 | and may be sold commercially, and may be aggregated with this 105 | software. 106 | 107 | 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR 108 | IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 109 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 110 | PURPOSE. -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/resources/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica Neue", Arial, sans-serif; 3 | background: #FFF; 4 | color: #000; 5 | margin: 0px; 6 | font-size: 0.82em; 7 | line-height: 1.25em; 8 | } 9 | 10 | a { 11 | color: #00F; 12 | text-decoration: none; 13 | } 14 | 15 | a:hover { 16 | color: #333; 17 | background: #FE8; 18 | } 19 | 20 | p { 21 | margin-bottom: 1em; 22 | } 23 | 24 | h1 { 25 | font-size: 2.1em; 26 | font-weight: normal; 27 | line-height: 1.2em; 28 | margin: 1.4em 0 0.7em 0; 29 | } 30 | 31 | h2 { 32 | font-size: 1.6em; 33 | margin: 1.8em 0 0.8em 0; 34 | font-weight: normal; 35 | line-height: 1.2em; 36 | } 37 | 38 | h3 { 39 | font-size: 1.4em; 40 | color:#555; 41 | margin: 1.4em 0 0.7em 0; 42 | font-weight: normal; 43 | } 44 | 45 | h4 { 46 | margin: 1.4em 0 0.5em 0; 47 | font-size: 1em; 48 | } 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 | 65 | .clear 66 | { 67 | clear: both; 68 | width: 0; height: 0; 69 | } 70 | 71 | dt 72 | { 73 | margin-bottom: 0.3em; 74 | font-weight: bold; 75 | } 76 | 77 | dd 78 | { 79 | margin-left: 2em; 80 | margin-bottom: 1em; 81 | } 82 | 83 | dd p 84 | { 85 | margin-top: 0.6em; 86 | } 87 | 88 | li 89 | { 90 | margin: 0 0 0.5em 2em; 91 | } 92 | 93 | ul li 94 | { 95 | list-style: disc; 96 | } 97 | 98 | ol li 99 | { 100 | list-style: decimal; 101 | } 102 | 103 | .banner 104 | { 105 | background: #EDF3FE; 106 | border-bottom: 1px solid #ccc; 107 | padding: 1em 2em 0.5em 2em; 108 | } 109 | .banner h1 110 | { 111 | font-size: 1.2em; 112 | margin: 0; 113 | } 114 | 115 | .banner h1 .type 116 | { 117 | font-size: 0.833em; 118 | display:block; 119 | } 120 | 121 | .banner h1 .type, 122 | .banner h1 .parent 123 | { 124 | color: #666; 125 | } 126 | 127 | .banner ul 128 | { 129 | margin-top: 0.3em; 130 | margin-bottom: 0; 131 | font-size: 0.85em; 132 | } 133 | 134 | .banner li 135 | { 136 | list-style: none; 137 | margin-left: 0; 138 | margin-bottom: 0; 139 | } 140 | 141 | pre 142 | { 143 | margin-bottom: 1em; 144 | } 145 | 146 | .methods dt 147 | { 148 | width: 1em; 149 | font-size: 1.5em; 150 | color:#AAA; 151 | position: absolute; 152 | font-weight: normal; 153 | margin: 0; 154 | } 155 | 156 | .methods dd 157 | { 158 | margin-left: 2.5em; 159 | min-height: 1.8em; 160 | -height: 1.8em; 161 | padding-bottom: 0.8em; 162 | } 163 | 164 | 165 | .methods ul li 166 | { 167 | margin-right: 0.7em; 168 | margin-left: 0; 169 | list-style: none; 170 | display: inline; 171 | } 172 | 173 | #content { 174 | margin: 2em; 175 | margin-left: 3.5em; 176 | margin-right: 3.5em; 177 | } 178 | 179 | 180 | .sectiontitle { 181 | margin-top: 2em; 182 | margin-bottom: 1.3em; 183 | margin-left: -1.2em; 184 | font-size: 1.2em; 185 | padding: 0 0 0.25em 0; 186 | font-weight: bold; 187 | border-bottom: 1px solid #000; 188 | } 189 | 190 | .contenttitle { 191 | margin-top: 4em; 192 | margin-bottom: 1.3em; 193 | margin-left: -0.9em; 194 | font-size: 1.6em; 195 | padding: 0 0 0.25em 0; 196 | font-weight: bold; 197 | } 198 | 199 | .attr-rw { 200 | padding-right: 1em; 201 | text-align: center; 202 | color: #055; 203 | } 204 | 205 | .attr-name { 206 | font-weight: bold; 207 | padding-right: 1em; 208 | } 209 | 210 | .attr-desc { 211 | } 212 | 213 | tt { 214 | font-size: 1.15em; 215 | } 216 | 217 | .attr-value { 218 | font-family: monospace; 219 | padding-left: 1em; 220 | font-size: 1.15em; 221 | } 222 | 223 | .dyn-source { 224 | display: none; 225 | background: #fffde8; 226 | color: #000; 227 | border: #ffe0bb dotted 1px; 228 | margin: 0.5em 2em 0.5em 0; 229 | padding: 0.5em; 230 | } 231 | 232 | .dyn-source .cmt { 233 | color: #00F; 234 | font-style: italic; 235 | } 236 | 237 | .dyn-source .kw { 238 | color: #070; 239 | font-weight: bold; 240 | } 241 | 242 | .description pre { 243 | padding: 0.5em; 244 | border: #ffe0bb dotted 1px; 245 | background: #fffde8; 246 | } 247 | 248 | .method { 249 | margin-bottom: 2em; 250 | } 251 | .method .description, 252 | .method .sourcecode 253 | { 254 | margin-left: 1.2em; 255 | } 256 | .method h4 257 | { 258 | border-bottom: 1px dotted #999; 259 | padding: 0 0 0.2em 0; 260 | margin-bottom: 0.8em; 261 | font-size: 1.1em; 262 | color:#333; 263 | } 264 | .method .method-title { 265 | border-bottom: 1px dotted #666; 266 | padding: 0 0 0.15em 0; 267 | margin: 0 0 0.5em 0; 268 | font-size: 1.2em; 269 | line-height: 1.25em; 270 | } 271 | 272 | .method .sourcecode p.source-link { 273 | text-indent: 0em; 274 | margin-top: 0.5em; 275 | } 276 | 277 | .method .aka { 278 | margin-top: 0.3em; 279 | margin-left: 1em; 280 | font-style: italic; 281 | text-indent: 2em; 282 | } 283 | 284 | .method .source-link 285 | { 286 | font-size: 0.85em; 287 | } 288 | 289 | .ruby-constant { 290 | color: teal; 291 | } 292 | .ruby-keyword { 293 | color: #000; 294 | font-weight: bold 295 | } 296 | .ruby-title { 297 | color: #900; 298 | font-weight: bold; 299 | } 300 | .ruby-ivar { 301 | color: teal; 302 | } 303 | .ruby-operator { 304 | color: #000; 305 | font-weight: bold 306 | } 307 | .ruby-identifier { 308 | color: #000; 309 | } 310 | .ruby-string, 311 | .ruby-node { 312 | color: #D14; 313 | } 314 | .ruby-comment { 315 | color: #998; 316 | font-style: italic; 317 | } 318 | .ruby-regexp { 319 | color: #009926; 320 | } 321 | .ruby-value { 322 | color: #990073; 323 | } 324 | .ruby-number { 325 | color: #40A070; 326 | } 327 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/resources/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica Neue", Arial, sans-serif; 3 | background: #FFF; 4 | color: #000; 5 | margin: 0px; 6 | font-size: 0.82em; 7 | line-height: 1.25em; 8 | } 9 | 10 | a:link, a:active, a:visited, a:hover { 11 | color: #980905; 12 | text-decoration: none; 13 | } 14 | 15 | a:hover, .banner a:hover { 16 | color: #333; 17 | background: #FE8; 18 | } 19 | 20 | h1 a, h2 a, .banner a { 21 | color: #fff; 22 | } 23 | 24 | h1 a:hover, h2 a:hover { 25 | color: #fff; 26 | } 27 | 28 | p { 29 | margin-bottom: 1em; 30 | } 31 | 32 | h1 { 33 | font-size: 2.1em; 34 | font-weight: normal; 35 | line-height: 1.2em; 36 | margin: 1.4em 0 0.7em 0; 37 | } 38 | 39 | h2 { 40 | font-size: 1.6em; 41 | margin: 1.8em 0 0.8em 0; 42 | font-weight: normal; 43 | line-height: 1.2em; 44 | } 45 | 46 | h3 { 47 | font-size: 1.4em; 48 | color:#555; 49 | margin: 1.4em 0 0.7em 0; 50 | font-weight: normal; 51 | } 52 | 53 | h4 { 54 | margin: 1.4em 0 0.5em 0; 55 | font-size: 1em; 56 | } 57 | 58 | table 59 | { 60 | margin-bottom: 1em; 61 | } 62 | 63 | td, th 64 | { 65 | padding: 0 0.7em 0.3em 0; 66 | } 67 | 68 | th 69 | { 70 | font-weight: bold; 71 | } 72 | 73 | .clear 74 | { 75 | clear: both; 76 | width: 0; height: 0; 77 | } 78 | 79 | dt 80 | { 81 | margin-bottom: 0.3em; 82 | font-weight: bold; 83 | } 84 | 85 | dd 86 | { 87 | margin-left: 2em; 88 | margin-bottom: 1em; 89 | } 90 | 91 | dd p 92 | { 93 | margin-top: 0.6em; 94 | } 95 | 96 | li 97 | { 98 | margin: 0 0 0.5em 2em; 99 | } 100 | 101 | ul li 102 | { 103 | list-style: disc; 104 | } 105 | 106 | ol li 107 | { 108 | list-style: decimal; 109 | } 110 | 111 | .banner 112 | { 113 | background: #C52F24; 114 | color: #FFF; 115 | border: 1px solid #980905; 116 | padding: 1em; 117 | } 118 | .banner h1 119 | { 120 | font-size: 1.2em; 121 | margin: 0; 122 | } 123 | 124 | .banner h1 .type 125 | { 126 | font-size: 0.833em; 127 | display:block; 128 | } 129 | 130 | .banner h1 .type, 131 | .banner h1 .parent 132 | { 133 | color: #CCC; 134 | } 135 | 136 | .banner ul 137 | { 138 | margin-top: 0.3em; 139 | margin-bottom: 0; 140 | font-size: 0.85em; 141 | } 142 | 143 | .banner li 144 | { 145 | list-style: none; 146 | margin-left: 0; 147 | margin-bottom: 0; 148 | } 149 | 150 | .banner .github_url { 151 | color: #CCC; 152 | } 153 | 154 | pre 155 | { 156 | margin-bottom: 1em; 157 | } 158 | 159 | .methods dt 160 | { 161 | width: 1em; 162 | font-size: 1.5em; 163 | color:#AAA; 164 | position: absolute; 165 | font-weight: normal; 166 | margin: 0; 167 | } 168 | 169 | .methods dd 170 | { 171 | margin-left: 2.5em; 172 | min-height: 1.8em; 173 | -height: 1.8em; 174 | padding-bottom: 0.8em; 175 | } 176 | 177 | 178 | .methods ul li 179 | { 180 | margin-right: 0.7em; 181 | margin-left: 0; 182 | list-style: none; 183 | display: inline; 184 | } 185 | 186 | #content { 187 | margin: 2em; 188 | margin-left: 3.5em; 189 | margin-right: 3.5em; 190 | } 191 | 192 | 193 | .sectiontitle { 194 | margin-top: 2em; 195 | margin-bottom: 1.3em; 196 | margin-left: -1.2em; 197 | font-size: 1.2em; 198 | padding: 0 0 0.25em 0; 199 | font-weight: bold; 200 | border-bottom: 1px solid #000; 201 | } 202 | 203 | .contenttitle { 204 | margin-top: 4em; 205 | margin-bottom: 1.3em; 206 | margin-left: -0.9em; 207 | font-size: 1.6em; 208 | padding: 0 0 0.25em 0; 209 | font-weight: bold; 210 | } 211 | 212 | .attr-rw { 213 | padding-right: 1em; 214 | text-align: center; 215 | color: #055; 216 | } 217 | 218 | .attr-name { 219 | font-weight: bold; 220 | padding-right: 1em; 221 | } 222 | 223 | .attr-desc { 224 | } 225 | 226 | tt { 227 | font-size: 1.15em; 228 | } 229 | 230 | .attr-value { 231 | font-family: monospace; 232 | padding-left: 1em; 233 | font-size: 1.15em; 234 | } 235 | 236 | .dyn-source { 237 | display: none; 238 | background: #fffde8; 239 | color: #000; 240 | border: #ffe0bb dotted 1px; 241 | margin: 0.5em 2em 0.5em 0; 242 | padding: 0.5em; 243 | } 244 | 245 | .dyn-source .cmt { 246 | color: #00F; 247 | font-style: italic; 248 | } 249 | 250 | .dyn-source .kw { 251 | color: #070; 252 | font-weight: bold; 253 | } 254 | 255 | .description pre { 256 | padding: 0.5em; 257 | border: #ffe0bb dotted 1px; 258 | background: #fffde8; 259 | } 260 | 261 | .method { 262 | margin-bottom: 2em; 263 | } 264 | .method .description, 265 | .method .sourcecode 266 | { 267 | margin-left: 1.2em; 268 | } 269 | .method h4 270 | { 271 | border-bottom: 1px dotted #999; 272 | padding: 0 0 0.2em 0; 273 | margin-bottom: 0.8em; 274 | font-size: 1.1em; 275 | color:#333; 276 | } 277 | .method .method-title { 278 | border-bottom: 1px dotted #666; 279 | padding: 0 0 0.15em 0; 280 | margin: 0 0 0.5em 0; 281 | font-size: 1.2em; 282 | line-height: 1.25em; 283 | } 284 | 285 | .method .sourcecode p.source-link { 286 | text-indent: 0em; 287 | margin-top: 0.5em; 288 | } 289 | 290 | .method .aka { 291 | margin-top: 0.3em; 292 | margin-left: 1em; 293 | font-style: italic; 294 | text-indent: 2em; 295 | } 296 | 297 | .method .source-link 298 | { 299 | font-size: 0.85em; 300 | } 301 | 302 | .ruby-constant { 303 | color: teal; 304 | } 305 | .ruby-keyword { 306 | color: #000; 307 | font-weight: bold 308 | } 309 | .ruby-title { 310 | color: #900; 311 | font-weight: bold; 312 | } 313 | .ruby-ivar { 314 | color: teal; 315 | } 316 | .ruby-operator { 317 | color: #000; 318 | font-weight: bold 319 | } 320 | .ruby-identifier { 321 | color: #000; 322 | } 323 | .ruby-string, 324 | .ruby-node { 325 | color: #D14; 326 | } 327 | .ruby-comment { 328 | color: #998; 329 | font-style: italic; 330 | } 331 | .ruby-regexp { 332 | color: #009926; 333 | } 334 | .ruby-value { 335 | color: #990073; 336 | } 337 | .ruby-number { 338 | color: #40A070; 339 | } 340 | -------------------------------------------------------------------------------- /lib/sdoc/merge.rb: -------------------------------------------------------------------------------- 1 | require 'optparse' 2 | require 'pathname' 3 | require 'fileutils' 4 | 5 | if Gem.available? "json" 6 | gem "json", ">= 1.1.3" 7 | else 8 | gem "json_pure", ">= 1.1.3" 9 | end 10 | require 'json' 11 | 12 | require 'sdoc/templatable' 13 | 14 | class SDoc::Merge 15 | include SDoc::Templatable 16 | 17 | FLAG_FILE = "created.rid" 18 | 19 | def initialize() 20 | @names = [] 21 | @urls = [] 22 | @op_dir = 'doc' 23 | @title = '' 24 | @directories = [] 25 | end 26 | 27 | def merge(options) 28 | parse_options options 29 | 30 | @outputdir = Pathname.new( @op_dir ) 31 | 32 | check_directories 33 | setup_output_dir 34 | setup_names 35 | copy_files 36 | copy_docs if @urls.empty? 37 | merge_search_index 38 | merge_tree 39 | generate_index_file 40 | end 41 | 42 | def parse_options(options) 43 | opts = OptionParser.new do |opt| 44 | opt.banner = "Usage: sdoc-merge [options] directories" 45 | 46 | opt.on("-n", "--names [NAMES]", "Names of merged repositories. Comma separated") do |v| 47 | @names = v.split(',').map{|name| name.strip } 48 | end 49 | 50 | opt.on("-o", "--op [DIRECTORY]", "Set the output directory") do |v| 51 | @op_dir = v 52 | end 53 | 54 | opt.on("-t", "--title [TITLE]", "Set the title of merged file") do |v| 55 | @title = v 56 | end 57 | 58 | opt.on("-u", "--urls [URLS]", "Paths to merged docs. If you", 59 | "set this files and classes won't be actualy", 60 | "copied to merged build") do |v| 61 | @urls = v.split(' ').map{|name| name.strip } 62 | end 63 | end 64 | opts.parse! options 65 | @template_dir = Pathname.new(RDoc::Options.new.template_dir_for 'merge') 66 | @directories = options.dup 67 | end 68 | 69 | def merge_tree 70 | tree = [] 71 | @directories.each_with_index do |dir, i| 72 | name = @names[i] 73 | url = @urls.empty? ? name : @urls[i] 74 | filename = File.join dir, RDoc::Generator::SDoc::TREE_FILE 75 | data = open(filename).read.sub(/var tree =\s*/, '') 76 | subtree = JSON.parse(data, :max_nesting => 0) 77 | item = [ 78 | name, 79 | url + '/' + extract_index_path(dir), 80 | '', 81 | append_path(subtree, url) 82 | ] 83 | tree << item 84 | end 85 | 86 | dst = File.join @op_dir, RDoc::Generator::SDoc::TREE_FILE 87 | FileUtils.mkdir_p File.dirname(dst) 88 | File.open(dst, "w", 0644) do |f| 89 | f.write('var tree = '); f.write(tree.to_json(:max_nesting => 0)) 90 | end 91 | end 92 | 93 | def append_path subtree, path 94 | subtree.map do |item| 95 | item[1] = path + '/' + item[1] unless item[1].empty? 96 | item[3] = append_path item[3], path 97 | item 98 | end 99 | end 100 | 101 | def merge_search_index 102 | items = [] 103 | @indexes = {} 104 | @directories.each_with_index do |dir, i| 105 | name = @names[i] 106 | url = @urls.empty? ? name : @urls[i] 107 | filename = File.join dir, RDoc::Generator::SDoc::SEARCH_INDEX_FILE 108 | data = open(filename).read.sub(/var search_data =\s*/, '') 109 | subindex = JSON.parse(data, :max_nesting => 0) 110 | @indexes[name] = subindex 111 | 112 | searchIndex = subindex["index"]["searchIndex"] 113 | longSearchIndex = subindex["index"]["longSearchIndex"] 114 | subindex["index"]["info"].each_with_index do |info, j| 115 | info[2] = url + '/' + info[2] 116 | info[6] = i 117 | items << { 118 | :info => info, 119 | :searchIndex => searchIndex[j], 120 | :longSearchIndex => name + ' ' + longSearchIndex[j] 121 | } 122 | end 123 | end 124 | items.sort! do |a, b| 125 | # type (class/method/file) or name or doc part or namespace 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]] 127 | end 128 | 129 | index = { 130 | :searchIndex => items.map{|item| item[:searchIndex]}, 131 | :longSearchIndex => items.map{|item| item[:longSearchIndex]}, 132 | :info => items.map{|item| item[:info]} 133 | } 134 | search_data = { 135 | :index => index, 136 | :badges => @names 137 | } 138 | 139 | dst = File.join @op_dir, RDoc::Generator::SDoc::SEARCH_INDEX_FILE 140 | FileUtils.mkdir_p File.dirname(dst) 141 | File.open(dst, "w", 0644) do |f| 142 | f.write('var search_data = '); f.write(search_data.to_json(:max_nesting => 0)) 143 | end 144 | end 145 | 146 | def extract_index_path dir 147 | filename = File.join dir, 'index.html' 148 | content = File.open(filename) { |f| f.read } 149 | match = content.match(/ 0 168 | @directories.each do |dir| 169 | name = File.basename dir 170 | name = File.basename File.dirname(dir) if name == 'doc' 171 | @names << name 172 | end 173 | end 174 | end 175 | 176 | def copy_docs 177 | @directories.each_with_index do |dir, i| 178 | name = @names[i] 179 | index_dir = File.dirname(RDoc::Generator::SDoc::TREE_FILE) 180 | FileUtils.mkdir_p(File.join(@op_dir, name)) 181 | 182 | Dir.new(dir).each do |item| 183 | if File.directory?(File.join(dir, item)) && item != '.' && item != '..' && item != index_dir 184 | FileUtils.cp_r File.join(dir, item), File.join(@op_dir, name, item), :preserve => true 185 | end 186 | end 187 | end 188 | end 189 | 190 | def copy_files 191 | dir = @directories.first 192 | Dir.new(dir).each do |item| 193 | if item != '.' && item != '..' && item != RDoc::Generator::SDoc::FILE_DIR && item != RDoc::Generator::SDoc::CLASS_DIR 194 | FileUtils.cp_r File.join(dir, item), @op_dir, :preserve => true 195 | end 196 | end 197 | end 198 | 199 | def setup_output_dir 200 | if File.exists? @op_dir 201 | error "#{@op_dir} allready exists" 202 | end 203 | FileUtils.mkdir_p @op_dir 204 | end 205 | 206 | def check_directories 207 | @directories.each do |dir| 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)) 211 | error "#{dir} does not seem to be an sdoc directory" 212 | end 213 | end 214 | end 215 | 216 | ## 217 | # Report an error message and exit 218 | 219 | def error(msg) 220 | raise RDoc::Error, msg 221 | end 222 | 223 | end 224 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/_context.rhtml: -------------------------------------------------------------------------------- 1 |
2 | <% unless (description = context.description).empty? %> 3 |
4 | <%= description %> 5 |
6 | <% end %> 7 | 8 | 9 | <% unless context.requires.empty? %> 10 | 11 |
Required Files
12 | 17 | <% end %> 18 | 19 | 20 | <% sections = context.sections.select { |s| s.title }.sort_by{ |s| s.title.to_s } %> 21 | <% unless sections.empty? then %> 22 | 23 |
Sections
24 | 29 | <% end %> 30 | 31 | 32 | <% unless context.classes_and_modules.empty? %> 33 | 34 |
Namespace
35 | 43 | <% end %> 44 | 45 | 46 | <% unless context.method_list.empty? %> 47 | 48 |
Methods
49 |
50 | <% each_letter_group(context.method_list) do |group| %> 51 |
<%= group[:name] %>
52 |
53 |
    54 | <% group[:methods].each_with_index do |method, i| %> 55 | <% 56 | comma = group[:methods].size == i+1 ? '' : ',' 57 | %> 58 |
  • 59 | <%= h method.name %><%= comma %> 60 |
  • 61 | <% end %> 62 |
63 |
64 | <% end %> 65 |
66 | <% end %> 67 | 68 | <% unless context.includes.empty? %> 69 | 70 |
Included Modules
71 | 84 | <% end %> 85 | 86 | 87 | 88 | <% context.each_section do |section, constants, attributes| %> 89 | 90 | <% if section.title then %> 91 |
92 | <%= h section.title %> 93 |
94 | <% end %> 95 | 96 | <% if section.comment then %> 97 |
98 | <%= section.description %> 99 |
100 | <% end %> 101 | 102 | <% unless constants.empty? %> 103 | 104 |
Constants
105 | 106 | <% context.each_constant do |const| %> 107 | 108 | 109 | 110 | 111 | 112 | <% if const.comment %> 113 | 114 | 115 | 116 | 117 | <% end %> 118 | <% end %> 119 |
<%= h const.name %>=<%= h const.value %>
 <%= const.description.strip %>
120 | <% end %> 121 | 122 | 123 | <% unless attributes.empty? %> 124 | 125 |
Attributes
126 | 127 | <% attributes.each do |attrib| %> 128 | 129 | 132 | 133 | 134 | 135 | <% end %> 136 |
130 | [<%= attrib.rw %>] 131 | <%= h attrib.name %><%= attrib.description.strip %>
137 | <% end %> 138 | 139 | 140 | 141 | <% 142 | context.methods_by_type(section).each do |type, visibilities| 143 | next if visibilities.empty? 144 | 145 | visibilities.each do |visibility, methods| 146 | next if methods.empty? 147 | %> 148 |
<%= type.capitalize %> <%= visibility.to_s.capitalize %> methods
149 | <% methods.each do |method| %> 150 |
151 |
152 | <% if method.call_seq %> 153 | <%= method.call_seq.gsub(/->/, '→') %> 154 | <% else %> 155 | <%= h method.name %><%= h method.params %> 156 | <% end %> 157 |
158 | 159 | <% if method.comment %> 160 |
161 | <%= method.description.strip %> 162 |
163 | <% end %> 164 | 165 | <% unless method.aliases.empty? %> 166 |
167 | Also aliased as: <%= method.aliases.map do |aka| 168 | if aka.parent then # HACK lib/rexml/encodings 169 | %{#{h aka.name}} 170 | else 171 | h aka.name 172 | end 173 | end.join ", " %> 174 |
175 | <% end %> 176 | 177 | <% if method.token_stream %> 178 | <% markup = method.sdoc_markup_code %> 179 |
180 | <% 181 | # generate github link 182 | github = if options.github 183 | if markup =~ /File\s(\S+), line (\d+)/ 184 | path = $1 185 | line = $2.to_i 186 | end 187 | path && github_url(path) 188 | else 189 | false 190 | end 191 | %> 192 | 199 |
200 |
<%= markup %>
201 |
202 |
203 | <% end %> 204 |
205 | <% end #methods.each %> 206 | <% end #visibilities.each %> 207 | <% end #context.methods_by_type %> 208 | <% end #context.each_section %> 209 |
-------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/_context.rhtml: -------------------------------------------------------------------------------- 1 |
2 | <% unless (description = context.description).empty? %> 3 |
4 | <%= description %> 5 |
6 | <% end %> 7 | 8 | 9 | <% unless context.requires.empty? %> 10 | 11 |
Required Files
12 | 17 | <% end %> 18 | 19 | 20 | <% sections = context.sections.select { |s| s.title }.sort_by{ |s| s.title.to_s } %> 21 | <% unless sections.empty? then %> 22 | 23 |
Sections
24 | 29 | <% end %> 30 | 31 | 32 | <% unless context.classes_and_modules.empty? %> 33 | 34 |
Namespace
35 | 43 | <% end %> 44 | 45 | 46 | <% unless context.method_list.empty? %> 47 | 48 |
Methods
49 |
50 | <% each_letter_group(context.method_list) do |group| %> 51 |
<%= group[:name] %>
52 |
53 |
    54 | <% group[:methods].each_with_index do |method, i| %> 55 | <% 56 | comma = group[:methods].size == i+1 ? '' : ',' 57 | %> 58 |
  • 59 | <%= h method.name %><%= comma %> 60 |
  • 61 | <% end %> 62 |
63 |
64 | <% end %> 65 |
66 | <% end %> 67 | 68 | <% unless context.includes.empty? %> 69 | 70 |
Included Modules
71 | 84 | <% end %> 85 | 86 | 87 | 88 | <% context.each_section do |section, constants, attributes| %> 89 | 90 | <% if section.title then %> 91 |
92 | <%= h section.title %> 93 |
94 | <% end %> 95 | 96 | <% if section.comment then %> 97 |
98 | <%= section.description %> 99 |
100 | <% end %> 101 | 102 | <% unless constants.empty? %> 103 | 104 |
Constants
105 | 106 | <% context.each_constant do |const| %> 107 | 108 | 109 | 110 | 111 | 112 | <% if const.comment %> 113 | 114 | 115 | 116 | 117 | <% end %> 118 | <% end %> 119 |
<%= h const.name %>=<%= h const.value %>
 <%= const.description.strip %>
120 | <% end %> 121 | 122 | 123 | <% unless attributes.empty? %> 124 | 125 |
Attributes
126 | 127 | <% attributes.each do |attrib| %> 128 | 129 | 132 | 133 | 134 | 135 | <% end %> 136 |
130 | [<%= attrib.rw %>] 131 | <%= h attrib.name %><%= attrib.description.strip %>
137 | <% end %> 138 | 139 | 140 | 141 | <% 142 | context.methods_by_type(section).each do |type, visibilities| 143 | next if visibilities.empty? 144 | 145 | visibilities.each do |visibility, methods| 146 | next if methods.empty? 147 | %> 148 |
<%= type.capitalize %> <%= visibility.to_s.capitalize %> methods
149 | <% methods.each do |method| %> 150 |
151 |
152 | <% if method.call_seq %> 153 | <%= method.call_seq.gsub(/->/, '→') %> 154 | <% else %> 155 | <%= h method.name %><%= h method.params %> 156 | <% end %> 157 |
158 | 159 | <% if method.comment %> 160 |
161 | <%= method.description.strip %> 162 |
163 | <% end %> 164 | 165 | <% unless method.aliases.empty? %> 166 |
167 | Also aliased as: <%= method.aliases.map do |aka| 168 | if aka.parent then # HACK lib/rexml/encodings 169 | %{#{h aka.name}} 170 | else 171 | h aka.name 172 | end 173 | end.join ", " %> 174 |
175 | <% end %> 176 | 177 | <% if method.token_stream %> 178 | <% markup = method.sdoc_markup_code %> 179 |
180 | <% 181 | # generate github link 182 | github = if options.github 183 | if markup =~ /File\s(\S+), line (\d+)/ 184 | path = $1 185 | line = $2.to_i 186 | end 187 | path && github_url(path) 188 | else 189 | false 190 | end 191 | %> 192 | 199 |
200 |
<%= markup %>
201 |
202 |
203 | <% end %> 204 |
205 | <% end #methods.each %> 206 | <% end #visibilities.each %> 207 | <% end #context.methods_by_type %> 208 | <% end #context.each_section %> 209 |
-------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/resources/css/panel.css: -------------------------------------------------------------------------------- 1 | /* Panel (begin) */ 2 | .panel 3 | { 4 | position: absolute; 5 | width: 100%; 6 | height: 100%; 7 | top: 0; 8 | left: 0; 9 | background: #FFF; 10 | z-index: 2; 11 | font-family: "Helvetica Neue", "Arial", sans-serif; 12 | //zoom: 1; 13 | } 14 | 15 | .panel_tree .results, 16 | .panel_results .tree 17 | { 18 | display: none; 19 | } 20 | 21 | /* Header with search box (begin) */ 22 | .panel .header 23 | { 24 | width: 100%; 25 | height: 29px; 26 | border-bottom: 1px solid #666; 27 | position: relative; 28 | left: 0; top: 0; 29 | background: #e8e8e8; 30 | } 31 | 32 | .panel .header div 33 | { 34 | margin: 0 7px; 35 | } 36 | .panel .header table 37 | { 38 | height: 29px; 39 | width: 100%; 40 | } 41 | 42 | .panel .header table td 43 | { 44 | vertical-align: middle; 45 | text-align: middle; 46 | } 47 | 48 | .panel .header label 49 | { 50 | position: absolute; 51 | font-size: 12px; 52 | line-height: 29px; 53 | margin-left: 3px; 54 | color: #777; 55 | cursor: text; 56 | } 57 | 58 | .panel .header table input 59 | { 60 | width: 100%; 61 | box-sizing: border-box; 62 | -moz-box-sizing: border-box; 63 | -webkit-box-sizing: border-box; 64 | display: inline-block; 65 | -webkit-appearance: searchfield; 66 | height: 22px; 67 | //height: auto; 68 | } 69 | 70 | /* Header with search box (end) */ 71 | 72 | 73 | /* Results (begin) */ 74 | .panel .result 75 | { 76 | position: absolute; 77 | top: 30px; 78 | bottom: 0; 79 | left: 0; 80 | width: 100%; 81 | //height: expression((this.parentNode.offsetHeight - 31)); 82 | overflow-y: scroll; 83 | overflow-x: hidden; 84 | -overflow-y: hidden; 85 | background: #EEE url(../i/results_bg.png); 86 | z-index: 2; 87 | //zoom:1; 88 | } 89 | 90 | .panel .result ul 91 | { 92 | font-size: 0.8em; 93 | width: 100%; 94 | background: #EEE url(../i/results_bg.png); 95 | //zoom:1; 96 | } 97 | 98 | .panel .result ul li 99 | { 100 | height: 46px; 101 | -height: 50px; 102 | //display: inline; 103 | //width: 100%; 104 | //zoom: 1; 105 | overflow: hidden; 106 | padding: 4px 10px 0 10px; 107 | cursor: pointer; 108 | } 109 | 110 | .panel .result ul li h1 111 | { 112 | font-size: 13px; 113 | font-weight: normal; 114 | color: #333; 115 | margin-bottom: 2px; 116 | white-space: nowrap; 117 | } 118 | 119 | .panel .result ul li p 120 | { 121 | font-size: 11px; 122 | color: #333; 123 | margin-bottom: 2px; 124 | white-space: nowrap; 125 | } 126 | 127 | .panel .result ul li h1 i, 128 | .panel .result ul li p.snippet 129 | { 130 | color: #777; 131 | } 132 | 133 | .panel .result ul li b 134 | { 135 | color: #000; 136 | } 137 | 138 | .panel .result ul li.current 139 | { 140 | background: #C52F24; 141 | } 142 | 143 | .panel .result ul li.current h1, 144 | .panel .result ul li.current p 145 | { 146 | color: #D9D9D9; 147 | } 148 | 149 | .panel .result ul li.current h1 i, 150 | .panel .result ul li.current p.snippet 151 | { 152 | color: #ACACAC; 153 | } 154 | 155 | .panel .result ul li.current b 156 | { 157 | color: #FFF; 158 | } 159 | 160 | 161 | .panel .result ul li:hover, 162 | .panel .result ul li.selected 163 | { 164 | background: #d0d0d0; 165 | } 166 | 167 | .panel .result ul li.current:hover 168 | { 169 | background: #C52F24; 170 | } 171 | 172 | .panel .result ul li .badge 173 | { 174 | margin-right: 0.4em; 175 | margin-left: -0.2em; 176 | padding: 0 0.2em; 177 | color: #000; 178 | border-radius: 3px; 179 | } 180 | 181 | .panel .result ul li .badge_1 182 | { 183 | background: #ACDBF4; 184 | } 185 | 186 | .panel .result ul li.current .badge_1 187 | { 188 | background: #97BFD7; 189 | } 190 | 191 | .panel .result ul li .badge_2 192 | { 193 | background: #ACF3C3; 194 | } 195 | 196 | .panel .result ul li.current .badge_2 197 | { 198 | background: #98D7AC; 199 | } 200 | 201 | .panel .result ul li .badge_3 202 | { 203 | background: #E0F3AC; 204 | } 205 | 206 | .panel .result ul li.current .badge_3 207 | { 208 | background: #C4D798; 209 | } 210 | 211 | .panel .result ul li .badge_4 212 | { 213 | background: #D7CA98; 214 | } 215 | 216 | .panel .result ul li.current .badge_4 217 | { 218 | background: #A6B0AC; 219 | } 220 | 221 | .panel .result ul li .badge_5 222 | { 223 | background: #F3C8AC; 224 | } 225 | 226 | .panel .result ul li.current .badge_5 227 | { 228 | background: #D7B198; 229 | } 230 | 231 | .panel .result ul li .badge_6 232 | { 233 | background: #F3ACC3; 234 | } 235 | 236 | .panel .result ul li.current .badge_6 237 | { 238 | background: #D798AB; 239 | } 240 | 241 | /* Results (end) */ 242 | 243 | /* Tree (begin) */ /**/ 244 | .panel .tree 245 | { 246 | position: absolute; 247 | top: 30px; 248 | bottom: 0; 249 | left: 0; 250 | width: 100%; 251 | //zoom: 1; 252 | //height: expression((this.parentNode.offsetHeight - 31)); 253 | overflow-y: scroll; 254 | overflow-x: hidden; 255 | -overflow-y: hidden; 256 | background: #EEE url(../i/tree_bg.png); 257 | z-index: 30; 258 | } 259 | 260 | .panel .tree ul 261 | { 262 | background: #EEE url(../i/tree_bg.png); 263 | } 264 | 265 | .panel .tree li 266 | { 267 | cursor: pointer; 268 | overflow: hidden; 269 | //height: 23px; 270 | //display: inline; 271 | //zoom: 1; 272 | //width: 100%; 273 | } 274 | 275 | 276 | .panel .tree li .content 277 | { 278 | padding-left: 18px; 279 | padding-top: 5px; 280 | height: 18px; 281 | overflow: hidden; 282 | position: relative; 283 | } 284 | 285 | .panel .tree li .icon 286 | { 287 | width: 10px; 288 | height: 9px; 289 | background: url(../i/arrows.png); 290 | background-position: 0 -9px; 291 | position: absolute; 292 | left: 1px; 293 | top: 8px; 294 | cursor: default; 295 | } 296 | 297 | .panel .tree li.closed .icon 298 | { 299 | background-position: 0 0; 300 | } 301 | 302 | .panel .tree ul li h1 303 | { 304 | font-size: 13px; 305 | font-weight: normal; 306 | color: #000; 307 | margin-bottom: 2px; 308 | white-space: nowrap; 309 | } 310 | 311 | .panel .tree ul li p 312 | { 313 | font-size: 11px; 314 | color: #666; 315 | margin-bottom: 2px; 316 | white-space: nowrap; 317 | } 318 | 319 | .panel .tree ul li h1 i 320 | { 321 | color: #999; 322 | font-style: normal; 323 | } 324 | 325 | .panel .tree ul li.current h1 i 326 | { 327 | color: #CCC; 328 | } 329 | 330 | .panel .tree ul li.empty 331 | { 332 | cursor: text; 333 | } 334 | 335 | .panel .tree ul li.empty h1, 336 | .panel .tree ul li.empty p 337 | { 338 | color: #666; 339 | font-style: italic; 340 | } 341 | 342 | .panel .tree ul li.current 343 | { 344 | background: #C52F24; 345 | } 346 | 347 | .panel .tree ul li.current .icon 348 | { 349 | background-position: -10px -9px; 350 | } 351 | 352 | .panel .tree ul li.current.closed .icon 353 | { 354 | background-position: -10px 0; 355 | } 356 | 357 | .panel .tree ul li.current h1 358 | { 359 | color: #FFF; 360 | } 361 | 362 | .panel .tree ul li.current p 363 | { 364 | color: #CCC; 365 | } 366 | 367 | .panel .tree ul li.current.empty h1, 368 | .panel .tree ul li.current.empty p 369 | { 370 | color: #999; 371 | } 372 | 373 | .panel .tree ul li:hover 374 | { 375 | background: #d0d0d0; 376 | } 377 | 378 | .panel .tree ul li.current:hover 379 | { 380 | background: #C52F24; 381 | } 382 | 383 | .panel .tree .stopper 384 | { 385 | display: none; 386 | } 387 | /* Tree (end) */ /**/ 388 | 389 | /* Panel (end) */ -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/resources/css/panel.css: -------------------------------------------------------------------------------- 1 | /* Panel (begin) */ 2 | .panel 3 | { 4 | position: absolute; 5 | width: 100%; 6 | height: 100%; 7 | top: 0; 8 | left: 0; 9 | background: #FFF; 10 | z-index: 2; 11 | font-family: "Helvetica Neue", "Arial", sans-serif; 12 | //zoom: 1; 13 | } 14 | 15 | .panel_tree .results, 16 | .panel_results .tree 17 | { 18 | display: none; 19 | } 20 | 21 | /* Header with search box (begin) */ 22 | .panel .header 23 | { 24 | width: 100%; 25 | height: 29px; 26 | border-bottom: 1px solid #666; 27 | position: relative; 28 | left: 0; top: 0; 29 | background: #e8e8e8; 30 | } 31 | 32 | .panel .header div 33 | { 34 | margin: 0 7px; 35 | } 36 | .panel .header table 37 | { 38 | height: 29px; 39 | width: 100%; 40 | } 41 | 42 | .panel .header table td 43 | { 44 | vertical-align: middle; 45 | text-align: middle; 46 | } 47 | 48 | .panel .header label 49 | { 50 | position: absolute; 51 | font-size: 12px; 52 | line-height: 29px; 53 | margin-left: 3px; 54 | color: #999; 55 | cursor: text; 56 | } 57 | 58 | .panel .header table input 59 | { 60 | width: 100%; 61 | box-sizing: border-box; 62 | -moz-box-sizing: border-box; 63 | -webkit-box-sizing: border-box; 64 | display: inline-block; 65 | -webkit-appearance: searchfield; 66 | height: 22px; 67 | //height: auto; 68 | } 69 | 70 | /* Header with search box (end) */ 71 | 72 | 73 | /* Results (begin) */ 74 | .panel .result 75 | { 76 | position: absolute; 77 | top: 30px; 78 | bottom: 0; 79 | left: 0; 80 | width: 100%; 81 | //height: expression((this.parentNode.offsetHeight - 31)); 82 | overflow-y: scroll; 83 | overflow-x: hidden; 84 | -overflow-y: hidden; 85 | background: #EDF3FE url(../i/results_bg.png); 86 | z-index: 2; 87 | //zoom:1; 88 | } 89 | 90 | .panel .result ul 91 | { 92 | font-size: 0.8em; 93 | width: 100%; 94 | background: #EDF3FE url(../i/results_bg.png); 95 | //zoom:1; 96 | } 97 | 98 | .panel .result ul li 99 | { 100 | height: 46px; 101 | -height: 50px; 102 | //display: inline; 103 | //width: 100%; 104 | //zoom: 1; 105 | overflow: hidden; 106 | padding: 4px 10px 0 10px; 107 | cursor: pointer; 108 | } 109 | 110 | .panel .result ul li h1 111 | { 112 | font-size: 13px; 113 | font-weight: normal; 114 | color: #333; 115 | margin-bottom: 2px; 116 | white-space: nowrap; 117 | } 118 | 119 | .panel .result ul li p 120 | { 121 | font-size: 11px; 122 | color: #333; 123 | margin-bottom: 2px; 124 | white-space: nowrap; 125 | } 126 | 127 | .panel .result ul li h1 i, 128 | .panel .result ul li p.snippet 129 | { 130 | color: #999; 131 | } 132 | 133 | .panel .result ul li b 134 | { 135 | color: #000; 136 | } 137 | 138 | .panel .result ul li.current 139 | { 140 | background: #3875D7; 141 | } 142 | 143 | .panel .result ul li.current h1, 144 | .panel .result ul li.current p 145 | { 146 | color: #DDD; 147 | } 148 | 149 | .panel .result ul li.current h1 i, 150 | .panel .result ul li.current p.snippet 151 | { 152 | color: #AAA; 153 | } 154 | 155 | .panel .result ul li.current b 156 | { 157 | color: #FFF; 158 | } 159 | 160 | 161 | .panel .result ul li:hover, 162 | .panel .result ul li.selected 163 | { 164 | background: #d0d0d0; 165 | } 166 | 167 | .panel .result ul li.current:hover 168 | { 169 | background: #2965C0; 170 | } 171 | 172 | .panel .result ul li .badge 173 | { 174 | margin-right: 0.4em; 175 | margin-left: -0.2em; 176 | padding: 0 0.2em; 177 | color: #000; 178 | border-radius: 3px; 179 | } 180 | 181 | .panel .result ul li .badge_1 182 | { 183 | background: #ACDBF4; 184 | } 185 | 186 | .panel .result ul li.current .badge_1 187 | { 188 | background: #97BFD7; 189 | } 190 | 191 | .panel .result ul li .badge_2 192 | { 193 | background: #ACF3C3; 194 | } 195 | 196 | .panel .result ul li.current .badge_2 197 | { 198 | background: #98D7AC; 199 | } 200 | 201 | .panel .result ul li .badge_3 202 | { 203 | background: #E0F3AC; 204 | } 205 | 206 | .panel .result ul li.current .badge_3 207 | { 208 | background: #C4D798; 209 | } 210 | 211 | .panel .result ul li .badge_4 212 | { 213 | background: #D7CA98; 214 | } 215 | 216 | .panel .result ul li.current .badge_4 217 | { 218 | background: #A6B0AC; 219 | } 220 | 221 | .panel .result ul li .badge_5 222 | { 223 | background: #F3C8AC; 224 | } 225 | 226 | .panel .result ul li.current .badge_5 227 | { 228 | background: #D7B198; 229 | } 230 | 231 | .panel .result ul li .badge_6 232 | { 233 | background: #F3ACC3; 234 | } 235 | 236 | .panel .result ul li.current .badge_6 237 | { 238 | background: #D798AB; 239 | } 240 | 241 | /* Results (end) */ 242 | 243 | /* Tree (begin) */ /**/ 244 | .panel .tree 245 | { 246 | position: absolute; 247 | top: 30px; 248 | bottom: 0; 249 | left: 0; 250 | width: 100%; 251 | //zoom: 1; 252 | //height: expression((this.parentNode.offsetHeight - 31)); 253 | overflow-y: scroll; 254 | overflow-x: hidden; 255 | -overflow-y: hidden; 256 | background: #EDF3FE url(../i/tree_bg.png); 257 | z-index: 30; 258 | } 259 | 260 | .panel .tree ul 261 | { 262 | background: #EDF3FE url(../i/tree_bg.png); 263 | } 264 | 265 | .panel .tree li 266 | { 267 | cursor: pointer; 268 | overflow: hidden; 269 | //height: 23px; 270 | //display: inline; 271 | //zoom: 1; 272 | //width: 100%; 273 | } 274 | 275 | 276 | .panel .tree li .content 277 | { 278 | padding-left: 18px; 279 | padding-top: 5px; 280 | height: 18px; 281 | overflow: hidden; 282 | position: relative; 283 | } 284 | 285 | .panel .tree li .icon 286 | { 287 | width: 10px; 288 | height: 9px; 289 | background: url(../i/arrows.png); 290 | background-position: 0 -9px; 291 | position: absolute; 292 | left: 1px; 293 | top: 8px; 294 | cursor: default; 295 | } 296 | 297 | .panel .tree li.closed .icon 298 | { 299 | background-position: 0 0; 300 | } 301 | 302 | .panel .tree ul li h1 303 | { 304 | font-size: 13px; 305 | font-weight: normal; 306 | color: #000; 307 | margin-bottom: 2px; 308 | white-space: nowrap; 309 | } 310 | 311 | .panel .tree ul li p 312 | { 313 | font-size: 11px; 314 | color: #666; 315 | margin-bottom: 2px; 316 | white-space: nowrap; 317 | } 318 | 319 | .panel .tree ul li h1 i 320 | { 321 | color: #999; 322 | font-style: normal; 323 | } 324 | 325 | .panel .tree ul li.empty 326 | { 327 | cursor: text; 328 | } 329 | 330 | .panel .tree ul li.empty h1, 331 | .panel .tree ul li.empty p 332 | { 333 | color: #666; 334 | font-style: italic; 335 | } 336 | 337 | .panel .tree ul li.current 338 | { 339 | background: #3875D7; 340 | } 341 | 342 | .panel .tree ul li.current .icon 343 | { 344 | background-position: -10px -9px; 345 | } 346 | 347 | .panel .tree ul li.current.closed .icon 348 | { 349 | background-position: -10px 0; 350 | } 351 | 352 | .panel .tree ul li.current h1 353 | { 354 | color: #FFF; 355 | } 356 | 357 | .panel .tree ul li.current p 358 | { 359 | color: #CCC; 360 | } 361 | 362 | .panel .tree ul li.current.empty h1, 363 | .panel .tree ul li.current.empty p 364 | { 365 | color: #999; 366 | } 367 | 368 | .panel .tree ul li:hover 369 | { 370 | background: #d0d0d0; 371 | } 372 | 373 | .panel .tree ul li.current:hover 374 | { 375 | background: #2965C0; 376 | } 377 | 378 | .panel .tree .stopper 379 | { 380 | display: none; 381 | } 382 | /* Tree (end) */ /**/ 383 | 384 | /* Panel (end) */ -------------------------------------------------------------------------------- /lib/sdoc/generator.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'erb' 3 | require 'pathname' 4 | require 'fileutils' 5 | if Gem::Specification.respond_to?(:find_by_name) ? Gem::Specification::find_by_name("json") : Gem.available?("json") 6 | gem "json", ">= 1.1.3" 7 | else 8 | gem "json_pure", ">= 1.1.3" 9 | end 10 | require 'json' 11 | 12 | require 'sdoc/github' 13 | require 'sdoc/templatable' 14 | require 'sdoc/helpers' 15 | require 'rdoc' 16 | 17 | class RDoc::ClassModule 18 | def with_documentation? 19 | document_self_or_methods || classes_and_modules.any?{ |c| c.with_documentation? } 20 | end 21 | end 22 | 23 | class RDoc::Options 24 | attr_accessor :github 25 | attr_accessor :se_index 26 | end 27 | 28 | class RDoc::AnyMethod 29 | 30 | TITLE_AFTER = %w(def class module) 31 | 32 | ## 33 | # Turns the method's token stream into HTML. 34 | # 35 | # Prepends line numbers if +add_line_numbers+ is true. 36 | 37 | def sdoc_markup_code 38 | return '' unless @token_stream 39 | 40 | src = "" 41 | starting_title = false 42 | 43 | @token_stream.each do |t| 44 | next unless t 45 | 46 | style = case t 47 | when RDoc::RubyToken::TkFLOAT then 'ruby-number' 48 | when RDoc::RubyToken::TkINTEGER then 'ruby-number' 49 | when RDoc::RubyToken::TkCONSTANT then 'ruby-constant' 50 | when RDoc::RubyToken::TkKW then 'ruby-keyword' 51 | when RDoc::RubyToken::TkIVAR then 'ruby-ivar' 52 | when RDoc::RubyToken::TkOp then 'ruby-operator' 53 | when RDoc::RubyToken::TkId then 'ruby-identifier' 54 | when RDoc::RubyToken::TkNode then 'ruby-node' 55 | when RDoc::RubyToken::TkCOMMENT then 'ruby-comment' 56 | when RDoc::RubyToken::TkREGEXP then 'ruby-regexp' 57 | when RDoc::RubyToken::TkSTRING then 'ruby-string' 58 | when RDoc::RubyToken::TkVal then 'ruby-value' 59 | end 60 | 61 | if RDoc::RubyToken::TkId === t && starting_title 62 | starting_title = false 63 | style = 'ruby-keyword ruby-title' 64 | end 65 | 66 | if RDoc::RubyToken::TkKW === t && TITLE_AFTER.include?(t.text) 67 | starting_title = true 68 | end 69 | 70 | text = CGI.escapeHTML t.text 71 | 72 | if style then 73 | src << "#{text}" 74 | else 75 | src << text 76 | end 77 | end 78 | 79 | # dedent the source 80 | indent = src.length 81 | lines = src.lines.to_a 82 | lines.shift if src =~ /\A.*#\ *File/i # remove '# File' comment 83 | lines.each do |line| 84 | if line =~ /^ *(?=\S)/ 85 | n = $&.length 86 | indent = n if n < indent 87 | break if n == 0 88 | end 89 | end 90 | src.gsub!(/^#{' ' * indent}/, '') if indent > 0 91 | 92 | add_line_numbers(src) if self.class.add_line_numbers 93 | 94 | src 95 | end 96 | 97 | end 98 | 99 | class RDoc::Generator::SDoc 100 | RDoc::RDoc.add_generator self 101 | 102 | DESCRIPTION = 'Searchable HTML documentation' 103 | 104 | include ERB::Util 105 | include SDoc::GitHub 106 | include SDoc::Templatable 107 | include SDoc::Helpers 108 | 109 | GENERATOR_DIRS = [File.join('sdoc', 'generator')] 110 | 111 | TREE_FILE = File.join 'panel', 'tree.js' 112 | SEARCH_INDEX_FILE = File.join 'js', 'search_index.js' 113 | 114 | FILE_DIR = 'files' 115 | CLASS_DIR = 'classes' 116 | 117 | RESOURCES_DIR = File.join('resources', '.') 118 | 119 | attr_reader :base_dir 120 | 121 | attr_reader :options 122 | 123 | def self.setup_options(options) 124 | @github = false 125 | options.se_index = true 126 | 127 | opt = options.option_parser 128 | opt.separator nil 129 | opt.separator "SDoc generator options:" 130 | opt.separator nil 131 | opt.on("--github", "-g", 132 | "Generate links to github.") do |value| 133 | options.github = true 134 | end 135 | opt.separator nil 136 | 137 | opt.on("--no-se-index", "-ns", 138 | "Do not generated index file for search engines.", 139 | "SDoc uses javascript to refrence individual documentation pages.", 140 | "Search engine crawlers are not smart enough to find all the", 141 | "referenced pages.", 142 | "To help them SDoc generates a static file with links to every", 143 | "documentation page. This file is not shown to the user." 144 | ) do |value| 145 | options.se_index = false 146 | end 147 | opt.separator nil 148 | 149 | end 150 | 151 | def initialize(options) 152 | @options = options 153 | if @options.respond_to?('diagram=') 154 | @options.diagram = false 155 | end 156 | @github_url_cache = {} 157 | 158 | @template_dir = Pathname.new(options.template_dir) 159 | @base_dir = Pathname.pwd.expand_path 160 | 161 | @json_index = RDoc::Generator::JsonIndex.new self, options 162 | end 163 | 164 | def generate(top_levels) 165 | @outputdir = Pathname.new(@options.op_dir).expand_path(@base_dir) 166 | @files = top_levels.sort 167 | @classes = RDoc::TopLevel.all_classes_and_modules.sort 168 | 169 | # Now actually write the output 170 | copy_resources 171 | generate_class_tree 172 | @json_index.generate top_levels 173 | generate_file_files 174 | generate_class_files 175 | generate_index_file 176 | generate_se_index if @options.se_index 177 | end 178 | 179 | def class_dir 180 | CLASS_DIR 181 | end 182 | 183 | def file_dir 184 | FILE_DIR 185 | end 186 | 187 | protected 188 | ### Output progress information if debugging is enabled 189 | def debug_msg( *msg ) 190 | return unless $DEBUG_RDOC 191 | $stderr.puts( *msg ) 192 | end 193 | 194 | ### Create class tree structure and write it as json 195 | def generate_class_tree 196 | debug_msg "Generating class tree" 197 | topclasses = @classes.select {|klass| !(RDoc::ClassModule === klass.parent) } 198 | tree = generate_file_tree + generate_class_tree_level(topclasses) 199 | debug_msg " writing class tree to %s" % TREE_FILE 200 | File.open(TREE_FILE, "w", 0644) do |f| 201 | f.write('var tree = '); f.write(tree.to_json(:max_nesting => 0)) 202 | end unless $dryrun 203 | end 204 | 205 | ### Recursivly build class tree structure 206 | def generate_class_tree_level(classes, visited = {}) 207 | tree = [] 208 | classes.select do |klass| 209 | !visited[klass] && klass.with_documentation? 210 | end.sort.each do |klass| 211 | visited[klass] = true 212 | item = [ 213 | klass.name, 214 | klass.document_self_or_methods ? klass.path : '', 215 | klass.module? ? '' : (klass.superclass ? " < #{String === klass.superclass ? klass.superclass : klass.superclass.full_name}" : ''), 216 | generate_class_tree_level(klass.classes_and_modules, visited) 217 | ] 218 | tree << item 219 | end 220 | tree 221 | end 222 | 223 | ### Add files to search +index+ array 224 | def add_file_search_index(index) 225 | debug_msg " generating file search index" 226 | 227 | @files.select { |file| 228 | file.document_self 229 | }.sort.each do |file| 230 | debug_msg " #{file.path}" 231 | index[:searchIndex].push( search_string(file.name) ) 232 | index[:longSearchIndex].push( search_string(file.path) ) 233 | index[:info].push([ 234 | file.name, 235 | file.path, 236 | file.path, 237 | '', 238 | snippet(file.comment), 239 | TYPE_FILE 240 | ]) 241 | end 242 | end 243 | 244 | ### Add classes to search +index+ array 245 | def add_class_search_index(index) 246 | debug_msg " generating class search index" 247 | @classes.uniq.select { |klass| 248 | klass.document_self_or_methods 249 | }.sort.each do |klass| 250 | modulename = klass.module? ? '' : (klass.superclass ? (String === klass.superclass ? klass.superclass : klass.superclass.full_name) : '') 251 | debug_msg " #{klass.parent.full_name}::#{klass.name}" 252 | index[:searchIndex].push( search_string(klass.name) ) 253 | index[:longSearchIndex].push( search_string(klass.parent.full_name) ) 254 | files = klass.in_files.map{ |file| file.absolute_name } 255 | index[:info].push([ 256 | klass.name, 257 | files.include?(klass.parent.full_name) ? files.first : klass.parent.full_name, 258 | klass.path, 259 | modulename ? " < #{modulename}" : '', 260 | snippet(klass.comment), 261 | TYPE_CLASS 262 | ]) 263 | end 264 | end 265 | 266 | ### Add methods to search +index+ array 267 | def add_method_search_index(index) 268 | debug_msg " generating method search index" 269 | 270 | list = @classes.uniq.map do |klass| 271 | klass.method_list 272 | end.flatten.sort do |a, b| 273 | a.name == b.name ? 274 | a.parent.full_name <=> b.parent.full_name : 275 | a.name <=> b.name 276 | end.select do |method| 277 | method.document_self 278 | end.find_all do |m| 279 | m.visibility == :public || m.visibility == :protected || 280 | m.force_documentation 281 | end 282 | 283 | list.each do |method| 284 | debug_msg " #{method.full_name}" 285 | index[:searchIndex].push( search_string(method.name) + '()' ) 286 | index[:longSearchIndex].push( search_string(method.parent.full_name) ) 287 | index[:info].push([ 288 | method.name, 289 | method.parent.full_name, 290 | method.path, 291 | method.params, 292 | snippet(method.comment), 293 | TYPE_METHOD 294 | ]) 295 | end 296 | end 297 | 298 | ### Generate a documentation file for each class 299 | def generate_class_files 300 | debug_msg "Generating class documentation in #@outputdir" 301 | templatefile = @template_dir + 'class.rhtml' 302 | 303 | @classes.each do |klass| 304 | debug_msg " working on %s (%s)" % [ klass.full_name, klass.path ] 305 | outfile = @outputdir + klass.path 306 | rel_prefix = @outputdir.relative_path_from( outfile.dirname ) 307 | 308 | debug_msg " rendering #{outfile}" 309 | self.render_template( templatefile, binding(), outfile ) 310 | end 311 | end 312 | 313 | ### Generate a documentation file for each file 314 | def generate_file_files 315 | debug_msg "Generating file documentation in #@outputdir" 316 | templatefile = @template_dir + 'file.rhtml' 317 | 318 | @files.each do |file| 319 | outfile = @outputdir + file.path 320 | debug_msg " working on %s (%s)" % [ file.full_name, outfile ] 321 | rel_prefix = @outputdir.relative_path_from( outfile.dirname ) 322 | 323 | debug_msg " rendering #{outfile}" 324 | self.render_template( templatefile, binding(), outfile ) 325 | end 326 | end 327 | 328 | ### Determines index path based on @options.main_page (or lack thereof) 329 | def index_path 330 | # Break early to avoid a big if block when no main page is specified 331 | default = @files.first.path 332 | return default unless @options.main_page 333 | 334 | # Transform class name to file path 335 | if @options.main_page.include?("::") 336 | slashed = @options.main_page.sub(/^::/, "").gsub("::", "/") 337 | "%s/%s.html" % [ class_dir, slashed ] 338 | elsif file = @files.find { |f| f.full_name == @options.main_page } 339 | file.path 340 | else 341 | default 342 | end 343 | end 344 | 345 | ### Create index.html with frameset 346 | def generate_index_file 347 | debug_msg "Generating index file in #@outputdir" 348 | templatefile = @template_dir + 'index.rhtml' 349 | outfile = @outputdir + 'index.html' 350 | 351 | self.render_template( templatefile, binding(), outfile ) 352 | end 353 | 354 | ### Generate file with links for the search engine 355 | def generate_se_index 356 | debug_msg "Generating search engine index in #@outputdir" 357 | templatefile = @template_dir + 'se_index.rhtml' 358 | outfile = @outputdir + 'panel/links.html' 359 | 360 | self.render_template( templatefile, binding(), outfile ) 361 | end 362 | 363 | ### Copy all the resource files to output dir 364 | def copy_resources 365 | resoureces_path = @template_dir + RESOURCES_DIR 366 | debug_msg "Copying #{resoureces_path}/** to #{@outputdir}/**" 367 | FileUtils.cp_r resoureces_path.to_s, @outputdir.to_s, :preserve => true unless $dryrun 368 | end 369 | 370 | class FilesTree 371 | attr_reader :children 372 | def add(path, url) 373 | path = path.split(File::SEPARATOR) unless Array === path 374 | @children ||= {} 375 | if path.length == 1 376 | @children[path.first] = url 377 | else 378 | @children[path.first] ||= FilesTree.new 379 | @children[path.first].add(path[1, path.length], url) 380 | end 381 | end 382 | end 383 | 384 | def generate_file_tree 385 | if @files.length > 1 386 | @files_tree = FilesTree.new 387 | @files.each do |file| 388 | @files_tree.add(file.relative_name, file.path) 389 | end 390 | [['', '', 'files', generate_file_tree_level(@files_tree)]] 391 | else 392 | [] 393 | end 394 | end 395 | 396 | def generate_file_tree_level(tree) 397 | tree.children.keys.sort.map do |name| 398 | child = tree.children[name] 399 | if String === child 400 | [name, child, '', []] 401 | else 402 | ['', '', name, generate_file_tree_level(child)] 403 | end 404 | end 405 | end 406 | end 407 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/resources/js/highlight.pack.js: -------------------------------------------------------------------------------- 1 | var hljs=new function(){function l(o){return o.replace(/&/gm,"&").replace(/"}while(x.length||y.length){var u=t().splice(0,1)[0];v+=l(w.substr(q,u.offset-q));q=u.offset;if(u.event=="start"){v+=r(u.node);s.push(u.node)}else{if(u.event=="stop"){var p=s.length;do{p--;var o=s[p];v+=("")}while(o!=u.node);s.splice(p,1);while(p'+l(K[0])+""}else{M+=l(K[0])}O=N.lR.lastIndex;K=N.lR.exec(L)}M+=l(L.substr(O,L.length-O));return M}function J(r,L){if(L.sL&&d[L.sL]){var K=f(L.sL,r);s+=K.keyword_count;return K.value}else{return E(r,L)}}function H(L,r){var K=L.cN?'':"";if(L.rB){p+=K;L.buffer=""}else{if(L.eB){p+=l(r)+K;L.buffer=""}else{p+=K;L.buffer=r}}B.push(L);A+=L.r}function D(N,K,P){var Q=B[B.length-1];if(P){p+=J(Q.buffer+N,Q);return false}var L=y(K,Q);if(L){p+=J(Q.buffer+N,Q);H(L,K);return L.rB}var r=v(B.length-1,K);if(r){var M=Q.cN?"":"";if(Q.rE){p+=J(Q.buffer+N,Q)+M}else{if(Q.eE){p+=J(Q.buffer+N,Q)+M+l(K)}else{p+=J(Q.buffer+N+K,Q)+M}}while(r>1){M=B[B.length-2].cN?"":"";p+=M;r--;B.length--}var O=B[B.length-1];B.length--;B[B.length-1].buffer="";if(O.starts){H(O.starts,"")}return Q.rE}if(w(K,Q)){throw"Illegal"}}var G=d[I];var B=[G.dM];var A=0;var s=0;var p="";try{var u=0;G.dM.buffer="";do{var x=q(C,u);var t=D(x[0],x[1],x[2]);u+=x[0].length;if(!t){u+=x[1].length}}while(!x[2]);if(B.length>1){throw"Illegal"}return{language:I,r:A,keyword_count:s,value:p}}catch(F){if(F=="Illegal"){return{language:null,r:0,keyword_count:0,value:l(C)}}else{throw F}}}function h(){function o(t,s,u){if(t.compiled){return}if(!u){t.bR=c(s,t.b?t.b:"\\B|\\b");if(!t.e&&!t.eW){t.e="\\B|\\b"}if(t.e){t.eR=c(s,t.e)}}if(t.i){t.iR=c(s,t.i)}if(t.r==undefined){t.r=1}if(t.k){t.lR=c(s,t.l||hljs.IR,true)}for(var r in t.k){if(!t.k.hasOwnProperty(r)){continue}if(t.k[r] instanceof Object){t.kG=t.k}else{t.kG={keyword:t.k}}break}if(!t.c){t.c=[]}t.compiled=true;for(var q=0;qx.keyword_count+x.r){x=u}if(u.keyword_count+u.r>w.keyword_count+w.r){x=w;w=u}}}var s=t.className;if(!s.match(w.language)){s=s?(s+" "+w.language):w.language}var o=b(t);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=k(o,b(q),A)}if(y){w.value=w.value.replace(/^((<[^>]+>|\t)+)/gm,function(B,E,D,C){return E.replace(/\t/g,y)})}if(p){w.value=w.value.replace(/\n/g,"
")}if(/MSIE [678]/.test(navigator.userAgent)&&t.tagName=="CODE"&&t.parentNode.tagName=="PRE"){var q=t.parentNode;var v=document.createElement("div");v.innerHTML="
"+w.value+"
";t=v.firstChild.firstChild;v.firstChild.cN=q.cN;q.parentNode.replaceChild(v.firstChild,q)}else{t.innerHTML=w.value}t.className=s;t.dataset={};t.dataset.result={language:w.language,kw:w.keyword_count,re:w.r};if(x&&x.language){t.dataset.second_best={language:x.language,kw:x.keyword_count,re:x.r}}}function j(){if(j.called){return}j.called=true;e();var q=document.getElementsByTagName("pre");for(var o=0;o|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\.",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.inherit=function(o,r){var q={};for(var p in o){q[p]=o[p]}if(r){for(var p in r){q[p]=r[p]}}return q}}();hljs.LANGUAGES.ruby=function(){var g="[a-zA-Z_][a-zA-Z0-9_]*(\\!|\\?)?";var a="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?";var n={keyword:{and:1,"false":1,then:1,defined:1,module:1,"in":1,"return":1,redo:1,"if":1,BEGIN:1,retry:1,end:1,"for":1,"true":1,self:1,when:1,next:1,until:1,"do":1,begin:1,unless:1,END:1,rescue:1,nil:1,"else":1,"break":1,undef:1,not:1,"super":1,"class":1,"case":1,require:1,yield:1,alias:1,"while":1,ensure:1,elsif:1,or:1,def:1},keymethods:{__id__:1,__send__:1,abort:1,abs:1,"all?":1,allocate:1,ancestors:1,"any?":1,arity:1,assoc:1,at:1,at_exit:1,autoload:1,"autoload?":1,"between?":1,binding:1,binmode:1,"block_given?":1,call:1,callcc:1,caller:1,capitalize:1,"capitalize!":1,casecmp:1,"catch":1,ceil:1,center:1,chomp:1,"chomp!":1,chop:1,"chop!":1,chr:1,"class":1,class_eval:1,"class_variable_defined?":1,class_variables:1,clear:1,clone:1,close:1,close_read:1,close_write:1,"closed?":1,coerce:1,collect:1,"collect!":1,compact:1,"compact!":1,concat:1,"const_defined?":1,const_get:1,const_missing:1,const_set:1,constants:1,count:1,crypt:1,"default":1,default_proc:1,"delete":1,"delete!":1,delete_at:1,delete_if:1,detect:1,display:1,div:1,divmod:1,downcase:1,"downcase!":1,downto:1,dump:1,dup:1,each:1,each_byte:1,each_index:1,each_key:1,each_line:1,each_pair:1,each_value:1,each_with_index:1,"empty?":1,entries:1,eof:1,"eof?":1,"eql?":1,"equal?":1,"eval":1,exec:1,exit:1,"exit!":1,extend:1,fail:1,fcntl:1,fetch:1,fileno:1,fill:1,find:1,find_all:1,first:1,flatten:1,"flatten!":1,floor:1,flush:1,for_fd:1,foreach:1,fork:1,format:1,freeze:1,"frozen?":1,fsync:1,getc:1,gets:1,global_variables:1,grep:1,gsub:1,"gsub!":1,"has_key?":1,"has_value?":1,hash:1,hex:1,id:1,include:1,"include?":1,included_modules:1,index:1,indexes:1,indices:1,induced_from:1,inject:1,insert:1,inspect:1,instance_eval:1,instance_method:1,instance_methods:1,"instance_of?":1,"instance_variable_defined?":1,instance_variable_get:1,instance_variable_set:1,instance_variables:1,"integer?":1,intern:1,invert:1,ioctl:1,"is_a?":1,isatty:1,"iterator?":1,join:1,"key?":1,keys:1,"kind_of?":1,lambda:1,last:1,length:1,lineno:1,ljust:1,load:1,local_variables:1,loop:1,lstrip:1,"lstrip!":1,map:1,"map!":1,match:1,max:1,"member?":1,merge:1,"merge!":1,method:1,"method_defined?":1,method_missing:1,methods:1,min:1,module_eval:1,modulo:1,name:1,nesting:1,"new":1,next:1,"next!":1,"nil?":1,nitems:1,"nonzero?":1,object_id:1,oct:1,open:1,pack:1,partition:1,pid:1,pipe:1,pop:1,popen:1,pos:1,prec:1,prec_f:1,prec_i:1,print:1,printf:1,private_class_method:1,private_instance_methods:1,"private_method_defined?":1,private_methods:1,proc:1,protected_instance_methods:1,"protected_method_defined?":1,protected_methods:1,public_class_method:1,public_instance_methods:1,"public_method_defined?":1,public_methods:1,push:1,putc:1,puts:1,quo:1,raise:1,rand:1,rassoc:1,read:1,read_nonblock:1,readchar:1,readline:1,readlines:1,readpartial:1,rehash:1,reject:1,"reject!":1,remainder:1,reopen:1,replace:1,require:1,"respond_to?":1,reverse:1,"reverse!":1,reverse_each:1,rewind:1,rindex:1,rjust:1,round:1,rstrip:1,"rstrip!":1,scan:1,seek:1,select:1,send:1,set_trace_func:1,shift:1,singleton_method_added:1,singleton_methods:1,size:1,sleep:1,slice:1,"slice!":1,sort:1,"sort!":1,sort_by:1,split:1,sprintf:1,squeeze:1,"squeeze!":1,srand:1,stat:1,step:1,store:1,strip:1,"strip!":1,sub:1,"sub!":1,succ:1,"succ!":1,sum:1,superclass:1,swapcase:1,"swapcase!":1,sync:1,syscall:1,sysopen:1,sysread:1,sysseek:1,system:1,syswrite:1,taint:1,"tainted?":1,tell:1,test:1,"throw":1,times:1,to_a:1,to_ary:1,to_f:1,to_hash:1,to_i:1,to_int:1,to_io:1,to_proc:1,to_s:1,to_str:1,to_sym:1,tr:1,"tr!":1,tr_s:1,"tr_s!":1,trace_var:1,transpose:1,trap:1,truncate:1,"tty?":1,type:1,ungetc:1,uniq:1,"uniq!":1,unpack:1,unshift:1,untaint:1,untrace_var:1,upcase:1,"upcase!":1,update:1,upto:1,"value?":1,values:1,values_at:1,warn:1,write:1,write_nonblock:1,"zero?":1,zip:1}};var h={cN:"yardoctag",b:"@[A-Za-z]+"};var d={cN:"comment",b:"#",e:"$",c:[h]};var c={cN:"comment",b:"^\\=begin",e:"^\\=end",c:[h],r:10};var b={cN:"comment",b:"^__END__",e:"\\n$"};var u={cN:"subst",b:"#\\{",e:"}",l:g,k:n};var p=[hljs.BE,u];var s={cN:"string",b:"'",e:"'",c:p,r:0};var r={cN:"string",b:'"',e:'"',c:p,r:0};var q={cN:"string",b:"%[qw]?\\(",e:"\\)",c:p,r:10};var o={cN:"string",b:"%[qw]?\\[",e:"\\]",c:p,r:10};var m={cN:"string",b:"%[qw]?{",e:"}",c:p,r:10};var l={cN:"string",b:"%[qw]?<",e:">",c:p,r:10};var k={cN:"string",b:"%[qw]?/",e:"/",c:p,r:10};var j={cN:"string",b:"%[qw]?%",e:"%",c:p,r:10};var i={cN:"string",b:"%[qw]?-",e:"-",c:p,r:10};var t={cN:"string",b:"%[qw]?\\|",e:"\\|",c:p,r:10};var e={cN:"function",b:"\\bdef\\s+",e:" |$|;",l:g,k:n,c:[{cN:"title",b:a,l:g,k:n},{cN:"params",b:"\\(",e:"\\)",l:g,k:n},d,c,b]};var f={cN:"identifier",b:g,l:g,k:n,r:0};var v=[d,c,b,s,r,q,o,m,l,k,j,i,t,{cN:"class",b:"\\b(class|module)\\b",e:"$|;",k:{"class":1,module:1},c:[{cN:"title",b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?",r:0},{cN:"inheritance",b:"<\\s*",c:[{cN:"parent",b:"("+hljs.IR+"::)?"+hljs.IR}]},d,c,b]},e,{cN:"constant",b:"(::)?([A-Z]\\w*(::)?)+",r:0},{cN:"symbol",b:":",c:[s,r,q,o,m,l,k,j,i,t,f],r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{cN:"number",b:"\\?\\w"},{cN:"variable",b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},f,{b:"("+hljs.RSR+")\\s*",c:[d,c,b,{cN:"regexp",b:"/",e:"/[a-z]*",i:"\\n",c:[hljs.BE]}],r:0}];u.c=v;e.c[1].c=v;return{dM:{l:g,k:n,c:v}}}();hljs.LANGUAGES.javascript={dM:{k:{keyword:{"in":1,"if":1,"for":1,"while":1,"finally":1,"var":1,"new":1,"function":1,"do":1,"return":1,"void":1,"else":1,"break":1,"catch":1,"instanceof":1,"with":1,"throw":1,"case":1,"default":1,"try":1,"this":1,"switch":1,"continue":1,"typeof":1,"delete":1},literal:{"true":1,"false":1,"null":1}},c:[hljs.ASM,hljs.QSM,hljs.CLCM,hljs.CBLCLM,hljs.CNM,{b:"("+hljs.RSR+"|case|return|throw)\\s*",k:{"return":1,"throw":1,"case":1},c:[hljs.CLCM,hljs.CBLCLM,{cN:"regexp",b:"/.*?[^\\\\/]/[gim]*"}],r:0},{cN:"function",b:"\\bfunction\\b",e:"{",k:{"function":1},c:[{cN:"title",b:"[A-Za-z$_][0-9A-Za-z$_]*"},{cN:"params",b:"\\(",e:"\\)",c:[hljs.ASM,hljs.QSM,hljs.CLCM,hljs.CBLCLM]}]}]}};hljs.LANGUAGES.css=function(){var a={cN:"function",b:hljs.IR+"\\(",e:"\\)",c:[{eW:true,eE:true,c:[hljs.NM,hljs.ASM,hljs.QSM]}]};return{cI:true,dM:{i:"[=/|']",c:[hljs.CBLCLM,{cN:"id",b:"\\#[A-Za-z0-9_-]+"},{cN:"class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"attr_selector",b:"\\[",e:"\\]",i:"$"},{cN:"pseudo",b:":(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\\"\\']+"},{cN:"at_rule",b:"@font-face",l:"[a-z-]+",k:{"font-face":1}},{cN:"at_rule",b:"@",e:"[{;]",eE:true,k:{"import":1,page:1,media:1,charset:1},c:[a,hljs.ASM,hljs.QSM,hljs.NM]},{cN:"tag",b:hljs.IR,r:0},{cN:"rules",b:"{",e:"}",i:"[^\\s]",r:0,c:[hljs.CBLCLM,{cN:"rule",b:"[^\\s]",rB:true,e:";",eW:true,c:[{cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:true,i:"[^\\s]",starts:{cN:"value",eW:true,eE:true,c:[a,hljs.NM,hljs.QSM,hljs.ASM,hljs.CBLCLM,{cN:"hexcolor",b:"\\#[0-9A-F]+"},{cN:"important",b:"!important"}]}}]}]}]}}}();hljs.LANGUAGES.xml=function(){var b="[A-Za-z0-9\\._:-]+";var a={eW:true,c:[{cN:"attribute",b:b,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,dM:{c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"",r:10},{cN:"comment",b:"",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"",k:{title:{style:1}},c:[a],starts:{cN:"css",e:"",rE:true,sL:"css"}},{cN:"tag",b:"",k:{title:{script:1}},c:[a],starts:{cN:"javascript",e:"<\/script>",rE:true,sL:"javascript"}},{cN:"vbscript",b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"",c:[{cN:"title",b:"[^ />]+"},a]}]}}}();hljs.LANGUAGES.cpp=function(){var b={keyword:{"false":1,"int":1,"float":1,"while":1,"private":1,"char":1,"catch":1,"export":1,virtual:1,operator:2,sizeof:2,dynamic_cast:2,typedef:2,const_cast:2,"const":1,struct:1,"for":1,static_cast:2,union:1,namespace:1,unsigned:1,"long":1,"throw":1,"volatile":2,"static":1,"protected":1,bool:1,template:1,mutable:1,"if":1,"public":1,friend:2,"do":1,"return":1,"goto":1,auto:1,"void":2,"enum":1,"else":1,"break":1,"new":1,extern:1,using:1,"true":1,"class":1,asm:1,"case":1,typeid:1,"short":1,reinterpret_cast:2,"default":1,"double":1,register:1,explicit:1,signed:1,typename:1,"try":1,"this":1,"switch":1,"continue":1,wchar_t:1,inline:1,"delete":1,alignof:1,char16_t:1,char32_t:1,constexpr:1,decltype:1,noexcept:1,nullptr:1,static_assert:1,thread_local:1},built_in:{std:1,string:1,cin:1,cout:1,cerr:1,clog:1,stringstream:1,istringstream:1,ostringstream:1,auto_ptr:1,deque:1,list:1,queue:1,stack:1,vector:1,map:1,set:1,bitset:1,multiset:1,multimap:1,unordered_set:1,unordered_map:1,unordered_multiset:1,unordered_multimap:1,array:1,shared_ptr:1}};var a={cN:"stl_container",b:"\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<",e:">",k:b.built_in,r:10};a.c=[a];return{dM:{k:b,i:""}while(x.length||y.length){var u=t().splice(0,1)[0];v+=l(w.substr(q,u.offset-q));q=u.offset;if(u.event=="start"){v+=r(u.node);s.push(u.node)}else{if(u.event=="stop"){var p=s.length;do{p--;var o=s[p];v+=("")}while(o!=u.node);s.splice(p,1);while(p'+l(K[0])+""}else{M+=l(K[0])}O=N.lR.lastIndex;K=N.lR.exec(L)}M+=l(L.substr(O,L.length-O));return M}function J(r,L){if(L.sL&&d[L.sL]){var K=f(L.sL,r);s+=K.keyword_count;return K.value}else{return E(r,L)}}function H(L,r){var K=L.cN?'':"";if(L.rB){p+=K;L.buffer=""}else{if(L.eB){p+=l(r)+K;L.buffer=""}else{p+=K;L.buffer=r}}B.push(L);A+=L.r}function D(N,K,P){var Q=B[B.length-1];if(P){p+=J(Q.buffer+N,Q);return false}var L=y(K,Q);if(L){p+=J(Q.buffer+N,Q);H(L,K);return L.rB}var r=v(B.length-1,K);if(r){var M=Q.cN?"":"";if(Q.rE){p+=J(Q.buffer+N,Q)+M}else{if(Q.eE){p+=J(Q.buffer+N,Q)+M+l(K)}else{p+=J(Q.buffer+N+K,Q)+M}}while(r>1){M=B[B.length-2].cN?"":"";p+=M;r--;B.length--}var O=B[B.length-1];B.length--;B[B.length-1].buffer="";if(O.starts){H(O.starts,"")}return Q.rE}if(w(K,Q)){throw"Illegal"}}var G=d[I];var B=[G.dM];var A=0;var s=0;var p="";try{var u=0;G.dM.buffer="";do{var x=q(C,u);var t=D(x[0],x[1],x[2]);u+=x[0].length;if(!t){u+=x[1].length}}while(!x[2]);if(B.length>1){throw"Illegal"}return{language:I,r:A,keyword_count:s,value:p}}catch(F){if(F=="Illegal"){return{language:null,r:0,keyword_count:0,value:l(C)}}else{throw F}}}function h(){function o(t,s,u){if(t.compiled){return}if(!u){t.bR=c(s,t.b?t.b:"\\B|\\b");if(!t.e&&!t.eW){t.e="\\B|\\b"}if(t.e){t.eR=c(s,t.e)}}if(t.i){t.iR=c(s,t.i)}if(t.r==undefined){t.r=1}if(t.k){t.lR=c(s,t.l||hljs.IR,true)}for(var r in t.k){if(!t.k.hasOwnProperty(r)){continue}if(t.k[r] instanceof Object){t.kG=t.k}else{t.kG={keyword:t.k}}break}if(!t.c){t.c=[]}t.compiled=true;for(var q=0;qx.keyword_count+x.r){x=u}if(u.keyword_count+u.r>w.keyword_count+w.r){x=w;w=u}}}var s=t.className;if(!s.match(w.language)){s=s?(s+" "+w.language):w.language}var o=b(t);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=k(o,b(q),A)}if(y){w.value=w.value.replace(/^((<[^>]+>|\t)+)/gm,function(B,E,D,C){return E.replace(/\t/g,y)})}if(p){w.value=w.value.replace(/\n/g,"
")}if(/MSIE [678]/.test(navigator.userAgent)&&t.tagName=="CODE"&&t.parentNode.tagName=="PRE"){var q=t.parentNode;var v=document.createElement("div");v.innerHTML="
"+w.value+"
";t=v.firstChild.firstChild;v.firstChild.cN=q.cN;q.parentNode.replaceChild(v.firstChild,q)}else{t.innerHTML=w.value}t.className=s;t.dataset={};t.dataset.result={language:w.language,kw:w.keyword_count,re:w.r};if(x&&x.language){t.dataset.second_best={language:x.language,kw:x.keyword_count,re:x.r}}}function j(){if(j.called){return}j.called=true;e();var q=document.getElementsByTagName("pre");for(var o=0;o|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\.",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.inherit=function(o,r){var q={};for(var p in o){q[p]=o[p]}if(r){for(var p in r){q[p]=r[p]}}return q}}();hljs.LANGUAGES.ruby=function(){var g="[a-zA-Z_][a-zA-Z0-9_]*(\\!|\\?)?";var a="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?";var n={keyword:{and:1,"false":1,then:1,defined:1,module:1,"in":1,"return":1,redo:1,"if":1,BEGIN:1,retry:1,end:1,"for":1,"true":1,self:1,when:1,next:1,until:1,"do":1,begin:1,unless:1,END:1,rescue:1,nil:1,"else":1,"break":1,undef:1,not:1,"super":1,"class":1,"case":1,require:1,yield:1,alias:1,"while":1,ensure:1,elsif:1,or:1,def:1},keymethods:{__id__:1,__send__:1,abort:1,abs:1,"all?":1,allocate:1,ancestors:1,"any?":1,arity:1,assoc:1,at:1,at_exit:1,autoload:1,"autoload?":1,"between?":1,binding:1,binmode:1,"block_given?":1,call:1,callcc:1,caller:1,capitalize:1,"capitalize!":1,casecmp:1,"catch":1,ceil:1,center:1,chomp:1,"chomp!":1,chop:1,"chop!":1,chr:1,"class":1,class_eval:1,"class_variable_defined?":1,class_variables:1,clear:1,clone:1,close:1,close_read:1,close_write:1,"closed?":1,coerce:1,collect:1,"collect!":1,compact:1,"compact!":1,concat:1,"const_defined?":1,const_get:1,const_missing:1,const_set:1,constants:1,count:1,crypt:1,"default":1,default_proc:1,"delete":1,"delete!":1,delete_at:1,delete_if:1,detect:1,display:1,div:1,divmod:1,downcase:1,"downcase!":1,downto:1,dump:1,dup:1,each:1,each_byte:1,each_index:1,each_key:1,each_line:1,each_pair:1,each_value:1,each_with_index:1,"empty?":1,entries:1,eof:1,"eof?":1,"eql?":1,"equal?":1,"eval":1,exec:1,exit:1,"exit!":1,extend:1,fail:1,fcntl:1,fetch:1,fileno:1,fill:1,find:1,find_all:1,first:1,flatten:1,"flatten!":1,floor:1,flush:1,for_fd:1,foreach:1,fork:1,format:1,freeze:1,"frozen?":1,fsync:1,getc:1,gets:1,global_variables:1,grep:1,gsub:1,"gsub!":1,"has_key?":1,"has_value?":1,hash:1,hex:1,id:1,include:1,"include?":1,included_modules:1,index:1,indexes:1,indices:1,induced_from:1,inject:1,insert:1,inspect:1,instance_eval:1,instance_method:1,instance_methods:1,"instance_of?":1,"instance_variable_defined?":1,instance_variable_get:1,instance_variable_set:1,instance_variables:1,"integer?":1,intern:1,invert:1,ioctl:1,"is_a?":1,isatty:1,"iterator?":1,join:1,"key?":1,keys:1,"kind_of?":1,lambda:1,last:1,length:1,lineno:1,ljust:1,load:1,local_variables:1,loop:1,lstrip:1,"lstrip!":1,map:1,"map!":1,match:1,max:1,"member?":1,merge:1,"merge!":1,method:1,"method_defined?":1,method_missing:1,methods:1,min:1,module_eval:1,modulo:1,name:1,nesting:1,"new":1,next:1,"next!":1,"nil?":1,nitems:1,"nonzero?":1,object_id:1,oct:1,open:1,pack:1,partition:1,pid:1,pipe:1,pop:1,popen:1,pos:1,prec:1,prec_f:1,prec_i:1,print:1,printf:1,private_class_method:1,private_instance_methods:1,"private_method_defined?":1,private_methods:1,proc:1,protected_instance_methods:1,"protected_method_defined?":1,protected_methods:1,public_class_method:1,public_instance_methods:1,"public_method_defined?":1,public_methods:1,push:1,putc:1,puts:1,quo:1,raise:1,rand:1,rassoc:1,read:1,read_nonblock:1,readchar:1,readline:1,readlines:1,readpartial:1,rehash:1,reject:1,"reject!":1,remainder:1,reopen:1,replace:1,require:1,"respond_to?":1,reverse:1,"reverse!":1,reverse_each:1,rewind:1,rindex:1,rjust:1,round:1,rstrip:1,"rstrip!":1,scan:1,seek:1,select:1,send:1,set_trace_func:1,shift:1,singleton_method_added:1,singleton_methods:1,size:1,sleep:1,slice:1,"slice!":1,sort:1,"sort!":1,sort_by:1,split:1,sprintf:1,squeeze:1,"squeeze!":1,srand:1,stat:1,step:1,store:1,strip:1,"strip!":1,sub:1,"sub!":1,succ:1,"succ!":1,sum:1,superclass:1,swapcase:1,"swapcase!":1,sync:1,syscall:1,sysopen:1,sysread:1,sysseek:1,system:1,syswrite:1,taint:1,"tainted?":1,tell:1,test:1,"throw":1,times:1,to_a:1,to_ary:1,to_f:1,to_hash:1,to_i:1,to_int:1,to_io:1,to_proc:1,to_s:1,to_str:1,to_sym:1,tr:1,"tr!":1,tr_s:1,"tr_s!":1,trace_var:1,transpose:1,trap:1,truncate:1,"tty?":1,type:1,ungetc:1,uniq:1,"uniq!":1,unpack:1,unshift:1,untaint:1,untrace_var:1,upcase:1,"upcase!":1,update:1,upto:1,"value?":1,values:1,values_at:1,warn:1,write:1,write_nonblock:1,"zero?":1,zip:1}};var h={cN:"yardoctag",b:"@[A-Za-z]+"};var d={cN:"comment",b:"#",e:"$",c:[h]};var c={cN:"comment",b:"^\\=begin",e:"^\\=end",c:[h],r:10};var b={cN:"comment",b:"^__END__",e:"\\n$"};var u={cN:"subst",b:"#\\{",e:"}",l:g,k:n};var p=[hljs.BE,u];var s={cN:"string",b:"'",e:"'",c:p,r:0};var r={cN:"string",b:'"',e:'"',c:p,r:0};var q={cN:"string",b:"%[qw]?\\(",e:"\\)",c:p,r:10};var o={cN:"string",b:"%[qw]?\\[",e:"\\]",c:p,r:10};var m={cN:"string",b:"%[qw]?{",e:"}",c:p,r:10};var l={cN:"string",b:"%[qw]?<",e:">",c:p,r:10};var k={cN:"string",b:"%[qw]?/",e:"/",c:p,r:10};var j={cN:"string",b:"%[qw]?%",e:"%",c:p,r:10};var i={cN:"string",b:"%[qw]?-",e:"-",c:p,r:10};var t={cN:"string",b:"%[qw]?\\|",e:"\\|",c:p,r:10};var e={cN:"function",b:"\\bdef\\s+",e:" |$|;",l:g,k:n,c:[{cN:"title",b:a,l:g,k:n},{cN:"params",b:"\\(",e:"\\)",l:g,k:n},d,c,b]};var f={cN:"identifier",b:g,l:g,k:n,r:0};var v=[d,c,b,s,r,q,o,m,l,k,j,i,t,{cN:"class",b:"\\b(class|module)\\b",e:"$|;",k:{"class":1,module:1},c:[{cN:"title",b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?",r:0},{cN:"inheritance",b:"<\\s*",c:[{cN:"parent",b:"("+hljs.IR+"::)?"+hljs.IR}]},d,c,b]},e,{cN:"constant",b:"(::)?([A-Z]\\w*(::)?)+",r:0},{cN:"symbol",b:":",c:[s,r,q,o,m,l,k,j,i,t,f],r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{cN:"number",b:"\\?\\w"},{cN:"variable",b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},f,{b:"("+hljs.RSR+")\\s*",c:[d,c,b,{cN:"regexp",b:"/",e:"/[a-z]*",i:"\\n",c:[hljs.BE]}],r:0}];u.c=v;e.c[1].c=v;return{dM:{l:g,k:n,c:v}}}();hljs.LANGUAGES.javascript={dM:{k:{keyword:{"in":1,"if":1,"for":1,"while":1,"finally":1,"var":1,"new":1,"function":1,"do":1,"return":1,"void":1,"else":1,"break":1,"catch":1,"instanceof":1,"with":1,"throw":1,"case":1,"default":1,"try":1,"this":1,"switch":1,"continue":1,"typeof":1,"delete":1},literal:{"true":1,"false":1,"null":1}},c:[hljs.ASM,hljs.QSM,hljs.CLCM,hljs.CBLCLM,hljs.CNM,{b:"("+hljs.RSR+"|case|return|throw)\\s*",k:{"return":1,"throw":1,"case":1},c:[hljs.CLCM,hljs.CBLCLM,{cN:"regexp",b:"/.*?[^\\\\/]/[gim]*"}],r:0},{cN:"function",b:"\\bfunction\\b",e:"{",k:{"function":1},c:[{cN:"title",b:"[A-Za-z$_][0-9A-Za-z$_]*"},{cN:"params",b:"\\(",e:"\\)",c:[hljs.ASM,hljs.QSM,hljs.CLCM,hljs.CBLCLM]}]}]}};hljs.LANGUAGES.css=function(){var a={cN:"function",b:hljs.IR+"\\(",e:"\\)",c:[{eW:true,eE:true,c:[hljs.NM,hljs.ASM,hljs.QSM]}]};return{cI:true,dM:{i:"[=/|']",c:[hljs.CBLCLM,{cN:"id",b:"\\#[A-Za-z0-9_-]+"},{cN:"class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"attr_selector",b:"\\[",e:"\\]",i:"$"},{cN:"pseudo",b:":(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\\"\\']+"},{cN:"at_rule",b:"@font-face",l:"[a-z-]+",k:{"font-face":1}},{cN:"at_rule",b:"@",e:"[{;]",eE:true,k:{"import":1,page:1,media:1,charset:1},c:[a,hljs.ASM,hljs.QSM,hljs.NM]},{cN:"tag",b:hljs.IR,r:0},{cN:"rules",b:"{",e:"}",i:"[^\\s]",r:0,c:[hljs.CBLCLM,{cN:"rule",b:"[^\\s]",rB:true,e:";",eW:true,c:[{cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:true,i:"[^\\s]",starts:{cN:"value",eW:true,eE:true,c:[a,hljs.NM,hljs.QSM,hljs.ASM,hljs.CBLCLM,{cN:"hexcolor",b:"\\#[0-9A-F]+"},{cN:"important",b:"!important"}]}}]}]}]}}}();hljs.LANGUAGES.xml=function(){var b="[A-Za-z0-9\\._:-]+";var a={eW:true,c:[{cN:"attribute",b:b,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,dM:{c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"",r:10},{cN:"comment",b:"",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"",k:{title:{style:1}},c:[a],starts:{cN:"css",e:"",rE:true,sL:"css"}},{cN:"tag",b:"",k:{title:{script:1}},c:[a],starts:{cN:"javascript",e:"<\/script>",rE:true,sL:"javascript"}},{cN:"vbscript",b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"",c:[{cN:"title",b:"[^ />]+"},a]}]}}}();hljs.LANGUAGES.cpp=function(){var b={keyword:{"false":1,"int":1,"float":1,"while":1,"private":1,"char":1,"catch":1,"export":1,virtual:1,operator:2,sizeof:2,dynamic_cast:2,typedef:2,const_cast:2,"const":1,struct:1,"for":1,static_cast:2,union:1,namespace:1,unsigned:1,"long":1,"throw":1,"volatile":2,"static":1,"protected":1,bool:1,template:1,mutable:1,"if":1,"public":1,friend:2,"do":1,"return":1,"goto":1,auto:1,"void":2,"enum":1,"else":1,"break":1,"new":1,extern:1,using:1,"true":1,"class":1,asm:1,"case":1,typeid:1,"short":1,reinterpret_cast:2,"default":1,"double":1,register:1,explicit:1,signed:1,typename:1,"try":1,"this":1,"switch":1,"continue":1,wchar_t:1,inline:1,"delete":1,alignof:1,char16_t:1,char32_t:1,constexpr:1,decltype:1,noexcept:1,nullptr:1,static_assert:1,thread_local:1},built_in:{std:1,string:1,cin:1,cout:1,cerr:1,clog:1,stringstream:1,istringstream:1,ostringstream:1,auto_ptr:1,deque:1,list:1,queue:1,stack:1,vector:1,map:1,set:1,bitset:1,multiset:1,multimap:1,unordered_set:1,unordered_map:1,unordered_multiset:1,unordered_multimap:1,array:1,shared_ptr:1}};var a={cN:"stl_container",b:"\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<",e:">",k:b.built_in,r:10};a.c=[a];return{dM:{k:b,i:" viewHeight) { 127 | view.scrollTop = offset - viewHeight + height; 128 | } 129 | if (offset < viewScroll) { 130 | view.scrollTop = offset; 131 | } 132 | } 133 | 134 | // panel.js ----------------------------------------------- 135 | 136 | Searchdoc.Panel = function(element, data, tree, frame) { 137 | this.$element = $(element); 138 | this.$input = $('input', element).eq(0); 139 | this.$result = $('.result ul', element).eq(0); 140 | this.frame = frame; 141 | this.$current = null; 142 | this.$view = this.$result.parent(); 143 | this.data = data; 144 | this.searcher = new Searcher(data.index); 145 | this.tree = new Searchdoc.Tree($('.tree', element), tree, this); 146 | this.init(); 147 | } 148 | 149 | Searchdoc.Panel.prototype = $.extend({}, Searchdoc.Navigation, new function() { 150 | var suid = 1; 151 | 152 | this.init = function() { 153 | var _this = this; 154 | var observer = function() { 155 | _this.search(_this.$input[0].value); 156 | }; 157 | this.$input.keyup(observer); 158 | this.$input.click(observer); // mac's clear field 159 | 160 | this.searcher.ready(function(results, isLast) { 161 | _this.addResults(results, isLast); 162 | }) 163 | 164 | this.$result.click(function(e) { 165 | _this.$current.removeClass('current'); 166 | _this.$current = $(e.target).closest('li').addClass('current'); 167 | _this.select(); 168 | _this.$input.focus(); 169 | }); 170 | 171 | this.initNavigation(); 172 | this.setNavigationActive(false); 173 | } 174 | 175 | this.search = function(value, selectFirstMatch) { 176 | value = jQuery.trim(value).toLowerCase(); 177 | this.selectFirstMatch = selectFirstMatch; 178 | if (value) { 179 | this.$element.removeClass('panel_tree').addClass('panel_results'); 180 | this.tree.setNavigationActive(false); 181 | this.setNavigationActive(true); 182 | } else { 183 | this.$element.addClass('panel_tree').removeClass('panel_results'); 184 | this.tree.setNavigationActive(true); 185 | this.setNavigationActive(false); 186 | } 187 | if (value != this.lastQuery) { 188 | this.lastQuery = value; 189 | this.firstRun = true; 190 | this.searcher.find(value); 191 | } 192 | } 193 | 194 | this.addResults = function(results, isLast) { 195 | var target = this.$result.get(0); 196 | if (this.firstRun && (results.length > 0 || isLast)) { 197 | this.$current = null; 198 | this.$result.empty(); 199 | } 200 | for (var i=0, l = results.length; i < l; i++) { 201 | target.appendChild(renderItem.call(this, results[i])); 202 | }; 203 | if (this.firstRun && results.length > 0) { 204 | this.firstRun = false; 205 | this.$current = $(target.firstChild); 206 | this.$current.addClass('current'); 207 | if (this.selectFirstMatch) this.select(); 208 | scrollIntoView(this.$current[0], this.$view[0]) 209 | } 210 | if (jQuery.browser.msie) this.$element[0].className += ''; 211 | } 212 | 213 | this.open = function(src) { 214 | this.frame.location.href = '../' + src; 215 | if (this.frame.highlight) this.frame.highlight(src); 216 | } 217 | 218 | this.select = function() { 219 | this.open(this.$current.data('path')); 220 | } 221 | 222 | this.move = function(isDown) { 223 | if (!this.$current) return; 224 | var $next = this.$current[isDown ? 'next' : 'prev'](); 225 | if ($next.length) { 226 | this.$current.removeClass('current'); 227 | $next.addClass('current'); 228 | scrollIntoView($next[0], this.$view[0]); 229 | this.$current = $next; 230 | } 231 | return true; 232 | } 233 | 234 | function renderItem(result) { 235 | var li = document.createElement('li'), 236 | html = '', badge = result.badge; 237 | html += '

' + hlt(result.title); 238 | if (result.params) html += '' + result.params + ''; 239 | html += '

'; 240 | html += '

'; 241 | if (typeof badge != 'undefined') { 242 | html += '' + escapeHTML(this.data.badges[badge] || 'unknown') + ''; 243 | } 244 | html += hlt(result.namespace) + '

'; 245 | if (result.snippet) html += '

' + escapeHTML(result.snippet) + '

'; 246 | li.innerHTML = html; 247 | jQuery.data(li, 'path', result.path); 248 | return li; 249 | } 250 | 251 | function hlt(html) { 252 | return escapeHTML(html).replace(/\u0001/g, '').replace(/\u0002/g, '') 253 | } 254 | 255 | function escapeHTML(html) { 256 | return html.replace(/[&<>]/g, function(c) { 257 | return '&#' + c.charCodeAt(0) + ';'; 258 | }); 259 | } 260 | 261 | }); 262 | 263 | // tree.js ------------------------------------------------ 264 | 265 | Searchdoc.Tree = function(element, tree, panel) { 266 | this.$element = $(element); 267 | this.$list = $('ul', element); 268 | this.tree = tree; 269 | this.panel = panel; 270 | this.init(); 271 | } 272 | 273 | Searchdoc.Tree.prototype = $.extend({}, Searchdoc.Navigation, new function() { 274 | this.init = function() { 275 | var stopper = document.createElement('li'); 276 | stopper.className = 'stopper'; 277 | this.$list[0].appendChild(stopper); 278 | for (var i=0, l = this.tree.length; i < l; i++) { 279 | buildAndAppendItem.call(this, this.tree[i], 0, stopper); 280 | }; 281 | var _this = this; 282 | this.$list.click(function(e) { 283 | var $target = $(e.target), 284 | $li = $target.closest('li'); 285 | if ($target.hasClass('icon')) { 286 | _this.toggle($li); 287 | } else { 288 | _this.select($li); 289 | } 290 | }) 291 | 292 | this.initNavigation(); 293 | if (jQuery.browser.msie) document.body.className += ''; 294 | } 295 | 296 | this.select = function($li) { 297 | this.highlight($li); 298 | var path = $li[0].searchdoc_tree_data.path; 299 | if (path) this.panel.open(path); 300 | } 301 | 302 | this.highlight = function($li) { 303 | if (this.$current) this.$current.removeClass('current'); 304 | this.$current = $li.addClass('current'); 305 | } 306 | 307 | this.toggle = function($li) { 308 | var closed = !$li.hasClass('closed'), 309 | children = $li[0].searchdoc_tree_data.children; 310 | $li.toggleClass('closed'); 311 | for (var i=0, l = children.length; i < l; i++) { 312 | toggleVis.call(this, $(children[i].li), !closed); 313 | }; 314 | } 315 | 316 | this.moveRight = function() { 317 | if (!this.$current) { 318 | this.highlight(this.$list.find('li:first')); 319 | return; 320 | } 321 | if (this.$current.hasClass('closed')) { 322 | this.toggle(this.$current); 323 | } 324 | } 325 | 326 | this.moveLeft = function() { 327 | if (!this.$current) { 328 | this.highlight(this.$list.find('li:first')); 329 | return; 330 | } 331 | if (!this.$current.hasClass('closed')) { 332 | this.toggle(this.$current); 333 | } else { 334 | var level = this.$current[0].searchdoc_tree_data.level; 335 | if (level == 0) return; 336 | var $next = this.$current.prevAll('li.level_' + (level - 1) + ':visible:first'); 337 | this.$current.removeClass('current'); 338 | $next.addClass('current'); 339 | scrollIntoView($next[0], this.$element[0]); 340 | this.$current = $next; 341 | } 342 | } 343 | 344 | this.move = function(isDown) { 345 | if (!this.$current) { 346 | this.highlight(this.$list.find('li:first')); 347 | return true; 348 | } 349 | var next = this.$current[0]; 350 | if (isDown) { 351 | do { 352 | next = next.nextSibling; 353 | if (next && next.style && next.style.display != 'none') break; 354 | } while(next); 355 | } else { 356 | do { 357 | next = next.previousSibling; 358 | if (next && next.style && next.style.display != 'none') break; 359 | } while(next); 360 | } 361 | if (next && next.className.indexOf('stopper') == -1) { 362 | this.$current.removeClass('current'); 363 | $(next).addClass('current'); 364 | scrollIntoView(next, this.$element[0]); 365 | this.$current = $(next); 366 | } 367 | return true; 368 | } 369 | 370 | function toggleVis($li, show) { 371 | var closed = $li.hasClass('closed'), 372 | children = $li[0].searchdoc_tree_data.children; 373 | $li.css('display', show ? '' : 'none') 374 | if (!show && this.$current && $li[0] == this.$current[0]) { 375 | this.$current.removeClass('current'); 376 | this.$current = null; 377 | } 378 | for (var i=0, l = children.length; i < l; i++) { 379 | toggleVis.call(this, $(children[i].li), show && !closed); 380 | }; 381 | } 382 | 383 | function buildAndAppendItem(item, level, before) { 384 | var li = renderItem(item, level), 385 | list = this.$list[0]; 386 | item.li = li; 387 | list.insertBefore(li, before); 388 | for (var i=0, l = item[3].length; i < l; i++) { 389 | buildAndAppendItem.call(this, item[3][i], level + 1, before); 390 | }; 391 | return li; 392 | } 393 | 394 | function renderItem(item, level) { 395 | var li = document.createElement('li'), 396 | cnt = document.createElement('div'), 397 | h1 = document.createElement('h1'), 398 | p = document.createElement('p'), 399 | icon, i; 400 | 401 | li.appendChild(cnt); 402 | li.style.paddingLeft = getOffset(level); 403 | cnt.className = 'content'; 404 | if (!item[1]) li.className = 'empty '; 405 | cnt.appendChild(h1); 406 | // cnt.appendChild(p); 407 | h1.appendChild(document.createTextNode(item[0])); 408 | // p.appendChild(document.createTextNode(item[4])); 409 | if (item[2]) { 410 | i = document.createElement('i'); 411 | i.appendChild(document.createTextNode(item[2])); 412 | h1.appendChild(i); 413 | } 414 | if (item[3].length > 0) { 415 | icon = document.createElement('div'); 416 | icon.className = 'icon'; 417 | cnt.appendChild(icon); 418 | } 419 | 420 | // user direct assignement instead of $() 421 | // it's 8x faster 422 | // $(li).data('path', item[1]) 423 | // .data('children', item[3]) 424 | // .data('level', level) 425 | // .css('display', level == 0 ? '' : 'none') 426 | // .addClass('level_' + level) 427 | // .addClass('closed'); 428 | li.searchdoc_tree_data = { 429 | path: item[1], 430 | children: item[3], 431 | level: level 432 | } 433 | li.style.display = level == 0 ? '' : 'none'; 434 | li.className += 'level_' + level + ' closed'; 435 | return li; 436 | } 437 | 438 | function getOffset(level) { 439 | return 5 + 18*level + 'px'; 440 | } 441 | }); 442 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/resources/js/searchdoc.js: -------------------------------------------------------------------------------- 1 | Searchdoc = {}; 2 | 3 | // navigation.js ------------------------------------------ 4 | 5 | Searchdoc.Navigation = new function() { 6 | this.initNavigation = function() { 7 | var _this = this; 8 | 9 | $(document).keydown(function(e) { 10 | _this.onkeydown(e); 11 | }).keyup(function(e) { 12 | _this.onkeyup(e); 13 | }); 14 | 15 | this.navigationActive = true; 16 | } 17 | 18 | this.setNavigationActive = function(state) { 19 | this.navigationActive = state; 20 | this.clearMoveTimeout(); 21 | } 22 | 23 | 24 | this.onkeyup = function(e) { 25 | if (!this.navigationActive) return; 26 | switch(e.keyCode) { 27 | case 37: //Event.KEY_LEFT: 28 | case 38: //Event.KEY_UP: 29 | case 39: //Event.KEY_RIGHT: 30 | case 40: //Event.KEY_DOWN: 31 | case 73: // i - qwerty 32 | case 74: // j 33 | case 75: // k 34 | case 76: // l 35 | case 67: // c - dvorak 36 | case 72: // h 37 | case 84: // t 38 | case 78: // n 39 | this.clearMoveTimeout(); 40 | break; 41 | } 42 | } 43 | 44 | this.onkeydown = function(e) { 45 | if (!this.navigationActive) return; 46 | switch(e.keyCode) { 47 | case 37: //Event.KEY_LEFT: 48 | case 74: // j (qwerty) 49 | case 72: // h (dvorak) 50 | if (this.moveLeft()) e.preventDefault(); 51 | break; 52 | case 38: //Event.KEY_UP: 53 | case 73: // i (qwerty) 54 | case 67: // c (dvorak) 55 | if (e.keyCode == 38 || e.ctrlKey) { 56 | if (this.moveUp()) e.preventDefault(); 57 | this.startMoveTimeout(false); 58 | } 59 | break; 60 | case 39: //Event.KEY_RIGHT: 61 | case 76: // l (qwerty) 62 | case 78: // n (dvorak) 63 | if (this.moveRight()) e.preventDefault(); 64 | break; 65 | case 40: //Event.KEY_DOWN: 66 | case 75: // k (qwerty) 67 | case 84: // t (dvorak) 68 | if (e.keyCode == 40 || e.ctrlKey) { 69 | if (this.moveDown()) e.preventDefault(); 70 | this.startMoveTimeout(true); 71 | } 72 | break; 73 | case 9: //Event.KEY_TAB: 74 | case 13: //Event.KEY_RETURN: 75 | if (this.$current) this.select(this.$current); 76 | break; 77 | } 78 | if (e.ctrlKey && e.shiftKey) this.select(this.$current); 79 | } 80 | 81 | this.clearMoveTimeout = function() { 82 | clearTimeout(this.moveTimeout); 83 | this.moveTimeout = null; 84 | } 85 | 86 | this.startMoveTimeout = function(isDown) { 87 | if (!$.browser.mozilla && !$.browser.opera) return; 88 | if (this.moveTimeout) this.clearMoveTimeout(); 89 | var _this = this; 90 | 91 | var go = function() { 92 | if (!_this.moveTimeout) return; 93 | _this[isDown ? 'moveDown' : 'moveUp'](); 94 | _this.moveTimout = setTimeout(go, 100); 95 | } 96 | this.moveTimeout = setTimeout(go, 200); 97 | } 98 | 99 | this.moveRight = function() { 100 | } 101 | 102 | this.moveLeft = function() { 103 | } 104 | 105 | this.move = function(isDown) { 106 | } 107 | 108 | this.moveUp = function() { 109 | return this.move(false); 110 | } 111 | 112 | this.moveDown = function() { 113 | return this.move(true); 114 | } 115 | } 116 | 117 | 118 | // scrollIntoView.js -------------------------------------- 119 | 120 | function scrollIntoView(element, view) { 121 | var offset, viewHeight, viewScroll, height; 122 | offset = element.offsetTop; 123 | height = element.offsetHeight; 124 | viewHeight = view.offsetHeight; 125 | viewScroll = view.scrollTop; 126 | if (offset - viewScroll + height > viewHeight) { 127 | view.scrollTop = offset - viewHeight + height; 128 | } 129 | if (offset < viewScroll) { 130 | view.scrollTop = offset; 131 | } 132 | } 133 | 134 | // panel.js ----------------------------------------------- 135 | 136 | Searchdoc.Panel = function(element, data, tree, frame) { 137 | this.$element = $(element); 138 | this.$input = $('input', element).eq(0); 139 | this.$result = $('.result ul', element).eq(0); 140 | this.frame = frame; 141 | this.$current = null; 142 | this.$view = this.$result.parent(); 143 | this.data = data; 144 | this.searcher = new Searcher(data.index); 145 | 146 | this.tree = new Searchdoc.Tree($('.tree', element), tree, this); 147 | this.init(); 148 | } 149 | 150 | Searchdoc.Panel.prototype = $.extend({}, Searchdoc.Navigation, new function() { 151 | var suid = 1; 152 | 153 | this.init = function() { 154 | var _this = this; 155 | var observer = function() { 156 | _this.search(_this.$input[0].value); 157 | }; 158 | this.$input.keyup(observer); 159 | this.$input.click(observer); // mac's clear field 160 | 161 | this.searcher.ready(function(results, isLast) { 162 | _this.addResults(results, isLast); 163 | }) 164 | 165 | this.$result.click(function(e) { 166 | _this.$current.removeClass('current'); 167 | _this.$current = $(e.target).closest('li').addClass('current'); 168 | _this.select(); 169 | _this.$input.focus(); 170 | }); 171 | 172 | this.initNavigation(); 173 | this.setNavigationActive(false); 174 | } 175 | 176 | this.search = function(value, selectFirstMatch) { 177 | value = jQuery.trim(value).toLowerCase(); 178 | this.selectFirstMatch = selectFirstMatch; 179 | if (value) { 180 | this.$element.removeClass('panel_tree').addClass('panel_results'); 181 | this.tree.setNavigationActive(false); 182 | this.setNavigationActive(true); 183 | } else { 184 | this.$element.addClass('panel_tree').removeClass('panel_results'); 185 | this.tree.setNavigationActive(true); 186 | this.setNavigationActive(false); 187 | } 188 | if (value != this.lastQuery) { 189 | this.lastQuery = value; 190 | this.firstRun = true; 191 | this.searcher.find(value); 192 | } 193 | } 194 | 195 | this.addResults = function(results, isLast) { 196 | var target = this.$result.get(0); 197 | if (this.firstRun && (results.length > 0 || isLast)) { 198 | this.$current = null; 199 | this.$result.empty(); 200 | } 201 | for (var i=0, l = results.length; i < l; i++) { 202 | target.appendChild(renderItem.call(this, results[i])); 203 | }; 204 | if (this.firstRun && results.length > 0) { 205 | this.firstRun = false; 206 | this.$current = $(target.firstChild); 207 | this.$current.addClass('current'); 208 | if (this.selectFirstMatch) this.select(); 209 | scrollIntoView(this.$current[0], this.$view[0]) 210 | } 211 | if (jQuery.browser.msie) this.$element[0].className += ''; 212 | } 213 | 214 | this.open = function(src) { 215 | this.frame.location.href = '../' + src; 216 | if (this.frame.highlight) this.frame.highlight(src); 217 | } 218 | 219 | this.select = function() { 220 | this.open(this.$current.data('path')); 221 | } 222 | 223 | this.move = function(isDown) { 224 | if (!this.$current) return; 225 | var $next = this.$current[isDown ? 'next' : 'prev'](); 226 | if ($next.length) { 227 | this.$current.removeClass('current'); 228 | $next.addClass('current'); 229 | scrollIntoView($next[0], this.$view[0]); 230 | this.$current = $next; 231 | } 232 | return true; 233 | } 234 | 235 | function renderItem(result) { 236 | var li = document.createElement('li'), 237 | html = '', badge = result.badge; 238 | html += '

' + hlt(result.title); 239 | if (result.params) html += '' + result.params + ''; 240 | html += '

'; 241 | html += '

'; 242 | if (typeof badge != 'undefined') { 243 | html += '' + escapeHTML(this.data.badges[badge] || 'unknown') + ''; 244 | } 245 | html += hlt(result.namespace) + '

'; 246 | if (result.snippet) html += '

' + escapeHTML(result.snippet) + '

'; 247 | li.innerHTML = html; 248 | jQuery.data(li, 'path', result.path); 249 | return li; 250 | } 251 | 252 | function hlt(html) { 253 | return escapeHTML(html).replace(/\u0001/g, '').replace(/\u0002/g, '') 254 | } 255 | 256 | function escapeHTML(html) { 257 | return html.replace(/[&<>]/g, function(c) { 258 | return '&#' + c.charCodeAt(0) + ';'; 259 | }); 260 | } 261 | 262 | }); 263 | 264 | // tree.js ------------------------------------------------ 265 | 266 | Searchdoc.Tree = function(element, tree, panel) { 267 | this.$element = $(element); 268 | this.$list = $('ul', element); 269 | this.tree = tree; 270 | this.panel = panel; 271 | this.init(); 272 | } 273 | 274 | Searchdoc.Tree.prototype = $.extend({}, Searchdoc.Navigation, new function() { 275 | this.init = function() { 276 | var stopper = document.createElement('li'); 277 | stopper.className = 'stopper'; 278 | this.$list[0].appendChild(stopper); 279 | for (var i=0, l = this.tree.length; i < l; i++) { 280 | buildAndAppendItem.call(this, this.tree[i], 0, stopper); 281 | }; 282 | var _this = this; 283 | this.$list.click(function(e) { 284 | var $target = $(e.target), 285 | $li = $target.closest('li'); 286 | if ($target.hasClass('icon')) { 287 | _this.toggle($li); 288 | } else { 289 | _this.select($li); 290 | } 291 | }) 292 | 293 | this.initNavigation(); 294 | if (jQuery.browser.msie) document.body.className += ''; 295 | } 296 | 297 | this.select = function($li) { 298 | this.highlight($li); 299 | var path = $li[0].searchdoc_tree_data.path; 300 | if (path) this.panel.open(path); 301 | } 302 | 303 | this.highlight = function($li) { 304 | if (this.$current) this.$current.removeClass('current'); 305 | this.$current = $li.addClass('current'); 306 | } 307 | 308 | this.toggle = function($li) { 309 | var closed = !$li.hasClass('closed'), 310 | children = $li[0].searchdoc_tree_data.children; 311 | $li.toggleClass('closed'); 312 | for (var i=0, l = children.length; i < l; i++) { 313 | toggleVis.call(this, $(children[i].li), !closed); 314 | }; 315 | } 316 | 317 | this.moveRight = function() { 318 | if (!this.$current) { 319 | this.highlight(this.$list.find('li:first')); 320 | return; 321 | } 322 | if (this.$current.hasClass('closed')) { 323 | this.toggle(this.$current); 324 | } 325 | } 326 | 327 | this.moveLeft = function() { 328 | if (!this.$current) { 329 | this.highlight(this.$list.find('li:first')); 330 | return; 331 | } 332 | if (!this.$current.hasClass('closed')) { 333 | this.toggle(this.$current); 334 | } else { 335 | var level = this.$current[0].searchdoc_tree_data.level; 336 | if (level == 0) return; 337 | var $next = this.$current.prevAll('li.level_' + (level - 1) + ':visible:first'); 338 | this.$current.removeClass('current'); 339 | $next.addClass('current'); 340 | scrollIntoView($next[0], this.$element[0]); 341 | this.$current = $next; 342 | } 343 | } 344 | 345 | this.move = function(isDown) { 346 | if (!this.$current) { 347 | this.highlight(this.$list.find('li:first')); 348 | return true; 349 | } 350 | var next = this.$current[0]; 351 | if (isDown) { 352 | do { 353 | next = next.nextSibling; 354 | if (next && next.style && next.style.display != 'none') break; 355 | } while(next); 356 | } else { 357 | do { 358 | next = next.previousSibling; 359 | if (next && next.style && next.style.display != 'none') break; 360 | } while(next); 361 | } 362 | if (next && next.className.indexOf('stopper') == -1) { 363 | this.$current.removeClass('current'); 364 | $(next).addClass('current'); 365 | scrollIntoView(next, this.$element[0]); 366 | this.$current = $(next); 367 | } 368 | return true; 369 | } 370 | 371 | function toggleVis($li, show) { 372 | var closed = $li.hasClass('closed'), 373 | children = $li[0].searchdoc_tree_data.children; 374 | $li.css('display', show ? '' : 'none') 375 | if (!show && this.$current && $li[0] == this.$current[0]) { 376 | this.$current.removeClass('current'); 377 | this.$current = null; 378 | } 379 | for (var i=0, l = children.length; i < l; i++) { 380 | toggleVis.call(this, $(children[i].li), show && !closed); 381 | }; 382 | } 383 | 384 | function buildAndAppendItem(item, level, before) { 385 | var li = renderItem(item, level), 386 | list = this.$list[0]; 387 | item.li = li; 388 | list.insertBefore(li, before); 389 | for (var i=0, l = item[3].length; i < l; i++) { 390 | buildAndAppendItem.call(this, item[3][i], level + 1, before); 391 | }; 392 | return li; 393 | } 394 | 395 | function renderItem(item, level) { 396 | var li = document.createElement('li'), 397 | cnt = document.createElement('div'), 398 | h1 = document.createElement('h1'), 399 | p = document.createElement('p'), 400 | icon, i; 401 | 402 | li.appendChild(cnt); 403 | li.style.paddingLeft = getOffset(level); 404 | cnt.className = 'content'; 405 | if (!item[1]) li.className = 'empty '; 406 | cnt.appendChild(h1); 407 | // cnt.appendChild(p); 408 | h1.appendChild(document.createTextNode(item[0])); 409 | // p.appendChild(document.createTextNode(item[4])); 410 | if (item[2]) { 411 | i = document.createElement('i'); 412 | i.appendChild(document.createTextNode(item[2])); 413 | h1.appendChild(i); 414 | } 415 | if (item[3].length > 0) { 416 | icon = document.createElement('div'); 417 | icon.className = 'icon'; 418 | cnt.appendChild(icon); 419 | } 420 | 421 | // user direct assignement instead of $() 422 | // it's 8x faster 423 | // $(li).data('path', item[1]) 424 | // .data('children', item[3]) 425 | // .data('level', level) 426 | // .css('display', level == 0 ? '' : 'none') 427 | // .addClass('level_' + level) 428 | // .addClass('closed'); 429 | li.searchdoc_tree_data = { 430 | path: item[1], 431 | children: item[3], 432 | level: level 433 | } 434 | li.style.display = level == 0 ? '' : 'none'; 435 | li.className += 'level_' + level + ' closed'; 436 | return li; 437 | } 438 | 439 | function getOffset(level) { 440 | return 5 + 18*level + 'px'; 441 | } 442 | }); 443 | -------------------------------------------------------------------------------- /lib/rdoc/generator/template/rails/resources/js/jquery-effect.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery UI Effects 1.6rc6 3 | * 4 | * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) 5 | * Dual licensed under the MIT (MIT-LICENSE.txt) 6 | * and GPL (GPL-LICENSE.txt) licenses. 7 | * 8 | * http://docs.jquery.com/UI/Effects/ 9 | */ 10 | ;(function($) { 11 | 12 | $.effects = $.effects || {}; //Add the 'effects' scope 13 | 14 | $.extend($.effects, { 15 | version: "1.6rc6", 16 | 17 | // Saves a set of properties in a data storage 18 | save: function(element, set) { 19 | for(var i=0; i < set.length; i++) { 20 | if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]); 21 | } 22 | }, 23 | 24 | // Restores a set of previously saved properties from a data storage 25 | restore: function(element, set) { 26 | for(var i=0; i < set.length; i++) { 27 | if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i])); 28 | } 29 | }, 30 | 31 | setMode: function(el, mode) { 32 | if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle 33 | return mode; 34 | }, 35 | 36 | getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value 37 | // this should be a little more flexible in the future to handle a string & hash 38 | var y, x; 39 | switch (origin[0]) { 40 | case 'top': y = 0; break; 41 | case 'middle': y = 0.5; break; 42 | case 'bottom': y = 1; break; 43 | default: y = origin[0] / original.height; 44 | }; 45 | switch (origin[1]) { 46 | case 'left': x = 0; break; 47 | case 'center': x = 0.5; break; 48 | case 'right': x = 1; break; 49 | default: x = origin[1] / original.width; 50 | }; 51 | return {x: x, y: y}; 52 | }, 53 | 54 | // Wraps the element around a wrapper that copies position properties 55 | createWrapper: function(element) { 56 | 57 | //if the element is already wrapped, return it 58 | if (element.parent().is('.ui-effects-wrapper')) 59 | return element.parent(); 60 | 61 | //Cache width,height and float properties of the element, and create a wrapper around it 62 | var props = { width: element.outerWidth(true), height: element.outerHeight(true), 'float': element.css('float') }; 63 | element.wrap('
'); 64 | var wrapper = element.parent(); 65 | 66 | //Transfer the positioning of the element to the wrapper 67 | if (element.css('position') == 'static') { 68 | wrapper.css({ position: 'relative' }); 69 | element.css({ position: 'relative'} ); 70 | } else { 71 | var top = element.css('top'); if(isNaN(parseInt(top,10))) top = 'auto'; 72 | var left = element.css('left'); if(isNaN(parseInt(left,10))) left = 'auto'; 73 | wrapper.css({ position: element.css('position'), top: top, left: left, zIndex: element.css('z-index') }).show(); 74 | element.css({position: 'relative', top: 0, left: 0 }); 75 | } 76 | 77 | wrapper.css(props); 78 | return wrapper; 79 | }, 80 | 81 | removeWrapper: function(element) { 82 | if (element.parent().is('.ui-effects-wrapper')) 83 | return element.parent().replaceWith(element); 84 | return element; 85 | }, 86 | 87 | setTransition: function(element, list, factor, value) { 88 | value = value || {}; 89 | $.each(list, function(i, x){ 90 | unit = element.cssUnit(x); 91 | if (unit[0] > 0) value[x] = unit[0] * factor + unit[1]; 92 | }); 93 | return value; 94 | }, 95 | 96 | //Base function to animate from one class to another in a seamless transition 97 | animateClass: function(value, duration, easing, callback) { 98 | 99 | var cb = (typeof easing == "function" ? easing : (callback ? callback : null)); 100 | var ea = (typeof easing == "string" ? easing : null); 101 | 102 | return this.each(function() { 103 | 104 | var offset = {}; var that = $(this); var oldStyleAttr = that.attr("style") || ''; 105 | if(typeof oldStyleAttr == 'object') oldStyleAttr = oldStyleAttr["cssText"]; /* Stupidly in IE, style is a object.. */ 106 | if(value.toggle) { that.hasClass(value.toggle) ? value.remove = value.toggle : value.add = value.toggle; } 107 | 108 | //Let's get a style offset 109 | var oldStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle)); 110 | if(value.add) that.addClass(value.add); if(value.remove) that.removeClass(value.remove); 111 | var newStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle)); 112 | if(value.add) that.removeClass(value.add); if(value.remove) that.addClass(value.remove); 113 | 114 | // The main function to form the object for animation 115 | for(var n in newStyle) { 116 | if( typeof newStyle[n] != "function" && newStyle[n] /* No functions and null properties */ 117 | && n.indexOf("Moz") == -1 && n.indexOf("length") == -1 /* No mozilla spezific render properties. */ 118 | && newStyle[n] != oldStyle[n] /* Only values that have changed are used for the animation */ 119 | && (n.match(/color/i) || (!n.match(/color/i) && !isNaN(parseInt(newStyle[n],10)))) /* Only things that can be parsed to integers or colors */ 120 | && (oldStyle.position != "static" || (oldStyle.position == "static" && !n.match(/left|top|bottom|right/))) /* No need for positions when dealing with static positions */ 121 | ) offset[n] = newStyle[n]; 122 | } 123 | 124 | that.animate(offset, duration, ea, function() { // Animate the newly constructed offset object 125 | // Change style attribute back to original. For stupid IE, we need to clear the damn object. 126 | if(typeof $(this).attr("style") == 'object') { $(this).attr("style")["cssText"] = ""; $(this).attr("style")["cssText"] = oldStyleAttr; } else $(this).attr("style", oldStyleAttr); 127 | if(value.add) $(this).addClass(value.add); if(value.remove) $(this).removeClass(value.remove); 128 | if(cb) cb.apply(this, arguments); 129 | }); 130 | 131 | }); 132 | } 133 | }); 134 | 135 | 136 | function _normalizeArguments(a, m) { 137 | 138 | var o = a[1] && a[1].constructor == Object ? a[1] : {}; if(m) o.mode = m; 139 | var speed = a[1] && a[1].constructor != Object ? a[1] : o.duration; //either comes from options.duration or the second argument 140 | speed = $.fx.off ? 0 : typeof speed === "number" ? speed : $.fx.speeds[speed] || $.fx.speeds._default; 141 | var callback = o.callback || ( $.isFunction(a[2]) && a[2] ) || ( $.isFunction(a[3]) && a[3] ); 142 | 143 | return [a[0], o, speed, callback]; 144 | 145 | } 146 | 147 | //Extend the methods of jQuery 148 | $.fn.extend({ 149 | 150 | //Save old methods 151 | _show: $.fn.show, 152 | _hide: $.fn.hide, 153 | __toggle: $.fn.toggle, 154 | _addClass: $.fn.addClass, 155 | _removeClass: $.fn.removeClass, 156 | _toggleClass: $.fn.toggleClass, 157 | 158 | // New effect methods 159 | effect: function(fx, options, speed, callback) { 160 | return $.effects[fx] ? $.effects[fx].call(this, {method: fx, options: options || {}, duration: speed, callback: callback }) : null; 161 | }, 162 | 163 | show: function() { 164 | if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0]))) 165 | return this._show.apply(this, arguments); 166 | else { 167 | return this.effect.apply(this, _normalizeArguments(arguments, 'show')); 168 | } 169 | }, 170 | 171 | hide: function() { 172 | if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0]))) 173 | return this._hide.apply(this, arguments); 174 | else { 175 | return this.effect.apply(this, _normalizeArguments(arguments, 'hide')); 176 | } 177 | }, 178 | 179 | toggle: function(){ 180 | if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0])) || (arguments[0].constructor == Function)) 181 | return this.__toggle.apply(this, arguments); 182 | else { 183 | return this.effect.apply(this, _normalizeArguments(arguments, 'toggle')); 184 | } 185 | }, 186 | 187 | addClass: function(classNames, speed, easing, callback) { 188 | return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames); 189 | }, 190 | removeClass: function(classNames,speed,easing,callback) { 191 | return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames); 192 | }, 193 | toggleClass: function(classNames,speed,easing,callback) { 194 | return ( (typeof speed !== "boolean") && speed ) ? $.effects.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames, speed); 195 | }, 196 | morph: function(remove,add,speed,easing,callback) { 197 | return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]); 198 | }, 199 | switchClass: function() { 200 | return this.morph.apply(this, arguments); 201 | }, 202 | 203 | // helper functions 204 | cssUnit: function(key) { 205 | var style = this.css(key), val = []; 206 | $.each( ['em','px','%','pt'], function(i, unit){ 207 | if(style.indexOf(unit) > 0) 208 | val = [parseFloat(style), unit]; 209 | }); 210 | return val; 211 | } 212 | }); 213 | 214 | /* 215 | * jQuery Color Animations 216 | * Copyright 2007 John Resig 217 | * Released under the MIT and GPL licenses. 218 | */ 219 | 220 | // We override the animation for all of these color styles 221 | $.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){ 222 | $.fx.step[attr] = function(fx) { 223 | if ( fx.state == 0 ) { 224 | fx.start = getColor( fx.elem, attr ); 225 | fx.end = getRGB( fx.end ); 226 | } 227 | 228 | fx.elem.style[attr] = "rgb(" + [ 229 | Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0],10), 255), 0), 230 | Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1],10), 255), 0), 231 | Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2],10), 255), 0) 232 | ].join(",") + ")"; 233 | }; 234 | }); 235 | 236 | // Color Conversion functions from highlightFade 237 | // By Blair Mitchelmore 238 | // http://jquery.offput.ca/highlightFade/ 239 | 240 | // Parse strings looking for color tuples [255,255,255] 241 | function getRGB(color) { 242 | var result; 243 | 244 | // Check if we're already dealing with an array of colors 245 | if ( color && color.constructor == Array && color.length == 3 ) 246 | return color; 247 | 248 | // Look for rgb(num,num,num) 249 | if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) 250 | return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)]; 251 | 252 | // Look for rgb(num%,num%,num%) 253 | if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) 254 | return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55]; 255 | 256 | // Look for #a0b1c2 257 | if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) 258 | return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)]; 259 | 260 | // Look for #fff 261 | if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) 262 | return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)]; 263 | 264 | // Look for rgba(0, 0, 0, 0) == transparent in Safari 3 265 | if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) 266 | return colors['transparent']; 267 | 268 | // Otherwise, we're most likely dealing with a named color 269 | return colors[$.trim(color).toLowerCase()]; 270 | } 271 | 272 | function getColor(elem, attr) { 273 | var color; 274 | 275 | do { 276 | color = $.curCSS(elem, attr); 277 | 278 | // Keep going until we find an element that has color, or we hit the body 279 | if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") ) 280 | break; 281 | 282 | attr = "backgroundColor"; 283 | } while ( elem = elem.parentNode ); 284 | 285 | return getRGB(color); 286 | }; 287 | 288 | // Some named colors to work with 289 | // From Interface by Stefan Petre 290 | // http://interface.eyecon.ro/ 291 | 292 | var colors = { 293 | aqua:[0,255,255], 294 | azure:[240,255,255], 295 | beige:[245,245,220], 296 | black:[0,0,0], 297 | blue:[0,0,255], 298 | brown:[165,42,42], 299 | cyan:[0,255,255], 300 | darkblue:[0,0,139], 301 | darkcyan:[0,139,139], 302 | darkgrey:[169,169,169], 303 | darkgreen:[0,100,0], 304 | darkkhaki:[189,183,107], 305 | darkmagenta:[139,0,139], 306 | darkolivegreen:[85,107,47], 307 | darkorange:[255,140,0], 308 | darkorchid:[153,50,204], 309 | darkred:[139,0,0], 310 | darksalmon:[233,150,122], 311 | darkviolet:[148,0,211], 312 | fuchsia:[255,0,255], 313 | gold:[255,215,0], 314 | green:[0,128,0], 315 | indigo:[75,0,130], 316 | khaki:[240,230,140], 317 | lightblue:[173,216,230], 318 | lightcyan:[224,255,255], 319 | lightgreen:[144,238,144], 320 | lightgrey:[211,211,211], 321 | lightpink:[255,182,193], 322 | lightyellow:[255,255,224], 323 | lime:[0,255,0], 324 | magenta:[255,0,255], 325 | maroon:[128,0,0], 326 | navy:[0,0,128], 327 | olive:[128,128,0], 328 | orange:[255,165,0], 329 | pink:[255,192,203], 330 | purple:[128,0,128], 331 | violet:[128,0,128], 332 | red:[255,0,0], 333 | silver:[192,192,192], 334 | white:[255,255,255], 335 | yellow:[255,255,0], 336 | transparent: [255,255,255] 337 | }; 338 | 339 | /* 340 | * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ 341 | * 342 | * Uses the built in easing capabilities added In jQuery 1.1 343 | * to offer multiple easing options 344 | * 345 | * TERMS OF USE - jQuery Easing 346 | * 347 | * Open source under the BSD License. 348 | * 349 | * Copyright 2008 George McGinley Smith 350 | * All rights reserved. 351 | * 352 | * Redistribution and use in source and binary forms, with or without modification, 353 | * are permitted provided that the following conditions are met: 354 | * 355 | * Redistributions of source code must retain the above copyright notice, this list of 356 | * conditions and the following disclaimer. 357 | * Redistributions in binary form must reproduce the above copyright notice, this list 358 | * of conditions and the following disclaimer in the documentation and/or other materials 359 | * provided with the distribution. 360 | * 361 | * Neither the name of the author nor the names of contributors may be used to endorse 362 | * or promote products derived from this software without specific prior written permission. 363 | * 364 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 365 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 366 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 367 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 368 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 369 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 370 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 371 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 372 | * OF THE POSSIBILITY OF SUCH DAMAGE. 373 | * 374 | */ 375 | 376 | // t: current time, b: begInnIng value, c: change In value, d: duration 377 | $.easing.jswing = $.easing.swing; 378 | 379 | $.extend($.easing, 380 | { 381 | def: 'easeOutQuad', 382 | swing: function (x, t, b, c, d) { 383 | //alert($.easing.default); 384 | return $.easing[$.easing.def](x, t, b, c, d); 385 | }, 386 | easeInQuad: function (x, t, b, c, d) { 387 | return c*(t/=d)*t + b; 388 | }, 389 | easeOutQuad: function (x, t, b, c, d) { 390 | return -c *(t/=d)*(t-2) + b; 391 | }, 392 | easeInOutQuad: function (x, t, b, c, d) { 393 | if ((t/=d/2) < 1) return c/2*t*t + b; 394 | return -c/2 * ((--t)*(t-2) - 1) + b; 395 | }, 396 | easeInCubic: function (x, t, b, c, d) { 397 | return c*(t/=d)*t*t + b; 398 | }, 399 | easeOutCubic: function (x, t, b, c, d) { 400 | return c*((t=t/d-1)*t*t + 1) + b; 401 | }, 402 | easeInOutCubic: function (x, t, b, c, d) { 403 | if ((t/=d/2) < 1) return c/2*t*t*t + b; 404 | return c/2*((t-=2)*t*t + 2) + b; 405 | }, 406 | easeInQuart: function (x, t, b, c, d) { 407 | return c*(t/=d)*t*t*t + b; 408 | }, 409 | easeOutQuart: function (x, t, b, c, d) { 410 | return -c * ((t=t/d-1)*t*t*t - 1) + b; 411 | }, 412 | easeInOutQuart: function (x, t, b, c, d) { 413 | if ((t/=d/2) < 1) return c/2*t*t*t*t + b; 414 | return -c/2 * ((t-=2)*t*t*t - 2) + b; 415 | }, 416 | easeInQuint: function (x, t, b, c, d) { 417 | return c*(t/=d)*t*t*t*t + b; 418 | }, 419 | easeOutQuint: function (x, t, b, c, d) { 420 | return c*((t=t/d-1)*t*t*t*t + 1) + b; 421 | }, 422 | easeInOutQuint: function (x, t, b, c, d) { 423 | if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; 424 | return c/2*((t-=2)*t*t*t*t + 2) + b; 425 | }, 426 | easeInSine: function (x, t, b, c, d) { 427 | return -c * Math.cos(t/d * (Math.PI/2)) + c + b; 428 | }, 429 | easeOutSine: function (x, t, b, c, d) { 430 | return c * Math.sin(t/d * (Math.PI/2)) + b; 431 | }, 432 | easeInOutSine: function (x, t, b, c, d) { 433 | return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; 434 | }, 435 | easeInExpo: function (x, t, b, c, d) { 436 | return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; 437 | }, 438 | easeOutExpo: function (x, t, b, c, d) { 439 | return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; 440 | }, 441 | easeInOutExpo: function (x, t, b, c, d) { 442 | if (t==0) return b; 443 | if (t==d) return b+c; 444 | if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; 445 | return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; 446 | }, 447 | easeInCirc: function (x, t, b, c, d) { 448 | return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; 449 | }, 450 | easeOutCirc: function (x, t, b, c, d) { 451 | return c * Math.sqrt(1 - (t=t/d-1)*t) + b; 452 | }, 453 | easeInOutCirc: function (x, t, b, c, d) { 454 | if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; 455 | return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; 456 | }, 457 | easeInElastic: function (x, t, b, c, d) { 458 | var s=1.70158;var p=0;var a=c; 459 | if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 460 | if (a < Math.abs(c)) { a=c; var s=p/4; } 461 | else var s = p/(2*Math.PI) * Math.asin (c/a); 462 | return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 463 | }, 464 | easeOutElastic: function (x, t, b, c, d) { 465 | var s=1.70158;var p=0;var a=c; 466 | if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 467 | if (a < Math.abs(c)) { a=c; var s=p/4; } 468 | else var s = p/(2*Math.PI) * Math.asin (c/a); 469 | return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; 470 | }, 471 | easeInOutElastic: function (x, t, b, c, d) { 472 | var s=1.70158;var p=0;var a=c; 473 | if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); 474 | if (a < Math.abs(c)) { a=c; var s=p/4; } 475 | else var s = p/(2*Math.PI) * Math.asin (c/a); 476 | if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 477 | return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; 478 | }, 479 | easeInBack: function (x, t, b, c, d, s) { 480 | if (s == undefined) s = 1.70158; 481 | return c*(t/=d)*t*((s+1)*t - s) + b; 482 | }, 483 | easeOutBack: function (x, t, b, c, d, s) { 484 | if (s == undefined) s = 1.70158; 485 | return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; 486 | }, 487 | easeInOutBack: function (x, t, b, c, d, s) { 488 | if (s == undefined) s = 1.70158; 489 | if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 490 | return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 491 | }, 492 | easeInBounce: function (x, t, b, c, d) { 493 | return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b; 494 | }, 495 | easeOutBounce: function (x, t, b, c, d) { 496 | if ((t/=d) < (1/2.75)) { 497 | return c*(7.5625*t*t) + b; 498 | } else if (t < (2/2.75)) { 499 | return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; 500 | } else if (t < (2.5/2.75)) { 501 | return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; 502 | } else { 503 | return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; 504 | } 505 | }, 506 | easeInOutBounce: function (x, t, b, c, d) { 507 | if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; 508 | return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; 509 | } 510 | }); 511 | /* 512 | * 513 | * TERMS OF USE - EASING EQUATIONS 514 | * 515 | * Open source under the BSD License. 516 | * 517 | * Copyright 2001 Robert Penner 518 | * All rights reserved. 519 | * 520 | * Redistribution and use in source and binary forms, with or without modification, 521 | * are permitted provided that the following conditions are met: 522 | * 523 | * Redistributions of source code must retain the above copyright notice, this list of 524 | * conditions and the following disclaimer. 525 | * Redistributions in binary form must reproduce the above copyright notice, this list 526 | * of conditions and the following disclaimer in the documentation and/or other materials 527 | * provided with the distribution. 528 | * 529 | * Neither the name of the author nor the names of contributors may be used to endorse 530 | * or promote products derived from this software without specific prior written permission. 531 | * 532 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 533 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 534 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 535 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 536 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 537 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 538 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 539 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 540 | * OF THE POSSIBILITY OF SUCH DAMAGE. 541 | * 542 | */ 543 | 544 | })(jQuery); 545 | 546 | /* 547 | * jQuery UI Effects Highlight 1.6rc6 548 | * 549 | * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) 550 | * Dual licensed under the MIT (MIT-LICENSE.txt) 551 | * and GPL (GPL-LICENSE.txt) licenses. 552 | * 553 | * http://docs.jquery.com/UI/Effects/Highlight 554 | * 555 | * Depends: 556 | * effects.core.js 557 | */ 558 | (function($) { 559 | 560 | $.effects.highlight = function(o) { 561 | 562 | return this.queue(function() { 563 | 564 | // Create element 565 | var el = $(this), props = ['backgroundImage','backgroundColor','opacity']; 566 | 567 | // Set options 568 | var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode 569 | var color = o.options.color || "#ffff99"; // Default highlight color 570 | var oldColor = el.css("backgroundColor"); 571 | 572 | // Adjust 573 | $.effects.save(el, props); el.show(); // Save & Show 574 | el.css({backgroundImage: 'none', backgroundColor: color}); // Shift 575 | 576 | // Animation 577 | var animation = {backgroundColor: oldColor }; 578 | if (mode == "hide") animation['opacity'] = 0; 579 | 580 | // Animate 581 | el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { 582 | if(mode == "hide") el.hide(); 583 | $.effects.restore(el, props); 584 | if (mode == "show" && $.browser.msie) this.style.removeAttribute('filter'); 585 | if(o.callback) o.callback.apply(this, arguments); 586 | el.dequeue(); 587 | }}); 588 | 589 | }); 590 | 591 | }; 592 | 593 | })(jQuery); -------------------------------------------------------------------------------- /lib/rdoc/generator/template/sdoc/resources/js/jquery-effect.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery UI Effects 1.6rc6 3 | * 4 | * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) 5 | * Dual licensed under the MIT (MIT-LICENSE.txt) 6 | * and GPL (GPL-LICENSE.txt) licenses. 7 | * 8 | * http://docs.jquery.com/UI/Effects/ 9 | */ 10 | ;(function($) { 11 | 12 | $.effects = $.effects || {}; //Add the 'effects' scope 13 | 14 | $.extend($.effects, { 15 | version: "1.6rc6", 16 | 17 | // Saves a set of properties in a data storage 18 | save: function(element, set) { 19 | for(var i=0; i < set.length; i++) { 20 | if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]); 21 | } 22 | }, 23 | 24 | // Restores a set of previously saved properties from a data storage 25 | restore: function(element, set) { 26 | for(var i=0; i < set.length; i++) { 27 | if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i])); 28 | } 29 | }, 30 | 31 | setMode: function(el, mode) { 32 | if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle 33 | return mode; 34 | }, 35 | 36 | getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value 37 | // this should be a little more flexible in the future to handle a string & hash 38 | var y, x; 39 | switch (origin[0]) { 40 | case 'top': y = 0; break; 41 | case 'middle': y = 0.5; break; 42 | case 'bottom': y = 1; break; 43 | default: y = origin[0] / original.height; 44 | }; 45 | switch (origin[1]) { 46 | case 'left': x = 0; break; 47 | case 'center': x = 0.5; break; 48 | case 'right': x = 1; break; 49 | default: x = origin[1] / original.width; 50 | }; 51 | return {x: x, y: y}; 52 | }, 53 | 54 | // Wraps the element around a wrapper that copies position properties 55 | createWrapper: function(element) { 56 | 57 | //if the element is already wrapped, return it 58 | if (element.parent().is('.ui-effects-wrapper')) 59 | return element.parent(); 60 | 61 | //Cache width,height and float properties of the element, and create a wrapper around it 62 | var props = { width: element.outerWidth(true), height: element.outerHeight(true), 'float': element.css('float') }; 63 | element.wrap('
'); 64 | var wrapper = element.parent(); 65 | 66 | //Transfer the positioning of the element to the wrapper 67 | if (element.css('position') == 'static') { 68 | wrapper.css({ position: 'relative' }); 69 | element.css({ position: 'relative'} ); 70 | } else { 71 | var top = element.css('top'); if(isNaN(parseInt(top,10))) top = 'auto'; 72 | var left = element.css('left'); if(isNaN(parseInt(left,10))) left = 'auto'; 73 | wrapper.css({ position: element.css('position'), top: top, left: left, zIndex: element.css('z-index') }).show(); 74 | element.css({position: 'relative', top: 0, left: 0 }); 75 | } 76 | 77 | wrapper.css(props); 78 | return wrapper; 79 | }, 80 | 81 | removeWrapper: function(element) { 82 | if (element.parent().is('.ui-effects-wrapper')) 83 | return element.parent().replaceWith(element); 84 | return element; 85 | }, 86 | 87 | setTransition: function(element, list, factor, value) { 88 | value = value || {}; 89 | $.each(list, function(i, x){ 90 | unit = element.cssUnit(x); 91 | if (unit[0] > 0) value[x] = unit[0] * factor + unit[1]; 92 | }); 93 | return value; 94 | }, 95 | 96 | //Base function to animate from one class to another in a seamless transition 97 | animateClass: function(value, duration, easing, callback) { 98 | 99 | var cb = (typeof easing == "function" ? easing : (callback ? callback : null)); 100 | var ea = (typeof easing == "string" ? easing : null); 101 | 102 | return this.each(function() { 103 | 104 | var offset = {}; var that = $(this); var oldStyleAttr = that.attr("style") || ''; 105 | if(typeof oldStyleAttr == 'object') oldStyleAttr = oldStyleAttr["cssText"]; /* Stupidly in IE, style is a object.. */ 106 | if(value.toggle) { that.hasClass(value.toggle) ? value.remove = value.toggle : value.add = value.toggle; } 107 | 108 | //Let's get a style offset 109 | var oldStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle)); 110 | if(value.add) that.addClass(value.add); if(value.remove) that.removeClass(value.remove); 111 | var newStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle)); 112 | if(value.add) that.removeClass(value.add); if(value.remove) that.addClass(value.remove); 113 | 114 | // The main function to form the object for animation 115 | for(var n in newStyle) { 116 | if( typeof newStyle[n] != "function" && newStyle[n] /* No functions and null properties */ 117 | && n.indexOf("Moz") == -1 && n.indexOf("length") == -1 /* No mozilla spezific render properties. */ 118 | && newStyle[n] != oldStyle[n] /* Only values that have changed are used for the animation */ 119 | && (n.match(/color/i) || (!n.match(/color/i) && !isNaN(parseInt(newStyle[n],10)))) /* Only things that can be parsed to integers or colors */ 120 | && (oldStyle.position != "static" || (oldStyle.position == "static" && !n.match(/left|top|bottom|right/))) /* No need for positions when dealing with static positions */ 121 | ) offset[n] = newStyle[n]; 122 | } 123 | 124 | that.animate(offset, duration, ea, function() { // Animate the newly constructed offset object 125 | // Change style attribute back to original. For stupid IE, we need to clear the damn object. 126 | if(typeof $(this).attr("style") == 'object') { $(this).attr("style")["cssText"] = ""; $(this).attr("style")["cssText"] = oldStyleAttr; } else $(this).attr("style", oldStyleAttr); 127 | if(value.add) $(this).addClass(value.add); if(value.remove) $(this).removeClass(value.remove); 128 | if(cb) cb.apply(this, arguments); 129 | }); 130 | 131 | }); 132 | } 133 | }); 134 | 135 | 136 | function _normalizeArguments(a, m) { 137 | 138 | var o = a[1] && a[1].constructor == Object ? a[1] : {}; if(m) o.mode = m; 139 | var speed = a[1] && a[1].constructor != Object ? a[1] : o.duration; //either comes from options.duration or the second argument 140 | speed = $.fx.off ? 0 : typeof speed === "number" ? speed : $.fx.speeds[speed] || $.fx.speeds._default; 141 | var callback = o.callback || ( $.isFunction(a[2]) && a[2] ) || ( $.isFunction(a[3]) && a[3] ); 142 | 143 | return [a[0], o, speed, callback]; 144 | 145 | } 146 | 147 | //Extend the methods of jQuery 148 | $.fn.extend({ 149 | 150 | //Save old methods 151 | _show: $.fn.show, 152 | _hide: $.fn.hide, 153 | __toggle: $.fn.toggle, 154 | _addClass: $.fn.addClass, 155 | _removeClass: $.fn.removeClass, 156 | _toggleClass: $.fn.toggleClass, 157 | 158 | // New effect methods 159 | effect: function(fx, options, speed, callback) { 160 | return $.effects[fx] ? $.effects[fx].call(this, {method: fx, options: options || {}, duration: speed, callback: callback }) : null; 161 | }, 162 | 163 | show: function() { 164 | if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0]))) 165 | return this._show.apply(this, arguments); 166 | else { 167 | return this.effect.apply(this, _normalizeArguments(arguments, 'show')); 168 | } 169 | }, 170 | 171 | hide: function() { 172 | if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0]))) 173 | return this._hide.apply(this, arguments); 174 | else { 175 | return this.effect.apply(this, _normalizeArguments(arguments, 'hide')); 176 | } 177 | }, 178 | 179 | toggle: function(){ 180 | if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0])) || (arguments[0].constructor == Function)) 181 | return this.__toggle.apply(this, arguments); 182 | else { 183 | return this.effect.apply(this, _normalizeArguments(arguments, 'toggle')); 184 | } 185 | }, 186 | 187 | addClass: function(classNames, speed, easing, callback) { 188 | return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames); 189 | }, 190 | removeClass: function(classNames,speed,easing,callback) { 191 | return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames); 192 | }, 193 | toggleClass: function(classNames,speed,easing,callback) { 194 | return ( (typeof speed !== "boolean") && speed ) ? $.effects.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames, speed); 195 | }, 196 | morph: function(remove,add,speed,easing,callback) { 197 | return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]); 198 | }, 199 | switchClass: function() { 200 | return this.morph.apply(this, arguments); 201 | }, 202 | 203 | // helper functions 204 | cssUnit: function(key) { 205 | var style = this.css(key), val = []; 206 | $.each( ['em','px','%','pt'], function(i, unit){ 207 | if(style.indexOf(unit) > 0) 208 | val = [parseFloat(style), unit]; 209 | }); 210 | return val; 211 | } 212 | }); 213 | 214 | /* 215 | * jQuery Color Animations 216 | * Copyright 2007 John Resig 217 | * Released under the MIT and GPL licenses. 218 | */ 219 | 220 | // We override the animation for all of these color styles 221 | $.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){ 222 | $.fx.step[attr] = function(fx) { 223 | if ( fx.state == 0 ) { 224 | fx.start = getColor( fx.elem, attr ); 225 | fx.end = getRGB( fx.end ); 226 | } 227 | 228 | fx.elem.style[attr] = "rgb(" + [ 229 | Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0],10), 255), 0), 230 | Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1],10), 255), 0), 231 | Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2],10), 255), 0) 232 | ].join(",") + ")"; 233 | }; 234 | }); 235 | 236 | // Color Conversion functions from highlightFade 237 | // By Blair Mitchelmore 238 | // http://jquery.offput.ca/highlightFade/ 239 | 240 | // Parse strings looking for color tuples [255,255,255] 241 | function getRGB(color) { 242 | var result; 243 | 244 | // Check if we're already dealing with an array of colors 245 | if ( color && color.constructor == Array && color.length == 3 ) 246 | return color; 247 | 248 | // Look for rgb(num,num,num) 249 | if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) 250 | return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)]; 251 | 252 | // Look for rgb(num%,num%,num%) 253 | if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) 254 | return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55]; 255 | 256 | // Look for #a0b1c2 257 | if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) 258 | return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)]; 259 | 260 | // Look for #fff 261 | if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) 262 | return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)]; 263 | 264 | // Look for rgba(0, 0, 0, 0) == transparent in Safari 3 265 | if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) 266 | return colors['transparent']; 267 | 268 | // Otherwise, we're most likely dealing with a named color 269 | return colors[$.trim(color).toLowerCase()]; 270 | } 271 | 272 | function getColor(elem, attr) { 273 | var color; 274 | 275 | do { 276 | color = $.curCSS(elem, attr); 277 | 278 | // Keep going until we find an element that has color, or we hit the body 279 | if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") ) 280 | break; 281 | 282 | attr = "backgroundColor"; 283 | } while ( elem = elem.parentNode ); 284 | 285 | return getRGB(color); 286 | }; 287 | 288 | // Some named colors to work with 289 | // From Interface by Stefan Petre 290 | // http://interface.eyecon.ro/ 291 | 292 | var colors = { 293 | aqua:[0,255,255], 294 | azure:[240,255,255], 295 | beige:[245,245,220], 296 | black:[0,0,0], 297 | blue:[0,0,255], 298 | brown:[165,42,42], 299 | cyan:[0,255,255], 300 | darkblue:[0,0,139], 301 | darkcyan:[0,139,139], 302 | darkgrey:[169,169,169], 303 | darkgreen:[0,100,0], 304 | darkkhaki:[189,183,107], 305 | darkmagenta:[139,0,139], 306 | darkolivegreen:[85,107,47], 307 | darkorange:[255,140,0], 308 | darkorchid:[153,50,204], 309 | darkred:[139,0,0], 310 | darksalmon:[233,150,122], 311 | darkviolet:[148,0,211], 312 | fuchsia:[255,0,255], 313 | gold:[255,215,0], 314 | green:[0,128,0], 315 | indigo:[75,0,130], 316 | khaki:[240,230,140], 317 | lightblue:[173,216,230], 318 | lightcyan:[224,255,255], 319 | lightgreen:[144,238,144], 320 | lightgrey:[211,211,211], 321 | lightpink:[255,182,193], 322 | lightyellow:[255,255,224], 323 | lime:[0,255,0], 324 | magenta:[255,0,255], 325 | maroon:[128,0,0], 326 | navy:[0,0,128], 327 | olive:[128,128,0], 328 | orange:[255,165,0], 329 | pink:[255,192,203], 330 | purple:[128,0,128], 331 | violet:[128,0,128], 332 | red:[255,0,0], 333 | silver:[192,192,192], 334 | white:[255,255,255], 335 | yellow:[255,255,0], 336 | transparent: [255,255,255] 337 | }; 338 | 339 | /* 340 | * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ 341 | * 342 | * Uses the built in easing capabilities added In jQuery 1.1 343 | * to offer multiple easing options 344 | * 345 | * TERMS OF USE - jQuery Easing 346 | * 347 | * Open source under the BSD License. 348 | * 349 | * Copyright 2008 George McGinley Smith 350 | * All rights reserved. 351 | * 352 | * Redistribution and use in source and binary forms, with or without modification, 353 | * are permitted provided that the following conditions are met: 354 | * 355 | * Redistributions of source code must retain the above copyright notice, this list of 356 | * conditions and the following disclaimer. 357 | * Redistributions in binary form must reproduce the above copyright notice, this list 358 | * of conditions and the following disclaimer in the documentation and/or other materials 359 | * provided with the distribution. 360 | * 361 | * Neither the name of the author nor the names of contributors may be used to endorse 362 | * or promote products derived from this software without specific prior written permission. 363 | * 364 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 365 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 366 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 367 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 368 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 369 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 370 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 371 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 372 | * OF THE POSSIBILITY OF SUCH DAMAGE. 373 | * 374 | */ 375 | 376 | // t: current time, b: begInnIng value, c: change In value, d: duration 377 | $.easing.jswing = $.easing.swing; 378 | 379 | $.extend($.easing, 380 | { 381 | def: 'easeOutQuad', 382 | swing: function (x, t, b, c, d) { 383 | //alert($.easing.default); 384 | return $.easing[$.easing.def](x, t, b, c, d); 385 | }, 386 | easeInQuad: function (x, t, b, c, d) { 387 | return c*(t/=d)*t + b; 388 | }, 389 | easeOutQuad: function (x, t, b, c, d) { 390 | return -c *(t/=d)*(t-2) + b; 391 | }, 392 | easeInOutQuad: function (x, t, b, c, d) { 393 | if ((t/=d/2) < 1) return c/2*t*t + b; 394 | return -c/2 * ((--t)*(t-2) - 1) + b; 395 | }, 396 | easeInCubic: function (x, t, b, c, d) { 397 | return c*(t/=d)*t*t + b; 398 | }, 399 | easeOutCubic: function (x, t, b, c, d) { 400 | return c*((t=t/d-1)*t*t + 1) + b; 401 | }, 402 | easeInOutCubic: function (x, t, b, c, d) { 403 | if ((t/=d/2) < 1) return c/2*t*t*t + b; 404 | return c/2*((t-=2)*t*t + 2) + b; 405 | }, 406 | easeInQuart: function (x, t, b, c, d) { 407 | return c*(t/=d)*t*t*t + b; 408 | }, 409 | easeOutQuart: function (x, t, b, c, d) { 410 | return -c * ((t=t/d-1)*t*t*t - 1) + b; 411 | }, 412 | easeInOutQuart: function (x, t, b, c, d) { 413 | if ((t/=d/2) < 1) return c/2*t*t*t*t + b; 414 | return -c/2 * ((t-=2)*t*t*t - 2) + b; 415 | }, 416 | easeInQuint: function (x, t, b, c, d) { 417 | return c*(t/=d)*t*t*t*t + b; 418 | }, 419 | easeOutQuint: function (x, t, b, c, d) { 420 | return c*((t=t/d-1)*t*t*t*t + 1) + b; 421 | }, 422 | easeInOutQuint: function (x, t, b, c, d) { 423 | if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; 424 | return c/2*((t-=2)*t*t*t*t + 2) + b; 425 | }, 426 | easeInSine: function (x, t, b, c, d) { 427 | return -c * Math.cos(t/d * (Math.PI/2)) + c + b; 428 | }, 429 | easeOutSine: function (x, t, b, c, d) { 430 | return c * Math.sin(t/d * (Math.PI/2)) + b; 431 | }, 432 | easeInOutSine: function (x, t, b, c, d) { 433 | return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; 434 | }, 435 | easeInExpo: function (x, t, b, c, d) { 436 | return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; 437 | }, 438 | easeOutExpo: function (x, t, b, c, d) { 439 | return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; 440 | }, 441 | easeInOutExpo: function (x, t, b, c, d) { 442 | if (t==0) return b; 443 | if (t==d) return b+c; 444 | if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; 445 | return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; 446 | }, 447 | easeInCirc: function (x, t, b, c, d) { 448 | return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; 449 | }, 450 | easeOutCirc: function (x, t, b, c, d) { 451 | return c * Math.sqrt(1 - (t=t/d-1)*t) + b; 452 | }, 453 | easeInOutCirc: function (x, t, b, c, d) { 454 | if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; 455 | return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; 456 | }, 457 | easeInElastic: function (x, t, b, c, d) { 458 | var s=1.70158;var p=0;var a=c; 459 | if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 460 | if (a < Math.abs(c)) { a=c; var s=p/4; } 461 | else var s = p/(2*Math.PI) * Math.asin (c/a); 462 | return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 463 | }, 464 | easeOutElastic: function (x, t, b, c, d) { 465 | var s=1.70158;var p=0;var a=c; 466 | if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 467 | if (a < Math.abs(c)) { a=c; var s=p/4; } 468 | else var s = p/(2*Math.PI) * Math.asin (c/a); 469 | return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; 470 | }, 471 | easeInOutElastic: function (x, t, b, c, d) { 472 | var s=1.70158;var p=0;var a=c; 473 | if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); 474 | if (a < Math.abs(c)) { a=c; var s=p/4; } 475 | else var s = p/(2*Math.PI) * Math.asin (c/a); 476 | if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 477 | return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; 478 | }, 479 | easeInBack: function (x, t, b, c, d, s) { 480 | if (s == undefined) s = 1.70158; 481 | return c*(t/=d)*t*((s+1)*t - s) + b; 482 | }, 483 | easeOutBack: function (x, t, b, c, d, s) { 484 | if (s == undefined) s = 1.70158; 485 | return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; 486 | }, 487 | easeInOutBack: function (x, t, b, c, d, s) { 488 | if (s == undefined) s = 1.70158; 489 | if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 490 | return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 491 | }, 492 | easeInBounce: function (x, t, b, c, d) { 493 | return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b; 494 | }, 495 | easeOutBounce: function (x, t, b, c, d) { 496 | if ((t/=d) < (1/2.75)) { 497 | return c*(7.5625*t*t) + b; 498 | } else if (t < (2/2.75)) { 499 | return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; 500 | } else if (t < (2.5/2.75)) { 501 | return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; 502 | } else { 503 | return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; 504 | } 505 | }, 506 | easeInOutBounce: function (x, t, b, c, d) { 507 | if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; 508 | return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; 509 | } 510 | }); 511 | /* 512 | * 513 | * TERMS OF USE - EASING EQUATIONS 514 | * 515 | * Open source under the BSD License. 516 | * 517 | * Copyright 2001 Robert Penner 518 | * All rights reserved. 519 | * 520 | * Redistribution and use in source and binary forms, with or without modification, 521 | * are permitted provided that the following conditions are met: 522 | * 523 | * Redistributions of source code must retain the above copyright notice, this list of 524 | * conditions and the following disclaimer. 525 | * Redistributions in binary form must reproduce the above copyright notice, this list 526 | * of conditions and the following disclaimer in the documentation and/or other materials 527 | * provided with the distribution. 528 | * 529 | * Neither the name of the author nor the names of contributors may be used to endorse 530 | * or promote products derived from this software without specific prior written permission. 531 | * 532 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 533 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 534 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 535 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 536 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 537 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 538 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 539 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 540 | * OF THE POSSIBILITY OF SUCH DAMAGE. 541 | * 542 | */ 543 | 544 | })(jQuery); 545 | 546 | /* 547 | * jQuery UI Effects Highlight 1.6rc6 548 | * 549 | * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) 550 | * Dual licensed under the MIT (MIT-LICENSE.txt) 551 | * and GPL (GPL-LICENSE.txt) licenses. 552 | * 553 | * http://docs.jquery.com/UI/Effects/Highlight 554 | * 555 | * Depends: 556 | * effects.core.js 557 | */ 558 | (function($) { 559 | 560 | $.effects.highlight = function(o) { 561 | 562 | return this.queue(function() { 563 | 564 | // Create element 565 | var el = $(this), props = ['backgroundImage','backgroundColor','opacity']; 566 | 567 | // Set options 568 | var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode 569 | var color = o.options.color || "#ffff99"; // Default highlight color 570 | var oldColor = el.css("backgroundColor"); 571 | 572 | // Adjust 573 | $.effects.save(el, props); el.show(); // Save & Show 574 | el.css({backgroundImage: 'none', backgroundColor: color}); // Shift 575 | 576 | // Animation 577 | var animation = {backgroundColor: oldColor }; 578 | if (mode == "hide") animation['opacity'] = 0; 579 | 580 | // Animate 581 | el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { 582 | if(mode == "hide") el.hide(); 583 | $.effects.restore(el, props); 584 | if (mode == "show" && $.browser.msie) this.style.removeAttribute('filter'); 585 | if(o.callback) o.callback.apply(this, arguments); 586 | el.dequeue(); 587 | }}); 588 | 589 | }); 590 | 591 | }; 592 | 593 | })(jQuery); --------------------------------------------------------------------------------