Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

The @overall tag, which makes a class be rendered on the index page

  • Loading branch information...
commit e30907511266f8345c33e9f6dabd37b198248c6b 1 parent 1d4ce34
Alexey Ilyichev authored
View
1  lib/yard-rest-plugin.rb
@@ -19,4 +19,5 @@
YARD::Tags::Library.define_tag("Headers", :header, :with_name)
YARD::Tags::Library.define_tag("Response codes", :response_code, :with_name)
YARD::Tags::Library.define_tag("Image", :image)
+YARD::Tags::Library.define_tag("Overall", :overall)
View
20 lib/yard-rest-plugin/base_helper.rb
@@ -11,23 +11,31 @@ def run_verifier(list)
end
reject_module(list)
- reject_without_url(list)
- reject_without_topic(list)
+ end
+
+ def index_objects(list)
+ res = reject_module(list)
+ res = reject_without_url(res)
+ res = reject_without_topic(res)
+ res = reject_overall(res)
- list
+ res
end
def reject_module(list)
- list.reject! { |object| [:root, :module].include?(object.type) }
+ list.reject { |object| [:root, :module].include?(object.type) }
end
def reject_without_url(list)
- list.reject! { |object| [:class, :method].include?(object.type) and object.tags("url").empty? }
+ list.reject { |object| [:class, :method].include?(object.type) and object.tags("url").empty? }
end
def reject_without_topic(list)
- list.reject! { |object| [:class].include?(object.type) and object.tags("topic").empty? }
+ list.reject { |object| [:class].include?(object.type) and object.tags("topic").empty? }
end
+ def reject_overall(list)
+ list.reject { |object| object.has_tag?('overall') }
+ end
end
end
View
7 templates/rest/class/html/header.erb
@@ -1,9 +1,10 @@
<div class="service">
<h1>
- <span class="minor_heading">Resource: </span>
- <% if object.tags("url").size <= 1 %>
+ <% if object.tags("url").size == 1 %>
+ <span class="minor_heading">Resource: </span>
<%= object.tag("url").text %>
- <% else %>
+ <% elsif object.tags("url").size > 1 %>
+ <span class="minor_heading">Resource: </span>
<ul>
<% object.tags("url").each do |url_tag| %>
<li><%= url_tag.text %></li>
View
14 templates/rest/class/html/method_details_list.erb
@@ -1,6 +1,8 @@
-<div id="Services" class="method_details_list">
-<h2>Actions</h2>
-<% @meths.each_with_index do |meth, i| %>
- <%= yieldall :object => meth, :index => i %>
-<% end %>
-</div>
+<% unless @meths.empty? %>
+ <div id="Services" class="method_details_list">
+ <h2>Actions</h2>
+ <% @meths.each_with_index do |meth, i| %>
+ <%= yieldall :object => meth, :index => i %>
+ <% end %>
+ </div>
+<% end %>
View
25 templates/rest/fulldoc/html/setup.rb
@@ -3,20 +3,20 @@
def init
options[:objects] = objects = run_verifier(options[:objects])
- options[:files] = ([options[:readme]] + options[:files]).compact.map {|t| t.to_s }
+ options[:files] = ([options[:readme]] + options[:files]).compact.map { |t| t.to_s }
options[:readme] = options[:files].first
options[:title] ||= "Documentation by YARD #{YARD::VERSION}"
-
+
generate_assets
serialize('_index.html')
- options[:files].each_with_index do |file, i|
- serialize_file(file, i == 0 ? options[:title] : nil)
+ options[:files].each_with_index do |file, i|
+ serialize_file(file, i == 0 ? options[:title] : nil)
end
options.delete(:objects)
options.delete(:files)
-
- objects.each do |object|
+
+ objects.each do |object|
begin
serialize(object)
rescue => e
@@ -61,11 +61,11 @@ def asset(path, content)
end
def generate_assets
- %w( js/jquery.js js/app.js js/full_list.js
- css/style.css css/full_list.css css/common.css ).each do |file|
+ %w(js/jquery.js js/app.js js/full_list.js
+ css/style.css css/full_list.css css/common.css).each do |file|
asset(file, file(file, true))
end
-
+
@object = Registry.root
generate_resource_list
generate_topic_list
@@ -73,21 +73,20 @@ def generate_assets
end
def generate_topic_list
- topic_objects = options[:objects].reject {|o| o.root? || !is_class?(o) || o.tags('url').empty? || o.tags('topic').empty? }
+ topic_objects = index_objects(options[:objects]).reject { |o| o.root? }
@topics = {}
-
+
topic_objects.each do |object|
object.tags('topic').each { |topic| (@topics[topic.text] ||= []) << object }
end
-
@list_title = "Topic List"
@list_type = "topic"
asset('topic_list.html', erb(:full_list))
end
def generate_resource_list
- @items = options[:objects]
+ @items = index_objects(options[:objects])
@list_title = "Resource List"
@list_type = "resource"
asset('resource_list.html', erb(:full_list))
View
8 templates/rest/layout/html/index.erb
@@ -1,6 +1,10 @@
<div id="listing">
<h1 class="noborder title"><%= options[:title] %></h1>
+ <% @overall_objects.each do |obj| %>
+ <%= yieldall :object => obj %>
+ <% end %>
+
<% if @files && @files.size > 0 %>
<h2>Files A-Z</h2>
<ul id="files">
@@ -43,12 +47,12 @@
<h2>Resources A-Z</h2>
<ul>
<% urls = [] %>
- <% @objects.each do |object| %>
+ <% @resources.each do |object| %>
<% object.tags("url").each do |url_tag| %>
<% urls << [url_tag.text, object] %>
<% end %>
<% end %>
- <% urls.sort_by(&:first).each do |elem| %>
+ <% urls.sort_by(& :first).each do |elem| %>
<li><%= linkify(elem.last, elem.first) %></li>
<% end %>
</ul>
View
14 templates/rest/layout/html/setup.rb
@@ -12,10 +12,9 @@ def init
elsif object
case object
when '_index.html'
- sections :layout, [:index]
+ sections :layout, [:index, [T('class')]]
when CodeObjects::Base
type = object.root? ? :module : object.type
- #sections :layout, [T(type), T('disqus')]
sections :layout, [T(type)]
end
else
@@ -29,16 +28,17 @@ def contents
def index
- legitimate_objects = @objects.reject {|o| o.root? || !is_class?(o) || o.tags('url').empty?}
- topic_objects = legitimate_objects.reject{|o| o.tags('topic').empty? }
+ legitimate_objects = index_objects(@objects).reject {|o| o.root? }
@topics = {}
-
- topic_objects.each do |object|
+
+ legitimate_objects.each do |object|
object.tags('topic').each { |topic| (@topics[topic.text] ||= []) << object }
end
@resources = legitimate_objects.sort_by {|o| o.tags('url').first.text }
-
+
+ @overall_objects = @objects.find_all {|o| o.has_tag?('overall')}.sort_by {|o| o.tag('overall').text}
+
erb(:index)
end
Please sign in to comment.
Something went wrong with that request. Please try again.