Created
June 19, 2009 18:07
-
-
Save lsegal/132759 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' | |
class ClassLineHandler < YARD::Handlers::Ruby::Base | |
handles :class | |
def process | |
obj = ClassObject.new(namespace, statement[0].source) | |
obj.line_end = statement[0].line + statement.source.split("\n").size - 1 | |
end | |
end | |
class ModuleLineHandler < YARD::Handlers::Ruby::Base | |
handles :module | |
def process | |
obj = register ModuleObject.new(namespace, statement[0].source) | |
obj.line_end = statement[0].line + statement.source.split("\n").size - 1 | |
end | |
end | |
class LegacyClassLineHandler < YARD::Handlers::Ruby::Legacy::Base | |
handles TkCLASS | |
def process | |
classname = statement.tokens.to_s[/^class\s+(#{NAMESPACEMATCH})/, 1] | |
obj = ClassObject.new(namespace, classname) | |
obj.line_end = statement.line + statement.to_s(true).split("\n").size - 1 | |
end | |
end | |
class LegacyModuleLineHandler < YARD::Handlers::Ruby::Legacy::Base | |
handles TkMODULE | |
def process | |
modname = statement.tokens.to_s[/^module\s+(#{NAMESPACEMATCH})/, 1] | |
obj = register ModuleObject.new(namespace, modname) | |
obj.line_end = statement.line + statement.to_s(true).split("\n").size - 1 | |
end | |
end | |
YARD::Parser::SourceParser.parser_type = :ruby18 | |
YARD::Parser::SourceParser.parse_string <<-eof | |
module M | |
class A | |
def a; end | |
end | |
end | |
eof | |
obj = P("M::A") | |
p obj.line..obj.line_end | |
obj = P("M") | |
p obj.line..obj.line_end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment