Skip to content

Commit bf48abb

Browse files
committed
Use scala3 doc to generate dotty website
1 parent 30e10b5 commit bf48abb

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

project/Build.scala

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ object Build {
11731173
val testcasesSourceRoot = taskKey[String]("Root directory where tests sources are generated")
11741174
val generateSelfDocumentation = taskKey[Unit]("Generate example documentation")
11751175
// Note: the two tasks below should be one, but a bug in Tasty prevents that
1176-
val generateScala3Documentation = taskKey[Unit]("Generate documentation for dotty lib")
1176+
val generateScala3Documentation = inputKey[Unit]("Generate documentation for dotty lib")
11771177
val generateScala3StdlibDocumentation = taskKey[Unit]("Generate documentation for Scala3 standard library")
11781178
val generateTestcasesDocumentation = taskKey[Unit]("Generate documentation for testcases, usefull for debugging tests")
11791179
lazy val `scala3doc` = project.in(file("scala3doc")).asScala3doc
@@ -1468,12 +1468,11 @@ object Build {
14681468
enablePlugins(JmhPlugin)
14691469

14701470
def asScala3doc: Project = {
1471-
def generateDocumentation(targets: String, name: String, outDir: String, params: String = "") = Def.taskDyn {
1471+
def generateDocumentation(targets: String, name: String, outDir: String, ref: String, params: String = "") = Def.taskDyn {
14721472
val projectVersion = version.value
1473-
val sourcesAndRevision = s"-s github://lampepfl/dotty --projectVersion $projectVersion"
1474-
run.in(Compile).toTask(
1475-
s""" -d scala3doc/output/$outDir -t $targets -n "$name" $sourcesAndRevision $params"""
1476-
)
1473+
val sourcesAndRevision = s"-s github://lampepfl/dotty --revision $ref --projectVersion $projectVersion"
1474+
val cmd = s""" -d $outDir -t $targets -n "$name" $sourcesAndRevision $params"""
1475+
run.in(Compile).toTask(cmd)
14771476
}
14781477

14791478
def joinProducts(products: Seq[java.io.File]): String =
@@ -1508,14 +1507,16 @@ object Build {
15081507
fork.in(test) := true,
15091508
baseDirectory.in(run) := baseDirectory.in(ThisBuild).value,
15101509
generateSelfDocumentation := Def.taskDyn {
1511-
val revision = VersionUtil.gitHash
15121510
generateDocumentation(
15131511
classDirectory.in(Compile).value.getAbsolutePath,
1514-
"scala3doc", "self",
1515-
s"-p scala3doc/documentation --projectLogo scala3doc/documentation/logo.svg --revision $revision",
1516-
)
1512+
"scala3doc", "scala3doc/output/self", VersionUtil.gitHash,
1513+
"-p scala3doc/documentation --projectLogo scala3doc/documentation/logo.svg")
15171514
}.value,
1518-
generateScala3Documentation := Def.taskDyn {
1515+
generateScala3Documentation := Def.inputTaskDyn {
1516+
val dottydocExtraArgs = spaceDelimited("[output]").parsed
1517+
val dest = file(dottydocExtraArgs.headOption.getOrElse("scala3doc/output/scala3")).getAbsoluteFile
1518+
val majorVersion = (scalaBinaryVersion in LocalProject("scala3-library-bootstrapped")).value
1519+
15191520
val dottyJars: Seq[java.io.File] = Seq(
15201521
(`scala3-interfaces`/Compile/products).value,
15211522
(`tasty-core-bootstrapped`/Compile/products).value,
@@ -1525,21 +1526,17 @@ object Build {
15251526
val roots = joinProducts(dottyJars)
15261527

15271528
if (dottyJars.isEmpty) Def.task { streams.value.log.error("Dotty lib wasn't found") }
1528-
else generateDocumentation(roots, "Scala 3", "scala3", "-p scala3doc/scala3-docs --projectLogo scala3doc/scala3-docs/logo.svg --revision master")
1529-
}.value,
1530-
1531-
generateScala3StdlibDocumentation:= Def.taskDyn {
1532-
val dottyJars: Seq[java.io.File] = Seq(
1533-
(`stdlib-bootstrapped`/Compile/products).value,
1534-
).flatten
1535-
1536-
val roots = joinProducts(dottyJars)
1537-
1538-
if (dottyJars.isEmpty) Def.task { streams.value.log.error("Dotty lib wasn't found") }
1539-
else generateDocumentation(roots, "Scala 3", "scala3-stdlib", "-p scala3doc/scala3-docs --syntax wiki --projectLogo scala3doc/scala3-docs/logo.svg --revision master")
1540-
}.value,
1529+
else Def.task{
1530+
IO.write(dest / "versions" / "latest-nightly-base", majorVersion)
1531+
1532+
// This file is used by GitHub Pages when the page is available in a custom domain
1533+
IO.write(dest / "CNAME", "dotty.epfl.ch")
1534+
}.dependsOn(generateDocumentation(
1535+
roots, "Scala 3", dest.getAbsolutePath, "master",
1536+
"-p scala3doc/scala3-docs --projectLogo scala3doc/scala3-docs/logo.svg"))
1537+
}.evaluated,
15411538
generateTestcasesDocumentation := Def.taskDyn {
1542-
generateDocumentation(Build.testcasesOutputDir.in(Test).value, "Scala3doc testcases", "testcases", "--revision master")
1539+
generateDocumentation(Build.testcasesOutputDir.in(Test).value, "Scala3doc testcases", "scala3doc/output/testcases", "master")
15431540
}.value,
15441541
buildInfoKeys in Test := Seq[BuildInfoKey](
15451542
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)