require 'java'
module Java
module Doc
def self.parse(source_path, &block)
context = com.sun.tools.javac.util.Context.new
options = com.sun.tools.javac.util.Options.instance context
options.put '-sourcepath', source_path
com.sun.tools.javadoc.Messager.preRegister context, "javadoc"
tool = com.sun.tools.javadoc.JavadocTool.make0 context
sub_packages = com.sun.tools.javac.util.List.of 'org', 'com'
options_list = com.sun.tools.javac.util.List.nil
empty = com.sun.tools.javac.util.List.nil
filter = com.sun.tools.javadoc.ModifierFilter.new com.sun.tools.javadoc.ModifierFilter::ALL_ACCESS
root = tool.getRootDocImpl('en', 'utf-8', filter, empty, options_list, false, sub_packages, empty, false, false, false)
block.call(root) if block
return root
end
end
end