@@ -21,35 +21,38 @@ import scala.reflect.internal.util.{FakePos, Position}
21
21
* that generates documentation from source files.
22
22
*/
23
23
class ScalaDoc {
24
+ import ScalaDoc ._
24
25
val versionMsg = s " Scaladoc ${Properties .versionString} -- ${Properties .copyrightString}"
25
26
26
27
def process (args : Array [String ]): Boolean = {
27
28
var reporter : ScalaDocReporter = null
28
- val docSettings = new doc.Settings (msg => reporter.error(FakePos ( " scaladoc " ), msg + " \n scaladoc -help gives more information" ),
29
+ val docSettings = new doc.Settings (msg => reporter.error(NoDocPos , s " $msg \n scaladoc -help gives more information " ),
29
30
msg => reporter.echo(msg),
30
31
DefaultPathFactory )
31
32
reporter = new ScalaDocReporter (docSettings)
32
- val command = new ScalaDoc . Command (args.toList, docSettings)
33
+ val command = new Command (args.toList, docSettings)
33
34
def hasFiles = command.files.nonEmpty || docSettings.uncompilableFiles.nonEmpty
34
35
35
- if (docSettings.version.value)
36
+ if (! command.ok)
37
+ ()
38
+ else if (docSettings.version.value)
36
39
reporter.echo(versionMsg)
37
40
else if (docSettings.Xhelp .value)
38
41
reporter.echo(command.xusageMsg)
39
42
else if (docSettings.Yhelp .value)
40
43
reporter.echo(command.yusageMsg)
41
44
else if (docSettings.showPlugins.value)
42
- reporter.warning(null , " Plugins are not available when using Scaladoc" )
45
+ reporter.warning(NoDocPos , " Plugins are not available when using Scaladoc" )
43
46
else if (docSettings.showPhases.value)
44
- reporter.warning(null , s " Phases are restricted when using Scaladoc. \n ${new DocFactory (reporter, docSettings).compiler.phaseDescriptions}" )
47
+ reporter.warning(NoDocPos , s " Phases are restricted when using Scaladoc. \n ${new DocFactory (reporter, docSettings).compiler.phaseDescriptions}" )
45
48
else if (docSettings.help.value || ! hasFiles)
46
49
reporter.echo(command.usageMsg)
47
50
else
48
51
try new DocFactory (reporter, docSettings).document(command.files)
49
52
catch {
50
53
case ex @ FatalError (msg) =>
51
54
if (docSettings.isDebug) ex.printStackTrace()
52
- reporter.error(null , " fatal error: " + msg)
55
+ reporter.error(NoDocPos , s " fatal error: $ msg" )
53
56
}
54
57
finally reporter.finish()
55
58
@@ -86,13 +89,14 @@ class ScalaDocReporter(settings: Settings) extends ConsoleReporter(settings) {
86
89
}
87
90
88
91
object ScalaDoc extends ScalaDoc {
92
+ val NoDocPos = FakePos (" scaladoc" )
93
+
89
94
class Command (arguments : List [String ], settings : doc.Settings ) extends CompilerCommand (arguments, settings) {
90
95
override def cmdName = " scaladoc"
91
- override def usageMsg = (
92
- createUsageMsg(" where possible scaladoc" , explain = false )(x => x.isStandard && settings.isScaladocSpecific(x.name)) +
93
- " \n\n Standard scalac options also available:" +
94
- optionsMessage(x => x.isStandard && ! settings.isScaladocSpecific(x.name))
95
- )
96
+ override def usageMsg =
97
+ sm """ ${createUsageMsg(" where possible scaladoc" , explain = false )(x => x.isStandard && settings.isScaladocSpecific(x.name))}
98
+ |Standard scalac options also available:
99
+ | ${optionsMessage(x => x.isStandard && ! settings.isScaladocSpecific(x.name))}"""
96
100
}
97
101
98
102
def main (args : Array [String ]): Unit = {
0 commit comments