Permalink
Browse files

Added command summary

  • Loading branch information...
1 parent e0f8aab commit ec2a6edaeee0d47518e48055a375b8395284e7e1 @koraktor committed Nov 23, 2010
View
@@ -9,11 +9,12 @@
base_path = File.join File.dirname(__FILE__), 'yard-rubikon'
require File.join base_path, 'common'
+require File.join base_path, 'code_objects', 'command_object'
handler_path = File.join base_path, 'handlers'
handler_path = File.join handler_path, 'legacy' if RUBY18
-handlers = %w{application}
+handlers = %w{application command}
handlers.each do |handler|
require File.join handler_path, "#{handler}_handler"
end
@@ -0,0 +1,30 @@
+# This code is free software; you can redistribute it and/or modify it under
+# the terms of the new BSD License.
+#
+# Copyright (c) 2010, Sebastian Staudt
+
+module Rubikon
+
+ module YARD
+
+ module CodeObjects
+
+ class CommandObject < ::YARD::CodeObjects::Base
+
+ def aliases; [] end
+
+ def attr_info; nil end
+
+ def parameters; [] end
+
+ def scope; :public end
+
+ def sep; '>>' end
+
+ end
+
+ end
+
+ end
+
+end
@@ -0,0 +1,32 @@
+# This code is free software; you can redistribute it and/or modify it under
+# the terms of the new BSD License.
+#
+# Copyright (c) 2010, Sebastian Staudt
+
+module Rubikon
+
+ module YARD
+
+ module Handlers
+
+ class RubikonCommandHandler < ::YARD::Handlers::Ruby::Base
+
+ handles method_call(:command)
+ namespace_only
+
+ process do
+ name = statement.parameters.first.jump(:tstring_content, :ident).source
+ if namespace.type == :class && namespace.inheritance_tree.include?(RUBIKON_APPLICATION_BASE)
+ register CodeObjects::CommandObject.new(namespace, name, :public) do |o|
+ o.source = statement.source
+ end
+ end
+ end
+
+ end
+
+ end
+
+ end
+
+end
@@ -0,0 +1,39 @@
+# This code is free software; you can redistribute it and/or modify it under
+# the terms of the new BSD License.
+#
+# Copyright (c) 2010, Sebastian Staudt
+
+module Rubikon
+
+ module YARD
+
+ module Handlers
+
+ module Legacy
+
+ class CommandHandler < ::YARD::Handlers::Ruby::Legacy::Base
+
+ MATCH = /\Acommand\s+:?(.+?)\s+(do|\{)/
+ handles MATCH
+
+ process do
+ command_args = statement.tokens.to_s[MATCH, 1].split(',')
+ name = command_args[0].strip
+
+ if namespace.type == :class &&
+ namespace.inheritance_tree.include?(RUBIKON_APPLICATION_BASE)
+ register CodeObjects::CommandObject.new(namespace, name, :class) do |o|
+ o.source = statement.source
+ end
+ end
+ end
+
+ end
+
+ end
+
+ end
+
+ end
+
+end
@@ -0,0 +1,26 @@
+<% unless commands.empty? %>
+ <h2>
+ Command Summary
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
+ </h2>
+
+ <ul class="summary">
+ <% commands.each do |cmd| %>
+ <li class="<%= cmd.has_tag?(:deprecated) ? 'deprecated' : '' %>">
+ <span class="summary_signature">
+ <% title = "&gt;&gt; #{h cmd.name}"
+ link_title = "#{h cmd.name} (#{cmd.type})" %>
+ <%= link_url(url_for(cmd), title, :title => link_title) %>
+ </span>
+ <span class="rubikon-command note title">Command</span>
+ <% if cmd.has_tag?(:deprecated) %><span class="deprecated note title">Deprecated</span><% end %>
+
+ <% if cmd.has_tag?(:deprecated) %>
+ <span class="summary_desc"><strong>Deprecated.</strong> <%= htmlify_line cmd.tag(:deprecated).text %></span>
+ <% else %>
+ <span class="summary_desc"><%= htmlify_line docstring_summary(cmd) %></span>
+ <% end %>
+ </li>
+ <% end %>
+ </ul>
+<% end %>
@@ -6,4 +6,11 @@
def init
super
sections.place(:rubikon).after(T('docstring'))
+ sections.place(:command_summary).after(:attribute_summary)
+end
+
+def commands
+ object.children.select do |o|
+ o.is_a? Rubikon::YARD::CodeObjects::CommandObject
+ end
end

0 comments on commit ec2a6ed

Please sign in to comment.