Permalink
Browse files

Display documentation for Directive class as documentation for define…

…_directive
  • Loading branch information...
lsegal committed Apr 29, 2012
1 parent 35e3a39 commit 905b8cf51d19c106a1aeab1d74385817e01e09bf
Showing with 20 additions and 12 deletions.
  1. +5 −1 docs/templates/default/yard_tags/html/list.erb
  2. +15 −11 docs/templates/plugin.rb
@@ -7,7 +7,11 @@
id="<%= tag.name %>" toc-title="<%= tag_link_name(tag) %>">
<%= tag_signature tag %>
</h3>
- <%= yieldall :object => tag.object %>
+ <% if name == "Directive" %>
+ <%= yieldall :object => P("YARD::Tags::#{tag.text}") %>
+ <% else %>
+ <%= yieldall :object => tag.object %>
+ <% end %>
</div>
<% end %>
View
@@ -23,18 +23,22 @@ def tag_link_name(tag)
h(prefix + tag.name)
end
- def url_for(*args)
- if object.is_a?(CodeObjects::Base) &&
- (object.tag('yard.tag') || object.tag('yard.directive'))
- obj, self.object = object, Registry.root
- url = super
- self.object = obj
- url
- else
- super
+ # Wrap url_for and url_for_file to rewrite object when generating docs for
+ # yard.tag/directive objects.
+ %w(url_for, url_for_file).each do |meth|
+ self.class.send(:define_method, meth) do
+ if object.is_a?(CodeObjects::Base) &&
+ (object.tag('yard.tag') || object.tag('yard.directive') ||
+ (object.type == :class && object.superclass.name == :Directive))
+ obj, self.object = object, Registry.root
+ url = super
+ self.object = obj
+ url
+ else
+ super
+ end
end
end
- alias url_for_file url_for
def linkify(*args)
if args.first.is_a?(String)
@@ -58,4 +62,4 @@ def linkify(*args)
end
Template.extra_includes << TagTemplateHelper
-Engine.register_template_path(File.dirname(__FILE__) + '/templates')
+Engine.register_template_path(File.dirname(__FILE__))

0 comments on commit 905b8cf

Please sign in to comment.