2009-10-08 03:27:53 +02:00
|
|
|
/* sbt -- Simple Build Tool
|
|
|
|
|
* Copyright 2008, 2009 Mark Harrah
|
|
|
|
|
*/
|
|
|
|
|
package xsbt
|
|
|
|
|
|
|
|
|
|
import xsbti.Logger
|
2009-12-20 18:02:49 +01:00
|
|
|
import Log.debug
|
2009-10-08 03:27:53 +02:00
|
|
|
|
|
|
|
|
class ScaladocInterface
|
|
|
|
|
{
|
2009-11-30 00:13:47 +01:00
|
|
|
def run(args: Array[String], maximumErrors: Int, log: Logger) = (new Runner(args, maximumErrors, log)).run
|
|
|
|
|
}
|
|
|
|
|
private class Runner(args: Array[String], maximumErrors: Int, log: Logger)
|
|
|
|
|
{
|
2010-03-26 12:55:02 +01:00
|
|
|
import scala.tools.nsc.{doc, Global}
|
2010-05-14 00:31:37 +02:00
|
|
|
val docSettings: doc.Settings = new doc.Settings(Log.settingsError(log))
|
2010-03-26 12:55:02 +01:00
|
|
|
val command = Command(args.toList, docSettings)
|
2010-05-14 00:31:37 +02:00
|
|
|
val reporter = LoggerReporter(docSettings, maximumErrors, log)
|
|
|
|
|
def noErrors = !reporter.hasErrors && command.ok
|
2009-11-30 00:13:47 +01:00
|
|
|
|
|
|
|
|
import forScope._
|
|
|
|
|
def run()
|
2009-10-08 03:27:53 +02:00
|
|
|
{
|
2009-12-20 18:02:49 +01:00
|
|
|
debug(log, "Calling Scaladoc with arguments:\n\t" + args.mkString("\n\t"))
|
2010-05-14 00:31:37 +02:00
|
|
|
if(noErrors)
|
2009-10-08 03:27:53 +02:00
|
|
|
{
|
2009-12-20 18:02:49 +01:00
|
|
|
import doc._ // 2.8 trunk and Beta1-RC4 have doc.DocFactory. For other Scala versions, the next line creates forScope.DocFactory
|
|
|
|
|
val processor = new DocFactory(reporter, docSettings)
|
2009-11-30 00:13:47 +01:00
|
|
|
processor.document(command.files)
|
2009-10-08 03:27:53 +02:00
|
|
|
}
|
2009-11-30 00:13:47 +01:00
|
|
|
reporter.printSummary()
|
2010-05-14 00:31:37 +02:00
|
|
|
if(!noErrors) throw new InterfaceCompileFailed(args, "Scaladoc generation failed")
|
2009-11-30 00:13:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object forScope
|
|
|
|
|
{
|
2009-12-20 18:02:49 +01:00
|
|
|
class DocFactory(reporter: LoggerReporter, docSettings: doc.Settings) // 2.7 compatibility
|
2009-10-08 03:27:53 +02:00
|
|
|
{
|
2009-11-30 00:13:47 +01:00
|
|
|
object compiler extends Global(command.settings, reporter)
|
2009-10-08 03:27:53 +02:00
|
|
|
{
|
2009-11-30 00:13:47 +01:00
|
|
|
override def onlyPresentation = true
|
2009-12-20 18:02:49 +01:00
|
|
|
class DefaultDocDriver // 2.8 source compatibility
|
2009-11-30 00:13:47 +01:00
|
|
|
{
|
|
|
|
|
assert(false)
|
|
|
|
|
def process(units: Iterator[CompilationUnit]) = error("for 2.8 compatibility only")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
def document(ignore: Seq[String])
|
|
|
|
|
{
|
|
|
|
|
import compiler._
|
|
|
|
|
val run = new Run
|
|
|
|
|
run compile command.files
|
|
|
|
|
|
|
|
|
|
val generator =
|
|
|
|
|
{
|
|
|
|
|
import doc._
|
|
|
|
|
new DefaultDocDriver
|
|
|
|
|
{
|
|
|
|
|
lazy val global: compiler.type = compiler
|
|
|
|
|
lazy val settings = docSettings
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
generator.process(run.units)
|
2009-10-08 03:27:53 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|