Skip to content

Commit 958d06d

Browse files
committed
Use scala3 doc to generate dotty website
1 parent 8963e5f commit 958d06d

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

project/Build.scala

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ object Build {
11601160
val testcasesOutputDir = taskKey[String]("Root directory where tests classses are generated")
11611161
val testcasesSourceRoot = taskKey[String]("Root directory where tests sources are generated")
11621162
val generateSelfDocumentation = taskKey[Unit]("Generate example documentation")
1163-
val generateScala3Documentation = taskKey[Unit]("Generate documentation for dotty lib")
1163+
val generateScala3Documentation = inputKey[Unit]("Generate documentation for dotty lib")
11641164
val generateTestcasesDocumentation = taskKey[Unit]("Generate documentation for testcases, usefull for debugging tests")
11651165
lazy val `scala3doc` = project.in(file("scala3doc")).asScala3doc
11661166
lazy val `scala3doc-testcases` = project.in(file("scala3doc-testcases")).asScala3docTestcases
@@ -1454,12 +1454,11 @@ object Build {
14541454
enablePlugins(JmhPlugin)
14551455

14561456
def asScala3doc: Project = {
1457-
def generateDocumentation(targets: String, name: String, outDir: String, params: String = "") = Def.taskDyn {
1457+
def generateDocumentation(targets: String, name: String, outDir: String, ref: String, params: String = "") = Def.taskDyn {
14581458
val projectVersion = version.value
1459-
val sourcesAndRevision = s"-s github://lampepfl/dotty --projectVersion $projectVersion"
1460-
run.in(Compile).toTask(
1461-
s""" -d scala3doc/output/$outDir -t $targets -n "$name" $sourcesAndRevision $params"""
1462-
)
1459+
val sourcesAndRevision = s"-s github://lampepfl/dotty --revision $ref --projectVersion $projectVersion"
1460+
val cmd = s""" -d $outDir -t $targets -n "$name" $sourcesAndRevision $params"""
1461+
run.in(Compile).toTask(cmd)
14631462
}
14641463

14651464
def joinProducts(products: Seq[java.io.File]): String =
@@ -1494,14 +1493,16 @@ object Build {
14941493
fork.in(test) := true,
14951494
baseDirectory.in(run) := baseDirectory.in(ThisBuild).value,
14961495
generateSelfDocumentation := Def.taskDyn {
1497-
val revision = VersionUtil.gitHash
14981496
generateDocumentation(
14991497
classDirectory.in(Compile).value.getAbsolutePath,
1500-
"scala3doc", "self",
1501-
s"-p scala3doc/documentation --projectLogo scala3doc/documentation/logo.svg --revision $revision",
1502-
)
1498+
"scala3doc", "scala3doc/output/self", VersionUtil.gitHash,
1499+
"-p scala3doc/documentation --projectLogo scala3doc/documentation/logo.svg")
15031500
}.value,
1504-
generateScala3Documentation := Def.taskDyn {
1501+
generateScala3Documentation := Def.inputTaskDyn {
1502+
val dottydocExtraArgs = spaceDelimited("[output]").parsed
1503+
val dest = file(dottydocExtraArgs.headOption.getOrElse("scala3doc/output/scala3")).getAbsoluteFile
1504+
val majorVersion = (scalaBinaryVersion in LocalProject("scala3-library-bootstrapped")).value
1505+
15051506
val dottyJars: Seq[java.io.File] = Seq(
15061507
(`scala3-interfaces`/Compile/products).value,
15071508
(`tasty-core-bootstrapped`/Compile/products).value,
@@ -1513,10 +1514,17 @@ object Build {
15131514
val roots = joinProducts(dottyJars)
15141515

15151516
if (dottyJars.isEmpty) Def.task { streams.value.log.error("Dotty lib wasn't found") }
1516-
else generateDocumentation(roots, "Scala 3", "scala3", "-p scala3doc/scala3-docs --projectLogo scala3doc/scala3-docs/logo.svg --revision master")
1517-
}.value,
1517+
else Def.task{
1518+
IO.write(dest / "versions" / "latest-nightly-base", majorVersion)
1519+
1520+
// This file is used by GitHub Pages when the page is available in a custom domain
1521+
IO.write(dest / "CNAME", "dotty.epfl.ch")
1522+
}.dependsOn(generateDocumentation(
1523+
roots, "Scala 3", dest.getAbsolutePath, "master",
1524+
"-p scala3doc/scala3-docs --projectLogo scala3doc/scala3-docs/logo.svg"))
1525+
}.evaluated,
15181526
generateTestcasesDocumentation := Def.taskDyn {
1519-
generateDocumentation(Build.testcasesOutputDir.in(Test).value, "Scala3doc testcases", "testcases", "--revision master")
1527+
generateDocumentation(Build.testcasesOutputDir.in(Test).value, "Scala3doc testcases", "scala3doc/output/testcases", "master")
15201528
}.value,
15211529
buildInfoKeys in Test := Seq[BuildInfoKey](
15221530
Build.testcasesOutputDir.in(Test),

project/scripts/genDocs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ git checkout "$GIT_HEAD"
2525
### Generate the current snapshot of the website ###
2626
# this command will generate docs in $PWD/docs/_site
2727
SBT="$SCRIPT_DIR/sbt"
28-
"$SBT" "scala3-bootstrapped/genDocs $GENDOC_EXTRA_ARGS"
28+
"$SBT" "scala3doc/generateScala3Documentation docs/_site"
2929

3030
# make sure that the previous command actually succeeded
3131
if [ ! -d "$SITE_OUT_DIR" ]; then

0 commit comments

Comments
 (0)