Skip to content

Commit b99a117

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

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

project/Build.scala

Lines changed: 30 additions & 15 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,17 @@ 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+
1516+
generateScala3Documentation := Def.inputTaskDyn {
1517+
val dottydocExtraArgs = spaceDelimited("[output]").parsed
1518+
val dest = file(dottydocExtraArgs.headOption.getOrElse("scala3doc/output/scala3")).getAbsoluteFile
1519+
val majorVersion = (scalaBinaryVersion in LocalProject("scala3-library-bootstrapped")).value
1520+
15191521
val dottyJars: Seq[java.io.File] = Seq(
15201522
(`scala3-interfaces`/Compile/products).value,
15211523
(`tasty-core-bootstrapped`/Compile/products).value,
@@ -1525,8 +1527,16 @@ object Build {
15251527
val roots = joinProducts(dottyJars)
15261528

15271529
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+
else Def.task{
1531+
IO.write(dest / "versions" / "latest-nightly-base", majorVersion)
1532+
1533+
// This file is used by GitHub Pages when the page is available in a custom domain
1534+
IO.write(dest / "CNAME", "dotty.epfl.ch")
1535+
}.dependsOn(generateDocumentation(
1536+
roots, "Scala 3", dest.getAbsolutePath, "master",
1537+
"-p scala3doc/scala3-docs --projectLogo scala3doc/scala3-docs/logo.svg"))
1538+
}.evaluated,
1539+
15301540

15311541
generateScala3StdlibDocumentation:= Def.taskDyn {
15321542
val dottyJars: Seq[java.io.File] = Seq(
@@ -1536,11 +1546,16 @@ object Build {
15361546
val roots = joinProducts(dottyJars)
15371547

15381548
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")
1549+
else generateDocumentation(
1550+
roots, "Scala 3", "scala3doc/output/scala3-stdlib", "maser",
1551+
"-p scala3doc/scala3-docs --syntax wiki --projectLogo scala3doc/scala3-docs/logo.svg "
1552+
)
15401553
}.value,
1554+
15411555
generateTestcasesDocumentation := Def.taskDyn {
1542-
generateDocumentation(Build.testcasesOutputDir.in(Test).value, "Scala3doc testcases", "testcases", "--revision master")
1556+
generateDocumentation(Build.testcasesOutputDir.in(Test).value, "Scala3doc testcases", "scala3doc/output/testcases", "master")
15431557
}.value,
1558+
15441559
buildInfoKeys in Test := Seq[BuildInfoKey](
15451560
Build.testcasesOutputDir.in(Test),
15461561
Build.testcasesSourceRoot.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)