@@ -14,11 +14,12 @@ import java.nio.file.Files
14
14
15
15
import dotty .tools .dotc .config .Settings ._
16
16
17
- abstract class Scala3Args extends SettingGroup :
17
+ abstract class Scala3Args (reportError : String => Unit ) extends SettingGroup :
18
+ private val tastyRootsUsage = " Roots where tools should look for tasty files. Directories and jars are accepted"
18
19
val tastyRoots : Setting [String ] =
19
- StringSetting (" --tastyRoots" , " tastyRoots" , " Roots where tools should look for tasty files " , " " , aliases = List (" -t" ))
20
+ StringSetting (" --tastyRoots" , " tastyRoots" , tastyRootsUsage , " " , aliases = List (" -t" ))
20
21
val tastyRootsAlias : Setting [String ] =
21
- StringSetting (" -t" , " tastyRoots" , " Roots where tools should look for tasty files " , " " , aliases = List (" -t" ))
22
+ StringSetting (" -t" , " tastyRoots" , tastyRootsUsage , " " , aliases = List (" -t" ))
22
23
23
24
val dest : Setting [String ] =
24
25
StringSetting (" --dest" , " dest" , " Output to generate documentation to" , " " , aliases = List (" -d" ))
@@ -42,17 +43,24 @@ abstract class Scala3Args extends SettingGroup:
42
43
val docsRootAlias : Setting [String ] =
43
44
StringSetting (" -p" , " docs" , " Root of project docs" , " " , aliases = List (" -p" ))
44
45
45
-
46
46
val sourceLinks : Setting [String ] =
47
- StringSetting (" --sources" , " sources" , " Links to source files provided in convention: local_directory=remote_directory#line_suffix" , " " )
48
- val sourceLinksAlias : Setting [String ] =
49
- StringSetting (" -s" , " sources" , " Links to source files provided in convention: local_directory=remote_directory#line_suffix" , " " )
47
+ StringSetting (" --sources" , " sources" , SourceLinks .usage, " " )
48
+ val sourceLinksAlias1 : Setting [String ] =
49
+ StringSetting (" -s" , " sources" , SourceLinks .usage, " " )
50
+ val sourceLinksAlias2 : Setting [String ] =
51
+ StringSetting (" -doc-source-url" , " sources" , SourceLinks .usage, " " )
50
52
51
53
val projectTitle : Setting [String ] =
52
54
StringSetting (" --projectTitle" , " projectTitle" , " Title of the project used in documentation" , " " )
55
+ val projectTitleAlias : Setting [String ] =
56
+ StringSetting (" -doc-title" , " projectTitle" , " Title of the project used in documentation" , " " )
57
+
53
58
54
59
val projectVersion : Setting [String ] =
55
60
StringSetting (" --projectVersion" , " projectVersion" , " Version of the project used in documentation" , " " )
61
+ val projectVersionAlias : Setting [String ] =
62
+ StringSetting (" -doc-version" , " projectVersion" , " Version of the project used in documentation" , " " )
63
+
56
64
57
65
val projectLogo : Setting [String ] =
58
66
StringSetting (" --projectLogo" , " projectLogo" , " Relative path to logo of the project" , " " )
@@ -70,15 +78,16 @@ abstract class Scala3Args extends SettingGroup:
70
78
def extract (args : List [String ]) =
71
79
val initialSummary = ArgsSummary (defaultState, args, errors = Nil , warnings = Nil )
72
80
val res = processArguments(initialSummary, processAll = true , skipped = Nil )
73
- // TODO!
74
- if res.errors.nonEmpty then sys.error (s " Unable to parse arguments: \n ${res.errors.mkString(" \n " )}" )
81
+
82
+ if res.errors.nonEmpty then reportError (s " Unable to parse arguments: \n ${res.errors.mkString(" \n " )}" )
75
83
76
84
val parsedSyntax = syntax.valueIn(res.sstate) match
77
85
case " " => None
78
86
case other =>
79
87
Args .CommentSyntax .fromString(other) match
80
88
case None =>
81
- sys.error(s " unrecognized value for --syntax option: $other" )
89
+ reportError(s " unrecognized value for --syntax option: $other" )
90
+ None
82
91
case some => some
83
92
84
93
def parseOptionalArg (args : Setting [String ]* ) =
@@ -92,11 +101,11 @@ abstract class Scala3Args extends SettingGroup:
92
101
parseOptionalArg(classpath, classpathAlias1, classpathAlias2).getOrElse(System .getProperty(" java.class.path" )),
93
102
parseOptionalArg(dest, destAlias).fold(defaultDest())(new File (_)),
94
103
parseOptionalArg(docsRoot, docsRootAlias),
95
- parseOptionalArg(projectVersion),
96
- parseOptionalArg(projectTitle),
104
+ parseOptionalArg(projectVersion, projectVersionAlias ),
105
+ parseOptionalArg(projectTitle, projectTitleAlias ),
97
106
parseOptionalArg(projectLogo),
98
107
parsedSyntax,
99
- parseOptionalArg(sourceLinks, sourceLinksAlias ).fold(Nil )(_.split(" ," ).toList), // TODO!
108
+ parseOptionalArg(sourceLinks, sourceLinksAlias1, sourceLinksAlias2 ).fold(Nil )(_.split(" ," ).toList),
100
109
parseOptionalArg(revision)
101
110
)
102
111
@@ -166,7 +175,6 @@ object Main:
166
175
167
176
if (parsedArgs.output.exists()) IO .delete(parsedArgs.output)
168
177
169
- // TODO #20 pass options, classpath etc.
170
178
new DokkaGenerator (new DottyDokkaConfig (config), DokkaConsoleLogger .INSTANCE ).generate()
171
179
172
180
println(" Done" )
@@ -177,7 +185,7 @@ object Main:
177
185
sys.exit(1 )
178
186
179
187
def main (args : Array [String ]): Unit =
180
- val argDefinition = new Scala3Args {
188
+ val argDefinition = new Scala3Args (sys.error) {
181
189
protected def defaultName (): String = sys.error(s " Argument ' ${name.name}' is required " )
182
190
protected def defaultTastFiles (): List [File ] = sys.error(s " Argument ' ${tastyRoots.name}' is required " )
183
191
protected def defaultDest (): File = sys.error(s " Argument ' ${dest.name}' is required " )
0 commit comments