Skip to content

Commit 2b39c14

Browse files
committed
fix todos, add missing arguments and descriptions
1 parent 402462b commit 2b39c14

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

scala3doc/src/dotty/dokka/Main.scala

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ import java.nio.file.Files
1414

1515
import dotty.tools.dotc.config.Settings._
1616

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"
1819
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"))
2021
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"))
2223

2324
val dest: Setting[String] =
2425
StringSetting("--dest", "dest", "Output to generate documentation to", "", aliases = List("-d"))
@@ -42,17 +43,24 @@ abstract class Scala3Args extends SettingGroup:
4243
val docsRootAlias: Setting[String] =
4344
StringSetting("-p", "docs", "Root of project docs", "", aliases = List("-p"))
4445

45-
4646
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, "")
5052

5153
val projectTitle: Setting[String] =
5254
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+
5358

5459
val projectVersion: Setting[String] =
5560
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+
5664

5765
val projectLogo: Setting[String] =
5866
StringSetting("--projectLogo", "projectLogo", "Relative path to logo of the project", "")
@@ -70,15 +78,16 @@ abstract class Scala3Args extends SettingGroup:
7078
def extract(args: List[String]) =
7179
val initialSummary = ArgsSummary(defaultState, args, errors = Nil, warnings = Nil)
7280
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")}")
7583

7684
val parsedSyntax = syntax.valueIn(res.sstate) match
7785
case "" => None
7886
case other =>
7987
Args.CommentSyntax.fromString(other) match
8088
case None =>
81-
sys.error(s"unrecognized value for --syntax option: $other")
89+
reportError(s"unrecognized value for --syntax option: $other")
90+
None
8291
case some => some
8392

8493
def parseOptionalArg(args: Setting[String]*) =
@@ -92,11 +101,11 @@ abstract class Scala3Args extends SettingGroup:
92101
parseOptionalArg(classpath, classpathAlias1, classpathAlias2).getOrElse(System.getProperty("java.class.path")),
93102
parseOptionalArg(dest, destAlias).fold(defaultDest())(new File(_)),
94103
parseOptionalArg(docsRoot, docsRootAlias),
95-
parseOptionalArg(projectVersion),
96-
parseOptionalArg(projectTitle),
104+
parseOptionalArg(projectVersion, projectVersionAlias),
105+
parseOptionalArg(projectTitle, projectTitleAlias),
97106
parseOptionalArg(projectLogo),
98107
parsedSyntax,
99-
parseOptionalArg(sourceLinks, sourceLinksAlias).fold(Nil)(_.split(",").toList), // TODO!
108+
parseOptionalArg(sourceLinks, sourceLinksAlias1, sourceLinksAlias2).fold(Nil)(_.split(",").toList),
100109
parseOptionalArg(revision)
101110
)
102111

@@ -166,7 +175,6 @@ object Main:
166175

167176
if (parsedArgs.output.exists()) IO.delete(parsedArgs.output)
168177

169-
// TODO #20 pass options, classpath etc.
170178
new DokkaGenerator(new DottyDokkaConfig(config), DokkaConsoleLogger.INSTANCE).generate()
171179

172180
println("Done")
@@ -177,7 +185,7 @@ object Main:
177185
sys.exit(1)
178186

179187
def main(args: Array[String]): Unit =
180-
val argDefinition = new Scala3Args {
188+
val argDefinition = new Scala3Args(sys.error) {
181189
protected def defaultName(): String = sys.error(s"Argument '${name.name}' is required")
182190
protected def defaultTastFiles(): List[File] = sys.error(s"Argument '${tastyRoots.name}' is required")
183191
protected def defaultDest(): File = sys.error(s"Argument '${dest.name}' is required")

scala3doc/src/dotty/dokka/SourceLinks.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ case class SourceLinks(links: Seq[SourceLink], projectRoot: Path):
9090
object SourceLinks:
9191

9292
val usage =
93-
"""Source links provide a mapping between file in documentation and code repositry.
93+
"""Source links provide a mapping between file in documentation and code repository.
94+
|
9495
|Accepted formats:
9596
|<sub-path>=<source-link>
9697
|<source-link>

scala3doc/src/dotty/tools/dottydoc/Main.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import dotc.core.Contexts._
1111
import dotc.reporting.Reporter
1212
import dotc.{ Compiler, Driver }
1313
import dotc.config._
14+
import dotty.tools.dotc.report.error
1415

1516
import dotty.tools.dotc.config.Settings.Setting.value
1617

@@ -37,7 +38,7 @@ object Main extends Driver {
3738
val (filesToCompile, ctx) = setup(args, rootCtx)
3839
given Context = ctx
3940

40-
val argDefinition = new Scala3Args() {
41+
val argDefinition = new Scala3Args(error(_)) {
4142
protected def defaultName(): String = ctx.settings.projectName.value
4243
protected def defaultTastFiles(): List[File] = Nil
4344
protected def defaultDest(): File = File(ctx.settings.outputDir.value.toString)

0 commit comments

Comments
 (0)