Permalink
Browse files

Initial commit

Support for adding a note to Rubikon application classes
  • Loading branch information...
0 parents commit b15b460e853a97aed7f93b6619c03390beac1cd5 @koraktor committed Nov 22, 2010
25 LICENSE
@@ -0,0 +1,25 @@
+Copyright (c) 2010, Sebastian Staudt
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of the author nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 README.md
@@ -0,0 +1,22 @@
+YARD plugin for Rubikon
+=======================
+
+This plugin provides documentation support for [Rubikon][1] applications using
+YARD.
+
+## License
+
+This code is free software; you can redistribute it and/or modify it under the
+terms of the new BSD License. A copy of this license can be found in the
+LICENSE file.
+
+## Credits
+
+ * Sebastian Staudt – koraktor(at)gmail.com
+
+## See also
+
+ * [Rubikon][1]
+ * [YARD](http://yardoc.org)
+
+ [1]: http://koraktor.github.com/rubikon
19 lib/yard-rubikon.rb
@@ -0,0 +1,19 @@
+# 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
+
+template_path = File.join File.dirname(__FILE__), '..', 'templates'
+YARD::Templates::Engine.register_template_path template_path
+
+base_path = File.join File.dirname(__FILE__), 'yard-rubikon'
+
+require File.join base_path, 'common'
+
+handler_path = File.join base_path, 'handlers'
+handler_path = File.join handler_path, 'legacy' if RUBY18
+
+handlers = %w{application}
+handlers.each do |handler|
+ require File.join handler_path, "#{handler}_handler"
+end
15 lib/yard-rubikon/common.rb
@@ -0,0 +1,15 @@
+# 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
+
+ RUBIKON_APPLICATION_BASE =
+ ::YARD::CodeObjects::ClassObject.new(P('Rubikon::Application'), :Base)
+
+ end
+
+end
32 lib/yard-rubikon/handlers/application_handler.rb
@@ -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 RubikonApplicationHandler < ::YARD::Handlers::Ruby::ClassHandler
+
+ handles :class
+
+ process do
+ classname = statement[0].source
+ object = ::YARD::CodeObjects::ClassObject.new(namespace, classname)
+
+ if object.inheritance_tree.include? RUBIKON_APPLICATION_BASE
+ object.dynamic = true
+ object[:rubikon] = true
+ end
+ end
+
+ end
+
+ end
+
+ end
+
+end
38 lib/yard-rubikon/handlers/legacy/application_handler.rb
@@ -0,0 +1,38 @@
+# 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 ApplicationHandler < ::YARD::Handlers::Ruby::Legacy::ClassHandler
+
+ handles TkCLASS
+
+ process do
+ if statement.tokens.to_s =~ /^class\s+(#{NAMESPACEMATCH})\s*(?:<\s*(.+)|\Z)/m
+ classname = $1
+ object = ::YARD::CodeObjects::ClassObject.new(namespace, classname)
+
+ if object.inheritance_tree.include? RUBIKON_APPLICATION_BASE
+ object.dynamic = true
+ object[:rubikon] = true
+ end
+ end
+ end
+
+ end
+
+ end
+
+ end
+
+ end
+
+end
4 templates/default/class/html/rubikon.erb
@@ -0,0 +1,4 @@
+<% if object[:rubikon] %>
+ <em>This class uses <a href="http://koraktor.github.com/rubikon">Rubikon</a>
+ to provide a command-line interface.</em>
+<% end %>
9 templates/default/class/setup.rb
@@ -0,0 +1,9 @@
+# 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
+
+def init
+ super
+ sections.place(:rubikon).after(T('docstring'))
+end

0 comments on commit b15b460

Please sign in to comment.