Skip to content
Browse files

Update tag docs templates

  • Loading branch information...
1 parent 4df1232 commit 88fc9750b6a431d7227fbd808b253a65169c0967 @lsegal committed Mar 21, 2012
View
4 .yardopts
@@ -5,8 +5,10 @@
--exclude /yard/rubygems/
--asset docs/images:images
--type-name-tag yard.tag:"YARD Tag"
+--type-name-tag yard.directive:"YARD Directive"
--hide-tag yard.tag
---template-path ./docs/templates
+--hide-tag yard.directive
+--load ./docs/templates.rb
-
docs/WhatsNew.md
docs/GettingStarted.md
View
9 docs/templates/default/fulldoc/html/full_list_tag.erb
@@ -1,10 +1,7 @@
<% n = 1 %>
-<% @items.each do |item| %>
- <li class="r<%= n %> <%= item.has_tag?(:deprecated) ? 'deprecated' : '' %>">
- <% tag = item.tag('yard.tag') %>
- <span class="object_link">
- <%= link_url 'tag_page.html#' + tag.name, h("@" + tag.name) %>
- </span>
+<% collect_tags.each do |tag| %>
+ <li class="r<%= n %> <%= tag.object.has_tag?(:deprecated) ? 'deprecated' : '' %>">
+ <span class="object_link"><%= tag_link tag %></span>
</li>
<% n = n == 2 ? 1 : 2 %>
<% end %>
View
4 docs/templates/default/fulldoc/html/setup.rb
@@ -1,9 +1,9 @@
def generate_tag_list
- @items = Registry.all(:method).select {|m| m.has_tag?('yard.tag') }
@list_title = "Tag List"
@list_type = "tag"
- contents = T('yard_tags').run(options.merge(:items => @items))
+ contents = T('yard_tags').run(options)
page = T('layout').run(options.merge(:contents => contents, :breadcrumb_title => "YARD Tags List"))
asset('tag_list.html', erb(:full_list))
asset('tag_page.html', page)
end
+
View
5 docs/templates/default/layout/html/setup.rb
@@ -7,11 +7,6 @@ def javascripts
super + %w(js/tag_list.js)
end
-def tag_list
- @items = Registry.all(:method).select {|m| m.has_tag?('yard.tag') }
- erb(:tag_list)
-end
-
def menu_lists
super + [{:type => 'tag', :title => 'Tags', :search_title => 'Tag List'}]
end
View
7 docs/templates/default/layout/html/tag_list.erb
@@ -1,9 +1,8 @@
-<h2>YARD Tag Listing</h2>
+<h2>Tag Listing</h2>
<ul id="tags" class="index_inline_list">
<% n = 1 %>
-<% @items.each_with_index do |item| %>
- <% tag = item.tag('yard.tag') %>
- <li class="r<%= n %>"><%= link_url 'tag_page.html#' + tag.name, h("@" + tag.name) %></li>
+<% collect_tags.each do |tag| %>
+ <li class="r<%= n %>"><%= tag_link(tag) %></li>
<% n = n == 2 ? 1 : 2 %>
<% end %>
</ul>
View
16 docs/templates/default/yard_tags/html/list.erb
@@ -1,7 +1,17 @@
-<% @items.each do |item| %>
+<h2>Tag List</h2>
+
+<% all_tags.each do |tag| %>
<div class="method_details">
- <% tag = item.tag('yard.tag') %>
<p class="signature" id="<%= h tag.name %>"><%= tag_signature tag %></p>
- <%= yieldall :object => item %>
+ <%= yieldall :object => tag.object %>
+</div>
+<% end %>
+
+<h2>Directive List</h2>
+
+<% all_directives.each do |tag| %>
+<div class="method_details">
+ <p class="signature" id="<%= h tag.name %>"><%= tag_signature tag %></p>
+ <%= yieldall :object => tag.object %>
</div>
<% end %>
View
7 docs/templates/default/yard_tags/html/setup.rb
@@ -4,14 +4,19 @@ def init
def tag_signature(tag)
types = tag.types || []
- signature = "<strong>@#{tag.name}</strong> "
+ prefix = tag.tag_name == 'yard.directive' ? '@!' : '@'
+ signature = "<strong>#{prefix}#{tag.name}</strong> "
case types.first
when 'with_name'
signature += "name description"
when 'with_types'
signature += "[Types] description"
when 'with_types_and_name'
signature += "name [Types] description"
+ when 'with_title_and_text'
+ signature += "title | description"
+ when 'with_types_and_title'
+ signature += "[Types] title | description"
else
signature += "description"
end
View
28 lib/yard/tags/library.rb
@@ -91,7 +91,7 @@ def factory_method_for(tag)
# @return [nil] if the tag is freeform text
# @since 0.8.0
def factory_method_for_directive(directive)
- @directive_factory_methods[directive]
+ @directive_factory_classes[directive]
end
# Sets the list of tags to display when rendering templates. The order of
@@ -129,6 +129,7 @@ def sorted_labels
#
# @!macro [attach] yard.tag
# @!method $2_tag
+ # @!visibility private
# @yard.tag $2 [$3] $1
# @param [#to_s] tag the tag name to create
# @param [#to_s, Class<Tag>] meth the {Tag} factory method to call when
@@ -155,26 +156,35 @@ def #{tag_meth}(text)
@factory_methods.update(tag => meth)
tag
end
-
- def define_directive(tag, tag_meth = nil, directive_tag_meth = nil)
+
+ # @macro [attach] yard.directive
+ # @!method $2_directive
+ # @!visibility private
+ # @yard.directive $1 [$2] $3
+ # @overload define_directive(tag, tag_meth = nil, directive_class)
+ # Convenience method to define a new directive using a {Tag} factory
+ # method and {Directive} subclass that implements the directive
+ # callbacks.
+ # @see define_tag
+ def define_directive(tag, tag_meth = nil, directive_class = nil)
directive_meth = directive_method_name(tag)
- if directive_tag_meth.nil?
- tag_meth, directive_tag_meth = nil, tag_meth
+ if directive_class.nil?
+ tag_meth, directive_class = nil, tag_meth
end
class_eval <<-eof, __FILE__, __LINE__
def #{directive_meth}(tag, parser)
directive_call(tag, parser)
end
eof
-
+
@factory_methods ||= SymbolHash.new(false)
@factory_methods.update(tag => tag_meth)
- @directive_factory_methods ||= SymbolHash.new(false)
- @directive_factory_methods.update(tag => directive_tag_meth)
+ @directive_factory_classes ||= SymbolHash.new(false)
+ @directive_factory_classes.update(tag => directive_class)
tag
end
-
+
def tag_method_name(tag_name)
tag_or_directive_method_name(tag_name)
end

0 comments on commit 88fc975

Please sign in to comment.
Something went wrong with that request. Please try again.