Skip to content

Commit 5f29a26

Browse files
committed
Make Scaladoc actually exit with non-zero exit code in case of errors,
as its docs say it does.
1 parent 192d65f commit 5f29a26

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/scaladoc/scala/tools/nsc/ScalaDoc.scala

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@ class ScalaDoc {
1818
val versionMsg = "Scaladoc %s -- %s".format(Properties.versionString, Properties.copyrightString)
1919

2020
def process(args: Array[String]): Boolean = {
21-
var reporter: ConsoleReporter = null
21+
var reporter: ScalaDocReporter = null
2222
val docSettings = new doc.Settings(msg => reporter.error(FakePos("scaladoc"), msg + "\n scaladoc -help gives more information"),
2323
msg => reporter.printMessage(msg))
24-
reporter = new ConsoleReporter(docSettings) {
25-
// need to do this so that the Global instance doesn't trash all the
26-
// symbols just because there was an error
27-
override def hasErrors = false
28-
}
24+
reporter = new ScalaDocReporter(docSettings)
2925
val command = new ScalaDoc.Command(args.toList, docSettings)
3026
def hasFiles = command.files.nonEmpty || docSettings.uncompilableFiles.nonEmpty
3127

@@ -50,12 +46,18 @@ class ScalaDoc {
5046
}
5147
finally reporter.printSummary()
5248

53-
// not much point in returning !reporter.hasErrors when it has
54-
// been overridden with constant false.
55-
true
49+
!reporter.reallyHasErrors
5650
}
5751
}
5852

53+
class ScalaDocReporter(settings: Settings) extends ConsoleReporter(settings) {
54+
55+
// need to do sometimes lie so that the Global instance doesn't
56+
// trash all the symbols just because there was an error
57+
override def hasErrors = false
58+
def reallyHasErrors = super.hasErrors
59+
}
60+
5961
object ScalaDoc extends ScalaDoc {
6062
class Command(arguments: List[String], settings: doc.Settings) extends CompilerCommand(arguments, settings) {
6163
override def cmdName = "scaladoc"

0 commit comments

Comments
 (0)