From 5f29a264469b6ae161d9a98fe76d3f6466d82b12 Mon Sep 17 00:00:00 2001 From: David Turner Date: Sat, 4 Oct 2014 00:44:07 -0400 Subject: Make Scaladoc actually exit with non-zero exit code in case of errors, as its docs say it does. --- src/scaladoc/scala/tools/nsc/ScalaDoc.scala | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/scaladoc') diff --git a/src/scaladoc/scala/tools/nsc/ScalaDoc.scala b/src/scaladoc/scala/tools/nsc/ScalaDoc.scala index 52a0c20a11..32a6ba0ce3 100644 --- a/src/scaladoc/scala/tools/nsc/ScalaDoc.scala +++ b/src/scaladoc/scala/tools/nsc/ScalaDoc.scala @@ -18,14 +18,10 @@ class ScalaDoc { val versionMsg = "Scaladoc %s -- %s".format(Properties.versionString, Properties.copyrightString) def process(args: Array[String]): Boolean = { - var reporter: ConsoleReporter = null + var reporter: ScalaDocReporter = null val docSettings = new doc.Settings(msg => reporter.error(FakePos("scaladoc"), msg + "\n scaladoc -help gives more information"), msg => reporter.printMessage(msg)) - reporter = new ConsoleReporter(docSettings) { - // need to do this so that the Global instance doesn't trash all the - // symbols just because there was an error - override def hasErrors = false - } + reporter = new ScalaDocReporter(docSettings) val command = new ScalaDoc.Command(args.toList, docSettings) def hasFiles = command.files.nonEmpty || docSettings.uncompilableFiles.nonEmpty @@ -50,12 +46,18 @@ class ScalaDoc { } finally reporter.printSummary() - // not much point in returning !reporter.hasErrors when it has - // been overridden with constant false. - true + !reporter.reallyHasErrors } } +class ScalaDocReporter(settings: Settings) extends ConsoleReporter(settings) { + + // need to do sometimes lie so that the Global instance doesn't + // trash all the symbols just because there was an error + override def hasErrors = false + def reallyHasErrors = super.hasErrors +} + object ScalaDoc extends ScalaDoc { class Command(arguments: List[String], settings: doc.Settings) extends CompilerCommand(arguments, settings) { override def cmdName = "scaladoc" -- cgit v1.2.3