Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add initial custom templates for tags documentation

  • Loading branch information...
commit 12fa52f4d5928b2987f36bdd46ead1c656662989 1 parent 050518e
@lsegal authored
View
3  .yardopts
@@ -4,6 +4,9 @@
--exclude /server/templates/
--exclude /yard/rubygems/
--asset docs/images:images
+--type-name-tag yard.tag:"YARD Tag"
+--hide-tag yard.tag
+--template-path ./docs/templates
-
docs/WhatsNew.md
docs/GettingStarted.md
View
10 docs/templates/default/fulldoc/html/full_list_tag.erb
@@ -0,0 +1,10 @@
+<% 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>
+ </li>
+ <% n = n == 2 ? 1 : 2 %>
+<% end %>
View
7 docs/templates/default/fulldoc/html/js/tag_list.js
@@ -0,0 +1,7 @@
+function featureSearchFrameLinks() {
+ $('#tag_list_link').click(function() {
+ toggleSearchFrame(this, relpath + 'tag_list.html');
+ });
+}
+
+$(featureSearchFrameLinks);
View
9 docs/templates/default/fulldoc/html/setup.rb
@@ -0,0 +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))
+ 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
17 docs/templates/default/layout/html/setup.rb
@@ -0,0 +1,17 @@
+def init
+ super
+ sections.place(:tag_list).after_any(:files)
+end
+
+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
10 docs/templates/default/layout/html/tag_list.erb
@@ -0,0 +1,10 @@
+<h2>YARD 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>
+ <% n = n == 2 ? 1 : 2 %>
+<% end %>
+</ul>
+<div class="clear"></div>
View
7 docs/templates/default/yard_tags/html/list.erb
@@ -0,0 +1,7 @@
+<% @items.each do |item| %>
+<div class="method_details">
+ <% tag = item.tag('yard.tag') %>
+ <p class="signature" id="<%= h tag.name %>"><%= tag_signature tag %></p>
+ <%= yieldall :object => item %>
+</div>
+<% end %>
View
19 docs/templates/default/yard_tags/html/setup.rb
@@ -0,0 +1,19 @@
+def init
+ sections :list, [T('docstring')]
+end
+
+def tag_signature(tag)
+ types = tag.types || []
+ signature = "<strong>@#{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"
+ else
+ signature += "description"
+ end
+ signature
+end
View
11 lib/yard/tags/library.rb
@@ -241,7 +241,18 @@ def directive_create(tag_name, tag_buf, parser)
send(meth, tag, parser)
end
+ # @macro [attach] yard.tag
+ # @method $2_tag
+ # @visibility private
+ # @yard.tag $2 [$3] $1
+ #
+ # Defines the abstract tag
+ #
+ # @example
+ # # @abstract
+ # class Foo; end
define_tag "Abstract", :abstract
+
define_tag "API Visibility", :api
define_tag "Attribute", :attr, :with_types_and_name
define_tag "Attribute Getter", :attr_reader, :with_types_and_name
Please sign in to comment.
Something went wrong with that request. Please try again.