Created
December 30, 2010 03:47
-
-
Save lsegal/759428 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yard' | |
module YARD | |
Tags::Library.define_tag "Task Dependencies", :task_deps | |
Tags::Library.visible_tags << :task_deps | |
module CodeObjects | |
module Rake | |
class NamespaceObject < CodeObjects::ModuleObject | |
PREFIX = "!rake:" | |
alias tasks children | |
def path; parent == Registry.root ? "#{PREFIX}#{name}" : super end | |
def full_name; path.sub(/^#{PREFIX}/, '') end | |
def type; :module end | |
def sep; ':' end | |
end | |
class TaskObject < CodeObjects::MethodObject; end | |
end | |
end | |
module Handlers | |
class Processor; attr_accessor :desc_comments end | |
module Rake | |
class Base < Ruby::Base; namespace_only; in_file "Rakefile" end | |
class NamespaceHandler < Base | |
handles method_call(:namespace) | |
process do | |
name = statement.parameters[0].jump(:ident, :tstring_content).source | |
obj = CodeObjects::Rake::NamespaceObject.new(namespace, name) | |
register(obj) | |
parse_block(statement.last.last, namespace: obj) | |
end | |
end | |
class DescHandler < Base | |
handles method_call(:desc) | |
process do | |
parser.desc_comments = | |
statement.parameters[0].jump(:tstring_content).source | |
end | |
end | |
class TaskHandler < Base | |
handles method_call(:task) | |
process do | |
arg = statement.parameters[0][0] | |
name = arg.jump(:ident, :tstring_content).source | |
deps = arg.type == :assoc ? arg[1].source : nil | |
obj = CodeObjects::Rake::TaskObject.new(namespace, name) | |
register(obj) | |
if parser.desc_comments && obj.docstring.blank? | |
obj.docstring += parser.desc_comments | |
end | |
obj.docstring.add_tag Tags::Tag.new(:task_deps, deps) if deps | |
parser.desc_comments = nil | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment