Skip to content

Commit 75f3617

Browse files
committed
Document more then stdlib for Scala 3 doc
1 parent 82a1e87 commit 75f3617

File tree

5 files changed

+44
-55
lines changed

5 files changed

+44
-55
lines changed

.github/workflows/ci.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ name: Dotty CI
22

33
on:
44
push:
5+
paths-ignore:
6+
# Do not run everything on changes only in docs
7+
- 'scala3doc/**'
8+
- 'scala3doc-test/**'
59
pull_request:
10+
paths-ignore:
11+
# Do not run everything on changes only in docs
12+
- 'scala3doc/**'
13+
- 'scala3doc-test/**'
614
schedule:
715
- cron: '0 3 * * *' # Every day at 3 AM
816

.github/workflows/scala3doc.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ jobs:
4141
- name: Generate test documentation
4242
run: sbt scala3doc/generateSelfDocumentation
4343

44-
- name: Generate documentation with SBT plugin
45-
run: sbt scala3doc-example-project/doc
44+
- name: Generate Scala 3 documentation
45+
run: sbt scala3doc/generateScala3Documentation

project/Build.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ object Build {
136136

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

139+
val aritfactsForScala3Documentation = taskKey[Seq[File]]("All artifacts to document")
140+
139141
lazy val SourceDeps = config("sourcedeps")
140142

141143
// Settings shared by the build (scoped in ThisBuild). Used in build.sbt
@@ -1467,7 +1469,15 @@ object Build {
14671469
project.
14681470
settings(commonScala3DocSettings).
14691471
dependsOn(`scala3-compiler-bootstrapped`).
1470-
dependsOn(`scala3-tasty-inspector`)
1472+
dependsOn(`scala3-tasty-inspector`).
1473+
settings(aritfactsForScala3Documentation := Seq(
1474+
// All projects below will be put co generated documentaiton for Scala 3
1475+
classDirectory.in(`scala3-interfaces`).in(Compile).value,
1476+
classDirectory.in(`tasty-core`).in(Compile).value,
1477+
classDirectory.in(`scala3-library`).in(Compile).value,
1478+
// TODO this one fails to load using TASTY
1479+
// classDirectory.in(`stdlib-bootstrapped`).in(Compile).value,
1480+
))
14711481

14721482
def asScala3docTest: Project =
14731483
project.

scala3doc/.gitignore

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,4 @@
1-
*.class
2-
*.log
3-
libs/
4-
5-
# sbt specific
6-
.cache
7-
.history
8-
.lib/
9-
dist/*
10-
target/
11-
lib_managed/
12-
src_managed/
13-
project/boot/
14-
project/plugins/project/
15-
16-
# Scala-IDE specific
17-
.scala_dependencies
18-
.worksheet
19-
.bsp
20-
21-
# Intellij
22-
.idea
23-
24-
#integration tests dir
25-
/test-ws
26-
27-
# to test deploy
28-
private-*
29-
repo
30-
31-
.metals
32-
metals.sbt
33-
.bloop
34-
.dotty-ide*
35-
36-
# custom things
1+
# root where we generate documentation
372
output
383

39-
.vscode
404

scala3doc/build.sbt

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ val dokkaSiteVersion = "0.1.9"
77
libraryDependencies ++= Seq(
88
"org.scala-lang" %% "scala3-tasty-inspector" % scalaVersion.value,
99

10-
1110
"com.virtuslab.dokka" % "dokka-site" % dokkaSiteVersion,
1211
"org.scala-sbt" % "io_2.13" % "1.3.4",
1312
"com.vladsch.flexmark" % "flexmark-all" % flexmarkVersion,
@@ -17,10 +16,14 @@ libraryDependencies ++= Seq(
1716
) //a a
1817

1918
val generateSelfDocumentation = inputKey[Unit]("Generate example documentation")
20-
generateSelfDocumentation := {
21-
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
22-
}
19+
generateSelfDocumentation := Def.inputTaskDyn {
20+
runSelfDocumentation(classDirectory.in(Compile).value.getAbsolutePath)
21+
}.evaluated
2322

23+
def runSelfDocumentation(classDir: String) = Def.taskDyn {
24+
val mapping = "src/main/scala=https://github.com/lampepfl/scala3doc/tree/master/src/main/scala#L"
25+
run.in(Compile).toTask(s" -o output/self -t $classDir -d documentation -n scala3doc -s $mapping")
26+
}
2427

2528
// Uncomment to debug dokka processing (require to run debug in listen mode on 5005 port)
2629
// javaOptions.in(run) += "-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y"
@@ -29,19 +32,23 @@ fork.in(run) := true
2932
Compile / mainClass := Some("dotty.dokka.Main")
3033

3134

32-
// TODO #35 proper sbt integration
33-
val generateDottyLibDocumentation = taskKey[Unit]("Generate documentation for dotty lib")
34-
generateDottyLibDocumentation := Def.taskDyn {
35-
val dotttyLib = fullClasspath.in(Compile).value.find{ a =>
36-
val info = a.get(moduleID.key)
37-
info.nonEmpty &&
38-
info.get.organization == "ch.epfl.lamp" &&
39-
info.get.name.startsWith("dotty-library")
40-
}
41-
if (dotttyLib.isEmpty) Def.task {
35+
36+
def generateDottyDocsFromClasspath(artifacts: Seq[String]) = Def.taskDyn {
37+
val roots = artifacts.mkString(java.io.File.pathSeparator)
38+
val mapping = "=https://github.com/lampepfl/dotty/tree/master#L"
39+
if (artifacts.isEmpty) Def.task {
4240
streams.value.log.error("Dotty lib wasn't found")
4341
} else Def.task {
44-
run.in(Compile).toTask(s" -o output/stdLib -t ${dotttyLib.get.data} -d dotty-docs/docs -n dotty-lib -s library/src=https://github.com/lampepfl/dotty/tree/master/library/src#L").value
42+
run.in(Compile).toTask(s" -o output/stdLib -t $roots -d dotty-docs/docs -n dotty-lib -s $mapping ").value
4543
}
44+
}
45+
46+
val generateScala3Documentation = taskKey[Unit]("Generate documentation for dotty lib")
47+
generateScala3Documentation := Def.taskDyn {
48+
val dotttyJars = Build.aritfactsForScala3Documentation.value.map(_.toString)
49+
50+
streams.value.log.info(s"Documenting classes from:\n${dotttyJars.mkString("\n")}")
51+
52+
generateDottyDocsFromClasspath(dotttyJars)
4653
}.value
4754

0 commit comments

Comments
 (0)