Skip to content

Commit 2bc7355

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 c23ef2d commit 2bc7355

File tree

125 files changed

+119
-247
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

+119
-247
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ val `stdlib-bootstrapped-tasty-tests` = Build.`stdlib-bootstrapped-tasty-tests`
2020
val `tasty-core` = Build.`tasty-core`
2121
val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`
2222
val `tasty-core-scala2` = Build.`tasty-core-scala2`
23+
val scala3doc = Build.scala3doc
24+
val scala3docTest = Build.`scala3doc-test`
25+
// val `scala3doc-example-project` = Build.`scala3doc-example-project`
2326
val `scala3-bench-run` = Build.`scala3-bench-run`
2427
val dist = Build.dist
2528
val `community-build` = Build.`community-build`

project/Build.scala

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,10 @@ object Build {
11531153
lazy val `scala3-bench-bootstrapped` = project.in(file("bench")).asDottyBench(Bootstrapped)
11541154
lazy val `scala3-bench-run` = project.in(file("bench-run")).asDottyBench(Bootstrapped)
11551155

1156+
lazy val `scala3doc` = project.in(file("scala3doc")).asScala3doc
1157+
lazy val `scala3doc-test` = project.in(file("scala3doc-test")).asScala3docTest
1158+
lazy val `scala3doc-example-project` = project.in(file("scala3doc-example-project")).asDocExampleProject
1159+
11561160
// sbt plugin to use Dotty in your own build, see
11571161
// https://github.com/lampepfl/scala3-example-project for usage.
11581162
lazy val `sbt-dotty` = project.in(file("sbt-dotty")).
@@ -1440,6 +1444,73 @@ object Build {
14401444
settings(commonBenchmarkSettings).
14411445
enablePlugins(JmhPlugin)
14421446

1447+
def commonScala3DocSettings = commonBootstrappedSettings ++ Seq(
1448+
scalaVersion := dottyVersion,
1449+
resolvers += Resolver.jcenterRepo,
1450+
resolvers += Resolver.bintrayRepo("kotlin", "kotlin-dev"),
1451+
resolvers += Resolver.bintrayRepo("virtuslab", "dokka"),
1452+
// hack, we cannot build documentation so we need this to publish locally
1453+
publishArtifact in (Compile, packageDoc) := false
1454+
)
1455+
1456+
def asScala3doc: Project =
1457+
project.
1458+
settings(commonScala3DocSettings).
1459+
dependsOn(`scala3-compiler-bootstrapped`).
1460+
dependsOn(`scala3-tasty-inspector`)
1461+
1462+
def asScala3docTest: Project =
1463+
project.
1464+
settings(commonScala3DocSettings).
1465+
dependsOn(`scala3doc`)
1466+
1467+
def asDocExampleProject: Project = project.
1468+
settings(commonBootstrappedSettings0).
1469+
dependsOn(`scala3-compiler-bootstrapped`).
1470+
settings(
1471+
Compile/scalaSource := baseDirectory.value / "src/main/scala",
1472+
Test/scalaSource := baseDirectory.value / "src/test/scala",
1473+
Compile/resourceDirectory := baseDirectory.value / "src/main/resources",
1474+
Test/resourceDirectory := baseDirectory.value / "src/test/resources",
1475+
1476+
name := "scala3doc-example-project",
1477+
description := "Example SBT project that is documented using Scala3doc",
1478+
version := "0.1.0-SNAPSHOT",
1479+
scalaVersion := dottyVersion,
1480+
1481+
useScala3doc := true,
1482+
scala3docOptions ++= Seq("--name", "example-project"),
1483+
Compile / doc / target := file("out/doc/example-project"),
1484+
1485+
// we cannot set
1486+
doc/scalaInstance := {
1487+
val externalNonBootstrappedDeps = externalDependencyClasspath.in(`scala3doc`, Compile).value
1488+
val scalaLibrary = findArtifact(externalNonBootstrappedDeps, "scala-library")
1489+
1490+
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
1491+
// just directories containing classfiles because sbt maintains a cache of
1492+
// compiler instances. This cache is invalidated based on timestamps
1493+
// however this is only implemented on jars, directories are never
1494+
// invalidated.
1495+
val tastyCore = packageBin.in(`tasty-core`, Compile).value
1496+
val dottyLibrary = packageBin.in(`scala3-library-bootstrapped`, Compile).value
1497+
val dottyInterfaces = packageBin.in(`scala3-interfaces`, Compile).value
1498+
val dottyCompiler = packageBin.in(`scala3-compiler-bootstrapped`, Compile).value
1499+
val doctool = packageBin.in(`scala3doc`, Compile).value
1500+
1501+
val allJars = Seq(tastyCore, dottyLibrary, dottyInterfaces, dottyCompiler, doctool) ++ externalNonBootstrappedDeps.map(_.data)
1502+
1503+
makeScalaInstance(
1504+
state.value,
1505+
scalaVersion.value,
1506+
scalaLibrary,
1507+
dottyLibrary,
1508+
dottyCompiler,
1509+
allJars
1510+
)
1511+
},
1512+
)
1513+
14431514
def asDist(implicit mode: Mode): Project = project.
14441515
enablePlugins(PackPlugin).
14451516
withCommonSettings.

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
File renamed without changes.
File renamed without changes.

scala3doc/src/main/scala/example/level2/Documentation.scala renamed to scala3doc-test/src/example/level2/Documentation.scala

File renamed without changes.

scala3doc/src/main/scala/example/level2/SameLevelTypeLinking.scala renamed to scala3doc-test/src/example/level2/SameLevelTypeLinking.scala

File renamed without changes.

scala3doc/src/main/scala/example/level2/level3/level4/ClassLevel4.scala renamed to scala3doc-test/src/example/level2/level3/level4/ClassLevel4.scala

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)