yard-slipstream 0.0.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ <%= @json_search_index %>
@@ -1,4 +1,5 @@
1
1
  include Helpers::ModuleHelper
2
+ require 'json'
2
3
 
3
4
  def init
4
5
  options[:objects] = objects = run_verifier(options[:objects])
@@ -7,7 +8,7 @@ def init
7
8
  options[:title] ||= "Documentation by YARD #{YARD::VERSION}"
8
9
 
9
10
  generate_assets
10
- serialize('_index.html')
11
+ serialize('object_index.html')
11
12
  options[:files].each_with_index do |file, i|
12
13
  serialize_file(file, i == 0 ? options[:title] : nil)
13
14
  end
@@ -28,7 +29,7 @@ end
28
29
 
29
30
  def serialize(object)
30
31
  options[:object] = object
31
- serialize_index(options) if object == '_index.html' && options[:files].empty?
32
+ serialize_index(options) if object == 'object_index.html' && options[:files].empty?
32
33
  Templates::Engine.with_serializer(object, options[:serializer]) do
33
34
  T('layout').run(options)
34
35
  end
@@ -60,7 +61,7 @@ def asset(path, content)
60
61
  end
61
62
 
62
63
  def generate_assets
63
- %w( js/jquery.js js/app.js js/full_list.js js/live.js js/autocomplete.js
64
+ %w( js/jquery.js js/app.js js/full_list.js js/autocomplete.js js/live.js
64
65
  css/style.css css/custom.css css/full_list.css css/common.css ).each do |file|
65
66
  asset(file, file(file, true))
66
67
  end
@@ -70,6 +71,7 @@ def generate_assets
70
71
  generate_class_list
71
72
  generate_file_list
72
73
  generate_frameset
74
+ generate_json_search_index
73
75
  end
74
76
 
75
77
  def generate_method_list
@@ -82,6 +84,7 @@ def generate_method_list
82
84
  end
83
85
 
84
86
  def generate_class_list
87
+ @items = options[:objects]
85
88
  @list_title = "Class List"
86
89
  @list_type = "class"
87
90
  asset('class_list.html', erb(:full_list))
@@ -96,6 +99,45 @@ def generate_file_list
96
99
  @file_list = nil
97
100
  end
98
101
 
102
+ def generate_json_search_index
103
+ @search_index = []
104
+
105
+ @search_index << options[:files].map do |f|
106
+ {
107
+ :text => File.basename(f).gsub(/\.[^.]+$/, ''),
108
+ :href_tag => link_file(f)
109
+ }
110
+ end
111
+
112
+ @search_index << [
113
+ {
114
+ :text => "Top Level Namespace",
115
+ :href_tag => link_object(Registry.root, nil, nil, false)
116
+ }
117
+ ]
118
+
119
+ @search_index << options[:objects].map do |o|
120
+ {
121
+ :text => o,
122
+ :href_tag => link_object(o)
123
+ }
124
+ end
125
+
126
+ method_listing = prune_method_listing(Registry.all(:method), false)
127
+ method_listing = method_listing.reject {|m| m.name.to_s =~ /=$/ && m.is_attribute? }
128
+ method_listing = method_listing.sort_by {|m| m.name.to_s }
129
+ @search_index << method_listing.map do |m|
130
+ {
131
+ :text => m,
132
+ :href_tag => linkify(m,m.name(true))
133
+ }
134
+ end
135
+
136
+ @search_index.flatten!
137
+ @json_search_index = JSON.dump(@search_index)
138
+ asset('search_index.json', erb(:json_search_index))
139
+ end
140
+
99
141
  def generate_frameset
100
142
  asset('frames.html', erb(:frames))
101
143
  end
@@ -104,8 +146,7 @@ def class_list(root = Registry.root)
104
146
  out = ""
105
147
  children = run_verifier(root.children)
106
148
  if root == Registry.root
107
- children += Registry.all(:class, :module).select {|o| o.namespace.is_a?(CodeObjects::Proxy) }
108
- children = run_verifier(children)
149
+ children += @items.select {|o| o.namespace.is_a?(CodeObjects::Proxy) }
109
150
  end
110
151
  children.sort_by {|child| child.path }.map do |child|
111
152
  if child.is_a?(CodeObjects::NamespaceObject)
@@ -0,0 +1,18 @@
1
+ <div id="menu">
2
+ <% if object.is_a?(CodeObjects::Base) && @file.nil? %>
3
+ <a href="<%= url_for('object_index.html') %>"><% if object.root? || object.type == :method %>Index<% else %>Index (<%= object.name.to_s[0,1] %>)<% end %></a> &raquo;
4
+ <%= @breadcrumb.map {|obj| "<span class='title'>" + linkify(obj, obj.name) + "</span>" }.join(" &raquo; ") %>
5
+ <%= @breadcrumb.size > 0 ? " &raquo; " : "" %>
6
+ <span class="title"><%= object.root? ? "Top Level Namespace" : object.name(true) %></span>
7
+ <% else %>
8
+ <% if object != 'object_index.html' %><%= link_url('object_index.html', 'Index') %> &raquo; <% end %>
9
+ <span class="title"><%= @breadcrumb_title %></span>
10
+ <% end %>
11
+
12
+ <div class="noframes">
13
+ <span class="title"></span>
14
+ <a id="frames_link" class="link_disabled">Frames</a> |
15
+ <a target="_top" id="noframes_link" class="link_disabled">No Frames</a>
16
+ <span class="title"></span>
17
+ </div>
18
+ </div>
@@ -0,0 +1,7 @@
1
+ <div id="footer">
2
+ Generated on <%= Time.now.strftime("%c") %> by
3
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
4
+ <%= YARD::VERSION %> and the
5
+ <a href="http://github.com/dreamcat4/yard-slipstream">yard-slipstream</a> plugin
6
+ (ruby-<%= RUBY_VERSION %>).
7
+ </div>
@@ -1,6 +1,7 @@
1
1
  <meta name="Content-Type" content="text/html; charset=<%= charset %>" />
2
2
  <title><%= @page_title %></title>
3
3
  <link rel="stylesheet" href="<%= url_for("css/style.css") %>" type="text/css" media="screen" charset="utf-8" />
4
+ <link rel="stylesheet" href="<%= url_for("css/common.css") %>" type="text/css" media="screen" charset="utf-8" />
4
5
  <link rel="stylesheet" href="<%= url_for("css/custom.css") %>" type="text/css" media="screen" charset="utf-8" />
5
6
  <% if @extra_css %>
6
7
  <link rel="stylesheet" href="<%= url_for @extra_css %>" type="text/css" media="screen" charset="utf-8" />
@@ -16,7 +16,7 @@
16
16
 
17
17
  <h2>Namespace Listing A-Z</h2>
18
18
 
19
- <ul class="toplevel"><li><%= linkify(Registry.root) %></li></ul>
19
+ <ul class="toplevel" id="files_ribbon"><li class="r1"><%= linkify(Registry.root) %></li></ul>
20
20
 
21
21
  <% i = 0 %>
22
22
  <table>
@@ -1,27 +1,27 @@
1
1
  <div id="search2">
2
2
  <% @yardoc_org = "http://yardoc.org" %>
3
3
  <% @project = "yard" %>
4
- <form class="search2" method="get" action="<%= @yardoc_org %>/search/<%= @project %>">
5
- Search: <input name="q" type="search" placeholder="Search" id="search_box2" size="30" value="" />
6
- </form>
4
+ <div class="search2_center">
5
+ <form class="search2" onsubmit="return false;" action="">
6
+ <input name="q" type="search" placeholder="Search" id="search_box2" size="30" value="" />
7
+ </form>
8
+ </div>
7
9
  <script type="text/javascript" charset="utf-8">
8
- $('#search_box2').autocomplete('<%= @yardoc_org %>/search/<%= @project %>', {
9
- width: 340,
10
- formatItem: function(item) {
11
- var values = item[0].split(",");
12
- return values[0] + (values[1] == '' ? "" : " <small>(" + values[1] + ")</small>");
10
+ $('#search_box2').focus(function(){
11
+ var search_index = relpath + 'search_index.json';
12
+ jQuery.getJSON(search_index, go_data);
13
+
14
+ function go_data(adata) {
15
+ $('#search_box2').autocomplete(adata, {
16
+ width: 300,
17
+ matchContains: true,
18
+ formatItem: function(item) {
19
+ return item.text;
20
+ }
21
+ }).result(function(event, item) {
22
+ location.href = relpath + $(item.href_tag).attr("href");
23
+ });
13
24
  }
14
- }).result(function(event, item) {
15
- var values = item[0].split(",")
16
- $('#search_box2').val(values[1]);
17
- location.href = values[3];
18
- return false;
19
25
  });
20
26
  </script>
21
- <style>
22
- .frames form.search2 { position: absolute; right: 14px; top: -6px; padding-top: 10px; }
23
- .frames #menu .noframes { float: none; }
24
- .frames #menu { float: left; }
25
- .frames #content h1 { margin-top: 15px; }
26
- </style>
27
27
  </div>
@@ -0,0 +1,69 @@
1
+ def init
2
+ @breadcrumb = []
3
+
4
+ if @file
5
+ @contents = File.read_binary(@file)
6
+ @file = File.basename(@file)
7
+ @fname = @file.gsub(/\.[^.]+$/, '')
8
+ @breadcrumb_title = "File: " + @fname
9
+ @page_title ||= @breadcrumb_title
10
+ sections :layout, [:diskfile]
11
+ elsif object
12
+ case object
13
+ when 'object_index.html'
14
+ @page_title = options[:title]
15
+ sections :layout, [:index]
16
+ when CodeObjects::Base
17
+ unless object.root?
18
+ cur = object.namespace
19
+ while !cur.root?
20
+ @breadcrumb.unshift(cur)
21
+ cur = cur.namespace
22
+ end
23
+ end
24
+
25
+ @page_title = format_object_title(object)
26
+ type = object.root? ? :module : object.type
27
+ sections :layout, [T(type)]
28
+ end
29
+ else
30
+ sections :layout, [:contents]
31
+ end
32
+ end
33
+
34
+ def contents
35
+ @contents
36
+ end
37
+
38
+ def index
39
+ @objects_by_letter = {}
40
+ objects = @objects.reject {|o| o.root? }.sort_by {|o| o.name.to_s }
41
+ objects.each {|o| (@objects_by_letter[o.name.to_s[0,1].upcase] ||= []) << o }
42
+ erb(:index)
43
+ end
44
+
45
+ def diskfile
46
+ "<div id='filecontents'>" +
47
+ case (File.extname(@file)[1..-1] || '').downcase
48
+ when 'htm', 'html'
49
+ @contents
50
+ when 'txt'
51
+ "<pre>#{@contents}</pre>"
52
+ when 'textile', 'txtile'
53
+ htmlify(@contents, :textile)
54
+ when 'markdown', 'md', 'mdown', 'mkd'
55
+ htmlify(@contents, :markdown)
56
+ else
57
+ htmlify(@contents, diskfile_shebang_or_default)
58
+ end +
59
+ "</div>"
60
+ end
61
+
62
+ def diskfile_shebang_or_default
63
+ if @contents =~ /\A#!(\S+)\s*$/ # Shebang support
64
+ @contents = $'
65
+ $1.to_sym
66
+ else
67
+ options[:markup]
68
+ end
69
+ end
@@ -0,0 +1,3 @@
1
+ <div class="method_details <%= @index == 0 ? 'first' : '' %>" id="<%= anchor_for(object) %>">
2
+ <%= yieldall %>
3
+ </div>
@@ -0,0 +1,18 @@
1
+ <p class="signature <%= 'first' if @index == 0 %>"">
2
+ <% if object.tags(:overload).size == 1 %>
3
+ <%= signature(object.tag(:overload), false) %>
4
+ <% elsif object.tags(:overload).size > 1 %>
5
+ <% object.tags(:overload).each do |overload| %>
6
+ <span class="overload"><%= signature(overload, false) %></span>
7
+ <% end %>
8
+ <% else %>
9
+ <%= signature(object, false) %>
10
+ <% end %>
11
+
12
+ <% if object.aliases.size > 0 %>
13
+ <span class="aliases">Also known as:
14
+ <span class="names"><%= object.aliases.map {|o|
15
+ "<span id='#{anchor_for(o)}'>" + h(o.name.to_s) + "</span>" }.join(", ") %></span>
16
+ </span>
17
+ <% end %>
18
+ </p>
@@ -0,0 +1,8 @@
1
+ <% scopes(attr_listing) do |list, scope| %>
2
+ <div id="<%= scope %>_attr_details" class="attr_details">
3
+ <h2><%= scope.to_s.capitalize %> Attribute Details</h2>
4
+ <% list.each_with_index do |meth, i| %>
5
+ <%= yieldall :object => meth, :index => i %>
6
+ <% end %>
7
+ </div>
8
+ <% end %>
@@ -24,6 +24,11 @@
24
24
  <% n = n == 2 ? 1 : 2 %>
25
25
  <% end %>
26
26
  <% end %>
27
+ <% if (mixed_into = mixed_into(object)).size > 0 %>
28
+ <dt class="r<%=n%>">Included in:</dt>
29
+ <dd class="r<%=n%>"><%= mixed_into.sort_by {|o| o.path }.map {|o| linkify(o) }.join(", ") %></dd>
30
+ <% n = n == 2 ? 1 : 2 %>
31
+ <% end %>
27
32
  <% unless object.root? %>
28
33
  <dt class="r<%=n%> last">Defined in:</dt>
29
34
  <dd class="r<%=n%> last"><%= erb(:defines) %></dd>
@@ -0,0 +1,14 @@
1
+ <p class="children">
2
+ <% @inner.each do |name, list| %>
3
+ <% if list.size > 0 %>
4
+ <h3 class="inherited"><%= name.to_s.capitalize %></h3>
5
+ <ul id="<%= name %>_ribbon">
6
+ <% n = 1 %>
7
+ <% list.each do |child| %>
8
+ <li class="r<%= n %>"><%= linkify(child,child.name) %></li>
9
+ <% n = n == 2 ? 1 : 2 %>
10
+ <% end %>
11
+ </ul>
12
+ <% end %>
13
+ <% end %>
14
+ </p>
@@ -2,14 +2,14 @@ include Helpers::ModuleHelper
2
2
 
3
3
  def init
4
4
  sections \
5
- :box_info,
6
5
  :header,
6
+ :box_info,
7
7
  :children,
8
8
  :local_methods,
9
9
  :inherited_methods,
10
10
  # :method_summary, [:item_summary],
11
11
  :pre_docstring, T('docstring'),
12
- :constant_summary, :inherited_constants,
12
+ :constant_summary, [T('docstring')], :inherited_constants,
13
13
  :attribute_summary, [:item_summary],
14
14
  :methodmissing, [T('method_details')],
15
15
  # :attribute_details, [T('method_details')],
@@ -79,7 +79,7 @@ def sort_listing(list)
79
79
  list.sort_by {|o| [o.scope.to_s, o.name.to_s.downcase] }
80
80
  end
81
81
 
82
- def docstring_summary(obj)
82
+ def docstring_full(obj)
83
83
  docstring = ""
84
84
  if obj.tags(:overload).size == 1 && obj.docstring.empty?
85
85
  docstring = obj.tag(:overload).docstring
@@ -91,7 +91,11 @@ def docstring_summary(obj)
91
91
  docstring = Docstring.new(obj.tag(:return).text.gsub(/\A([a-z])/) {|x| x.upcase }.strip)
92
92
  end
93
93
 
94
- docstring.summary
94
+ docstring
95
+ end
96
+
97
+ def docstring_summary(obj)
98
+ docstring_full(obj).summary
95
99
  end
96
100
 
97
101
  def scopes(list)
@@ -0,0 +1,94 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{yard-slipstream}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Dreamcat4"]
12
+ s.date = %q{2010-04-10}
13
+ s.description = %q{yard-slipstream is a yard plugin for Yard-0.5.3 and higher. Slipstream gives users an option for faster page navigation in their yard documents. We just want to optimize the most frequent lookups and remove any duplicate info. Other than that its just plain straight Yard, with all the same "look and feel" as the default template.}
14
+ s.email = %q{dreamcat4@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "features/step_definitions/yard-slipstream_steps.rb",
27
+ "features/support/env.rb",
28
+ "features/yard-slipstream.feature",
29
+ "lib/yard-slipstream.rb",
30
+ "lib/yard-slipstream/handler.rb",
31
+ "lib/yard-slipstream/legacy.rb",
32
+ "spec/spec.opts",
33
+ "spec/spec_helper.rb",
34
+ "spec/yard-slipstream_spec.rb",
35
+ "templates/default/class/html/subclasses.erb",
36
+ "templates/default/fulldoc/html/css/custom.css",
37
+ "templates/default/fulldoc/html/css/style.css",
38
+ "templates/default/fulldoc/html/js/app.js",
39
+ "templates/default/fulldoc/html/js/autocomplete.js",
40
+ "templates/default/fulldoc/html/js/live.js",
41
+ "templates/default/fulldoc/html/json_search_index.erb",
42
+ "templates/default/fulldoc/html/setup.rb",
43
+ "templates/default/layout/html/breadcrumb.erb",
44
+ "templates/default/layout/html/footer.erb",
45
+ "templates/default/layout/html/headers.erb",
46
+ "templates/default/layout/html/index.erb",
47
+ "templates/default/layout/html/search.erb",
48
+ "templates/default/layout/html/setup.rb",
49
+ "templates/default/method_details/html/header.erb",
50
+ "templates/default/method_details/html/method_signature.erb",
51
+ "templates/default/module/html/attribute_details.erb",
52
+ "templates/default/module/html/attribute_summary.erb",
53
+ "templates/default/module/html/box_info.erb",
54
+ "templates/default/module/html/children.erb",
55
+ "templates/default/module/html/local_methods.erb",
56
+ "templates/default/module/setup.rb",
57
+ "yard-slipstream.gemspec"
58
+ ]
59
+ s.homepage = %q{http://github.com/dreamcat4/yard-slipstream}
60
+ s.rdoc_options = ["--charset=UTF-8"]
61
+ s.require_paths = ["lib"]
62
+ s.rubygems_version = %q{1.3.6}
63
+ s.summary = %q{Streamlined Navigation for the default yard template}
64
+ s.test_files = [
65
+ "spec/spec_helper.rb",
66
+ "spec/yard-slipstream_spec.rb"
67
+ ]
68
+
69
+ if s.respond_to? :specification_version then
70
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
71
+ s.specification_version = 3
72
+
73
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
74
+ s.add_runtime_dependency(%q<yard>, [">= 0"])
75
+ s.add_runtime_dependency(%q<json>, [">= 0"])
76
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
77
+ s.add_development_dependency(%q<yard>, [">= 0"])
78
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
79
+ else
80
+ s.add_dependency(%q<yard>, [">= 0"])
81
+ s.add_dependency(%q<json>, [">= 0"])
82
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
83
+ s.add_dependency(%q<yard>, [">= 0"])
84
+ s.add_dependency(%q<cucumber>, [">= 0"])
85
+ end
86
+ else
87
+ s.add_dependency(%q<yard>, [">= 0"])
88
+ s.add_dependency(%q<json>, [">= 0"])
89
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
90
+ s.add_dependency(%q<yard>, [">= 0"])
91
+ s.add_dependency(%q<cucumber>, [">= 0"])
92
+ end
93
+ end
94
+