Skip to content

Commit 3899b6a

Browse files
authored
Merge pull request #10373 from romanowski/scala3doc/generate-dotty-website
Use scala3 doc to generate dotty website
2 parents 57c4425 + b99a117 commit 3899b6a

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
@@ -1174,7 +1174,7 @@ object Build {
11741174
val testDocumentationRoot = taskKey[String]("Root directory where tests documentation are stored")
11751175
val generateSelfDocumentation = taskKey[Unit]("Generate example documentation")
11761176
// Note: the two tasks below should be one, but a bug in Tasty prevents that
1177-
val generateScala3Documentation = taskKey[Unit]("Generate documentation for dotty lib")
1177+
val generateScala3Documentation = inputKey[Unit]("Generate documentation for dotty lib")
11781178
val generateScala3StdlibDocumentation = taskKey[Unit]("Generate documentation for Scala3 standard library")
11791179
val generateTestcasesDocumentation = taskKey[Unit]("Generate documentation for testcases, usefull for debugging tests")
11801180
lazy val `scala3doc` = project.in(file("scala3doc")).asScala3doc
@@ -1469,12 +1469,11 @@ object Build {
14691469
enablePlugins(JmhPlugin)
14701470

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

14801479
def joinProducts(products: Seq[java.io.File]): String =
@@ -1509,14 +1508,17 @@ object Build {
15091508
fork.in(test) := true,
15101509
baseDirectory.in(run) := baseDirectory.in(ThisBuild).value,
15111510
generateSelfDocumentation := Def.taskDyn {
1512-
val revision = VersionUtil.gitHash
15131511
generateDocumentation(
15141512
classDirectory.in(Compile).value.getAbsolutePath,
1515-
"scala3doc", "self",
1516-
s"-p scala3doc/documentation --projectLogo scala3doc/documentation/logo.svg --revision $revision",
1517-
)
1513+
"scala3doc", "scala3doc/output/self", VersionUtil.gitHash,
1514+
"-p scala3doc/documentation --projectLogo scala3doc/documentation/logo.svg")
15181515
}.value,
1519-
generateScala3Documentation := Def.taskDyn {
1516+
1517+
generateScala3Documentation := Def.inputTaskDyn {
1518+
val dottydocExtraArgs = spaceDelimited("[output]").parsed
1519+
val dest = file(dottydocExtraArgs.headOption.getOrElse("scala3doc/output/scala3")).getAbsoluteFile
1520+
val majorVersion = (scalaBinaryVersion in LocalProject("scala3-library-bootstrapped")).value
1521+
15201522
val dottyJars: Seq[java.io.File] = Seq(
15211523
(`scala3-interfaces`/Compile/products).value,
15221524
(`tasty-core-bootstrapped`/Compile/products).value,
@@ -1526,8 +1528,16 @@ object Build {
15261528
val roots = joinProducts(dottyJars)
15271529

15281530
if (dottyJars.isEmpty) Def.task { streams.value.log.error("Dotty lib wasn't found") }
1529-
else generateDocumentation(roots, "Scala 3", "scala3", "-p scala3doc/scala3-docs --projectLogo scala3doc/scala3-docs/logo.svg --revision master")
1530-
}.value,
1531+
else Def.task{
1532+
IO.write(dest / "versions" / "latest-nightly-base", majorVersion)
1533+
1534+
// This file is used by GitHub Pages when the page is available in a custom domain
1535+
IO.write(dest / "CNAME", "dotty.epfl.ch")
1536+
}.dependsOn(generateDocumentation(
1537+
roots, "Scala 3", dest.getAbsolutePath, "master",
1538+
"-p scala3doc/scala3-docs --projectLogo scala3doc/scala3-docs/logo.svg"))
1539+
}.evaluated,
1540+
15311541

15321542
generateScala3StdlibDocumentation:= Def.taskDyn {
15331543
val dottyJars: Seq[java.io.File] = Seq(
@@ -1537,11 +1547,16 @@ object Build {
15371547
val roots = joinProducts(dottyJars)
15381548

15391549
if (dottyJars.isEmpty) Def.task { streams.value.log.error("Dotty lib wasn't found") }
1540-
else generateDocumentation(roots, "Scala 3", "scala3-stdlib", "-p scala3doc/scala3-docs --syntax wiki --projectLogo scala3doc/scala3-docs/logo.svg --revision master")
1550+
else generateDocumentation(
1551+
roots, "Scala 3", "scala3doc/output/scala3-stdlib", "maser",
1552+
"-p scala3doc/scala3-docs --syntax wiki --projectLogo scala3doc/scala3-docs/logo.svg "
1553+
)
15411554
}.value,
1555+
15421556
generateTestcasesDocumentation := Def.taskDyn {
1543-
generateDocumentation(Build.testcasesOutputDir.in(Test).value, "Scala3doc testcases", "testcases", "--revision master")
1557+
generateDocumentation(Build.testcasesOutputDir.in(Test).value, "Scala3doc testcases", "scala3doc/output/testcases", "master")
15441558
}.value,
1559+
15451560
buildInfoKeys in Test := Seq[BuildInfoKey](
15461561
Build.testcasesOutputDir.in(Test),
15471562
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)