class Buildr::Doc::Scaladoc
Public Instance Methods
generate(sources, target, options = {})
click to toggle source
# File lib/buildr/scala/doc.rb, line 40 def generate(sources, target, options = {}) cmd_args = [ '-d', target] cmd_args << '-verbose' if trace?(:scaladoc) options.reject { |key, value| [:sourcepath, :classpath].include?(key) }. each { |key, value| value.invoke if value.respond_to?(:invoke) }. each do |key, value| case value when true, nil cmd_args << "-#{key}" when false cmd_args << "-no#{key}" when Hash value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s } else cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten end end [:sourcepath, :classpath].each do |option| Array(options[option]).flatten.tap do |paths| cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty? end end cmd_args += sources.flatten.uniq unless Buildr.application.options.dryrun info "Generating Scaladoc for #{project.name}" trace (['scaladoc'] + cmd_args).join(' ') Java.load begin if Scala.version?(2.7, 2.8) Java.scala.tools.nsc.ScalaDoc.process(cmd_args.to_java(Java.java.lang.String)) else scaladoc = Java.scala.tools.nsc.ScalaDoc.new scaladoc.process(cmd_args.to_java(Java.java.lang.String)) end rescue => e fail 'Failed to generate Scaladocs, see errors above: ' + e end end end