Skip to content

Commit 82a1e87

Browse files
committed
Split scala3 doc and migrate file layout
Now both project matches repository standard. Test and dummy classes does not clutter scala3doc jar (are defined in test)
1 parent 58046f3 commit 82a1e87

File tree

125 files changed

+64
-326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+64
-326
lines changed

.github/workflows/scala3doc.yaml

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,43 +33,13 @@ jobs:
3333
java-version: 11
3434

3535
- name: Compile and test
36-
run: sbt compile test
36+
run: sbt scala3doc/test
3737

3838
- name: Locally publish self
39-
run: sbt publishLocal
39+
run: sbt scala3doc/publishLocal
4040

4141
- name: Generate test documentation
42-
run: sbt generateSelfDocumentation
43-
44-
- name: Generate documentation for dotty library
45-
run: sbt generateDottyLibDocumentation
42+
run: sbt scala3doc/generateSelfDocumentation
4643

4744
- name: Generate documentation with SBT plugin
48-
run: sbt example-project/doc
49-
50-
- name: Configure AWS Credentials
51-
uses: aws-actions/configure-aws-credentials@v1
52-
with:
53-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
54-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
55-
aws-region: eu-central-1
56-
57-
- name: Publish all
58-
run: |
59-
dest=s3://scala3doc/$([ $GITHUB_REF = "master" ] && echo master || echo pr-$(echo $GITHUB_REF | cut '-d/' -f3))
60-
aws s3 rm $dest
61-
aws s3 sync output $dest
62-
63-
- name: Update gh-pages
64-
run: |
65-
if [ $GITHUB_REF = "refs/heads/master" ]; then
66-
git config --global user.email "$(git log -1 --format=%ae)"
67-
git config --global user.name "$(git log -1 --format=%an)"
68-
git subtree add --prefix=our-site origin gh-pages
69-
rm -r our-site/*
70-
cp -r output/self/* our-site
71-
git add our-site
72-
git commit -m "$(git log -1 --pretty=%B)"
73-
git subtree push --prefix=our-site origin gh-pages
74-
fi
75-
45+
run: sbt scala3doc-example-project/doc

build.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ val `tasty-core` = Build.`tasty-core`
2121
val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`
2222
val `tasty-core-scala2` = Build.`tasty-core-scala2`
2323
val scala3doc = Build.scala3doc
24-
val `scala3doc-example-project` = Build.`scala3doc-example-project`
24+
val scala3docTest = Build.`scala3doc-test`
25+
// val `scala3doc-example-project` = Build.`scala3doc-example-project`
2526
val `scala3-bench-run` = Build.`scala3-bench-run`
2627
val dist = Build.dist
2728
val `community-build` = Build.`community-build`

project/Build.scala

Lines changed: 17 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@ object Build {
136136

137137
val fetchScalaJSSource = taskKey[File]("Fetch the sources of Scala.js")
138138

139-
// Scala3doc specific tasks
140-
val buildDokkaApi = taskKey[File]("Compile dokka wrapper and put jar in lib")
141-
val generateSelfDocumentation = taskKey[Unit]("Generate example documentation")
142-
val generateDottyLibDocumentation = taskKey[Unit]("Generate documentation for dotty lib")
143-
144139
lazy val SourceDeps = config("sourcedeps")
145140

146141
// Settings shared by the build (scoped in ThisBuild). Used in build.sbt
@@ -1169,6 +1164,7 @@ object Build {
11691164
lazy val `scala3-bench-run` = project.in(file("bench-run")).asDottyBench(Bootstrapped)
11701165

11711166
lazy val `scala3doc` = project.in(file("scala3doc")).asScala3doc
1167+
lazy val `scala3doc-test` = project.in(file("scala3doc-test")).asScala3docTest
11721168
lazy val `scala3doc-example-project` = project.in(file("scala3doc-example-project")).asDocExampleProject
11731169

11741170
// sbt plugin to use Dotty in your own build, see
@@ -1458,83 +1454,26 @@ object Build {
14581454
settings(commonBenchmarkSettings).
14591455
enablePlugins(JmhPlugin)
14601456

1461-
def asScala3doc: Project = {
1462-
val dokkaVersion = "1.4.10.2"
1463-
val kotlinxVersion = "0.7.2" // upgrade when upgrading dokka
1464-
val flexmarkVersion = "0.42.12"
1465-
val jacksonVersion = "2.9.8"
1466-
val scalaTagsVersion = "0.9.1"
1467-
val dokkaSiteVersion = "0.1.9"
1457+
def commonScala3DocSettings = commonBootstrappedSettings ++ Seq(
1458+
scalaVersion := dottyVersion,
1459+
resolvers += Resolver.jcenterRepo,
1460+
resolvers += Resolver.bintrayRepo("kotlin", "kotlin-dev"),
1461+
resolvers += Resolver.bintrayRepo("virtuslab", "dokka"),
1462+
// hack, we cannot build documentation so we need this to publish locally
1463+
publishArtifact in (Compile, packageDoc) := false
1464+
)
14681465

1466+
def asScala3doc: Project =
14691467
project.
1470-
settings(commonBootstrappedSettings).
1468+
settings(commonScala3DocSettings).
14711469
dependsOn(`scala3-compiler-bootstrapped`).
1472-
dependsOn(`scala3-tasty-inspector`).
1473-
settings(
1474-
Compile/scalaSource := baseDirectory.value / "src/main/scala",
1475-
Test/scalaSource := baseDirectory.value / "src/test/scala",
1476-
Compile/resourceDirectory := baseDirectory.value / "src/main/resources",
1477-
Test/resourceDirectory := baseDirectory.value / "src/test/resources",
1478-
1479-
scalaVersion := dottyVersion,
1480-
resolvers ++= Seq(
1481-
Resolver.jcenterRepo,
1482-
Resolver.bintrayRepo("kotlin", "kotlin-dev"),
1483-
Resolver.bintrayRepo("virtuslab", "dokka"),
1484-
),
1485-
libraryDependencies ++= Seq(
1486-
"org.jetbrains.dokka" % "dokka-test-api" % dokkaVersion % "test",
1487-
1488-
"org.scala-lang" %% "scala3-tasty-inspector" % dottyVersion,
1489-
1490-
"org.jetbrains.dokka" % "dokka-base" % dokkaVersion,
1491-
"org.jetbrains.dokka" % "dokka-core" % dokkaVersion,
1492-
"org.jetbrains.dokka" % "dokka-test-api" % dokkaVersion,
1493-
"org.jetbrains.kotlinx" % "kotlinx-html-jvm" % kotlinxVersion,
1494-
"com.virtuslab.dokka" % "dokka-site" % dokkaSiteVersion,
1495-
1496-
"org.scala-sbt" % "io_2.13" % "1.3.4",
1497-
1498-
"com.vladsch.flexmark" % "flexmark-all" % flexmarkVersion,
1499-
"com.lihaoyi" % "scalatags_2.13" % scalaTagsVersion,
1500-
"nl.big-o" % "liqp" % "0.6.7",
1501-
"args4j" % "args4j" % "2.33",
1502-
),
1503-
1504-
run / fork := true,
1505-
Test / fork := true,
1506-
Test / parallelExecution := false,
1507-
Compile / mainClass := Some("dotty.dokka.Main"),
1508-
1509-
Test / envVars := Map(
1510-
"scala3doc.classroot" -> (Compile/target/classDirectory).value.getAbsolutePath.toString,
1511-
),
1512-
1513-
// hack, we cannot build documentation so we need this to publish locally
1514-
Compile / packageDoc / publishArtifact := false,
1515-
1516-
generateSelfDocumentation := Def.taskDyn {
1517-
val classdir = (Compile/target/classDirectory).value
1518-
(Compile/run).toTask(s" -o output/self -t ${classdir} -d documentation -n scala3doc -s src/main/scala=https://github.com/lampepfl/scala3doc/tree/master/src/main/scala#L")
1519-
}.value,
1520-
1521-
generateDottyLibDocumentation := Def.taskDyn {
1522-
val dottyLib = (Compile/fullClasspath).value.find{ a =>
1523-
val info = a.get(moduleID.key)
1524-
info.nonEmpty &&
1525-
info.get.organization == "ch.epfl.lamp" &&
1526-
info.get.name.startsWith("dotty-library")
1527-
}
1528-
if (dottyLib.isEmpty) Def.task {
1529-
streams.value.log.error("Dotty lib wasn't found")
1530-
} else Def.task {
1531-
(Compile/run).toTask(s" -o output/stdLib -t ${dottyLib.get.data} -d dotty-docs/docs -n dotty-lib -s library/src=https://github.com/lampepfl/dotty/tree/master/library/src#L").value
1532-
}
1533-
}.value,
1534-
1535-
)
1536-
}
1470+
dependsOn(`scala3-tasty-inspector`)
15371471

1472+
def asScala3docTest: Project =
1473+
project.
1474+
settings(commonScala3DocSettings).
1475+
dependsOn(`scala3doc`)
1476+
15381477
def asDocExampleProject: Project = project.
15391478
settings(commonBootstrappedSettings0).
15401479
dependsOn(`scala3-compiler-bootstrapped`).

scala3doc-test/build.sbt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
val dokkaVersion = "1.4.10.2"
2+
3+
libraryDependencies ++= Seq(
4+
"org.jetbrains.dokka" % "dokka-test-api" % dokkaVersion % "test", // TODO move testing utils to dokka-site
5+
"com.novocode" % "junit-interface" % "0.11" % "test",
6+
)
7+
8+
val testOuputDir = taskKey[String]("Root directory where tests classses are generated")
9+
testOuputDir := (Compile/target/classDirectory).value.getAbsolutePath.toString
10+
11+
val testSourceRoot = taskKey[String]("Root directory where tests sources are generated")
12+
testSourceRoot := (baseDirectory.value / "src").getAbsolutePath.toString
13+
14+
15+
buildInfoKeys in Test := Seq[BuildInfoKey](
16+
testOuputDir,
17+
testSourceRoot,
18+
)
19+
buildInfoPackage in Test := "dotty.dokka"
20+
BuildInfoPlugin.buildInfoScopedSettings(Test)
21+
BuildInfoPlugin.buildInfoDefaultSettings
22+
23+
// Uncomment to debug dokka processing (require to run debug in listen mode on 5005 port)
24+
// javaOptions.in(run) += "-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y"
25+
26+
fork.in(run) := true
27+
28+
// There is a bug in dokka that prevents parallel tests withing the same jvm
29+
fork.in(test) := true
30+
Test / parallelExecution := false

scala3doc/src/test/scala/dotty/dokka/DottyTestRunner.scala renamed to scala3doc-test/test/dotty/dokka/DottyTestRunner.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ abstract class DottyAbstractCoreTest extends AbstractCoreTest:
5555
}
5656

5757
def listTastyFiles(f: File): Seq[File] =
58+
assertTrue(s"Tasty root dir does not exisits: $f", f.isDirectory())
5859
val (files, dirs) = f.listFiles().partition(_.isFile)
5960
files.toIndexedSeq.filter(_.getName.endsWith(".tasty")) ++ dirs.flatMap(listTastyFiles)
6061

scala3doc/src/test/scala/dotty/dokka/MultipleFileTest.scala renamed to scala3doc-test/test/dotty/dokka/MultipleFileTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ abstract class MultipleFileTest(val sourceFiles: List[String], val tastyFolders:
5151
def cleanup(s: String) = s.replace("\n", " ").replaceAll(" +", " ")
5252

5353
val allFromSource = sourceFiles.map{ file =>
54-
val all = signaturesFromSource(Source.fromFile(s"src/main/scala/tests/$file.scala"))
54+
val all = signaturesFromSource(Source.fromFile(s"${BuildInfo.testSourceRoot}/tests/$file.scala"))
5555
(all.expected, all.unexpected)
5656
}
5757

5858
val expectedFromSource = allFromSource.map(_._1).flatten.filter(extractSymbolName(_) != "NULL").map(cleanup)
5959
val unexpectedFromSource = allFromSource.map(_._2).flatten.filter(extractSymbolName(_) != "NULL").map(cleanup)
6060
val unexpectedSignatureSymbolNames = unexpectedFromSource.map(extractSymbolName)
6161

62-
val allFromDocumentation = tastyFolders.flatMap(folder => signaturesFromDocumentation(s"target/scala-0.27/classes/tests/$folder"))
62+
val allFromDocumentation = tastyFolders.flatMap(folder => signaturesFromDocumentation(s"${BuildInfo.testOuputDir}/tests/$folder"))
6363
val fromDocumentation = allFromDocumentation.filter(extractSymbolName(_) != "NULL").map(cleanup)
6464

6565
val documentedSignatures = fromDocumentation.flatMap(matchSignature(_, expectedFromSource)).toSet

scala3doc/src/test/scala/dotty/dokka/tasty/comments/MemberLookupTests.scala renamed to scala3doc-test/test/dotty/dokka/tasty/comments/MemberLookupTests.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import scala.tasty.Reflection
44

55
import org.junit.{Test, Rule}
66
import org.junit.Assert.{assertSame, assertTrue}
7+
import dotty.dokka.BuildInfo
78

89
class LookupTestCases[R <: Reflection](val r: R) {
910

@@ -122,7 +123,7 @@ class MemberLookupTests {
122123
import java.io.File
123124
import scala.collection.mutable.ListBuffer
124125

125-
val classRoot = File("target/scala-0.27/classes")
126+
val classRoot = new File(BuildInfo.testOuputDir)
126127

127128
def go(bld: ListBuffer[String])(file: File): Unit =
128129
file.listFiles.foreach { f =>

scala3doc/build.sbt

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,33 @@
1-
// re-expose subproject settings
2-
val `example-project` = ExampleProject.`example-project`
3-
4-
val dottyVersion = "3.0.0-M1-bin-SNAPSHOT"
5-
val dokkaVersion = "1.4.10.2"
61
val flexmarkVersion = "0.42.12"
72
val jacksonVersion = "2.9.8"
83
val scalaTagsVersion = "0.9.1"
94
val dokkaSiteVersion = "0.1.9"
105

6+
117
libraryDependencies ++= Seq(
12-
"org.jetbrains.dokka" % "dokka-test-api" % dokkaVersion % "test", // TODO move testing utils to dokka-site
13-
"com.virtuslab.dokka" % "dokka-site" % dokkaSiteVersion,
8+
"org.scala-lang" %% "scala3-tasty-inspector" % scalaVersion.value,
149

15-
"org.scala-lang" %% "scala3-tasty-inspector" % dottyVersion,
16-
"org.scala-lang" %% "scala3-compiler" % dottyVersion,
17-
"org.scala-sbt" % "io_2.13" % "1.3.4",
1810

11+
"com.virtuslab.dokka" % "dokka-site" % dokkaSiteVersion,
12+
"org.scala-sbt" % "io_2.13" % "1.3.4",
1913
"com.vladsch.flexmark" % "flexmark-all" % flexmarkVersion,
2014
"com.lihaoyi" % "scalatags_2.13" % scalaTagsVersion,
2115
"nl.big-o" % "liqp" % "0.6.7",
2216
"args4j" % "args4j" % "2.33",
23-
"com.novocode" % "junit-interface" % "0.11" % "test",
24-
)
25-
26-
resolvers += Resolver.jcenterRepo
27-
resolvers += Resolver.bintrayRepo("kotlin", "kotlin-dev")
28-
resolvers += Resolver.bintrayRepo("virtuslab", "dokka")
29-
30-
lazy val root = project
31-
.in(file("."))
32-
.settings(
33-
name := "scala3doc",
34-
version := "0.1.1-SNAPSHOT",
35-
scalaVersion := dottyVersion
36-
)
17+
) //a a
3718

3819
val generateSelfDocumentation = inputKey[Unit]("Generate example documentation")
3920
generateSelfDocumentation := {
4021
run.in(Compile).fullInput(" -o output/self -t target/scala-0.27/classes -d documentation -n scala3doc -s src/main/scala=https://github.com/lampepfl/scala3doc/tree/master/src/main/scala#L").evaluated // TODO #35 proper sbt integration
4122
}
4223

24+
4325
// Uncomment to debug dokka processing (require to run debug in listen mode on 5005 port)
4426
// javaOptions.in(run) += "-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y"
4527

4628
fork.in(run) := true
47-
// There is a bug in dokka that prevents parallel tests withing the same jvm
48-
fork.in(test) := true
49-
Test / parallelExecution := false
50-
51-
scalacOptions in Compile += "-language:implicitConversions"
52-
5329
Compile / mainClass := Some("dotty.dokka.Main")
5430

55-
// hack, we cannot build documentation so we need this to publish locally
56-
publishArtifact in (Compile, packageDoc) := false
5731

5832
// TODO #35 proper sbt integration
5933
val generateDottyLibDocumentation = taskKey[Unit]("Generate documentation for dotty lib")

scala3doc/project/ExampleProject.scala

Lines changed: 0 additions & 18 deletions
This file was deleted.

scala3doc/project/build.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

scala3doc/project/plugins.sbt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)