Skip to content

Commit a5c206f

Browse files
committed
Do not depend on dokka anymore
FIx some test failures
1 parent 4e337f2 commit a5c206f

15 files changed

+31
-115
lines changed

project/Build.scala

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,19 +1544,13 @@ object Build {
15441544
def joinProducts(products: Seq[java.io.File]): String =
15451545
products.iterator.map(_.getAbsolutePath.toString).mkString(" ")
15461546

1547-
val dokkaVersion = "1.4.10.2"
15481547
val flexmarkVersion = "0.42.12"
15491548

15501549
project.settings(commonBootstrappedSettings).
15511550
dependsOn(`scala3-compiler-bootstrapped`).
15521551
dependsOn(`scala3-tasty-inspector`).
15531552
settings(
1554-
// Needed to download dokka and its dependencies
1555-
resolvers += Resolver.jcenterRepo,
15561553
libraryDependencies ++= Seq(
1557-
"org.jetbrains.dokka" % "dokka-core" % dokkaVersion,
1558-
"org.jetbrains.dokka" % "dokka-base" % dokkaVersion,
1559-
"org.jetbrains.kotlinx" % "kotlinx-html-jvm" % "0.7.2", // Needs update when dokka version changes
15601554
"com.vladsch.flexmark" % "flexmark" % flexmarkVersion,
15611555
"com.vladsch.flexmark" % "flexmark-html-parser" % flexmarkVersion,
15621556
"com.vladsch.flexmark" % "flexmark-ext-anchorlink" % flexmarkVersion,
@@ -1572,15 +1566,12 @@ object Build {
15721566
"args4j" % "args4j" % "2.33",
15731567
Dependencies.`jackson-dataformat-yaml`,
15741568

1575-
"org.jetbrains.dokka" % "dokka-test-api" % dokkaVersion % "test",
15761569
"com.novocode" % "junit-interface" % "0.11" % "test",
15771570
),
15781571
Test / test := (Test / test).dependsOn(compile.in(Compile).in(`scala3doc-testcases`)).value,
15791572
testcasesOutputDir.in(Test) := joinProducts((`scala3doc-testcases`/Compile/products).value),
15801573
testcasesSourceRoot.in(Test) := (baseDirectory.in(`scala3doc-testcases`).value / "src").getAbsolutePath.toString,
15811574
Compile / mainClass := Some("dotty.dokka.Main"),
1582-
// There is a bug in dokka that prevents parallel tests withing the same jvm
1583-
fork.in(test) := true,
15841575
baseDirectory.in(run) := baseDirectory.in(ThisBuild).value,
15851576
generateSelfDocumentation := Def.taskDyn {
15861577
generateDocumentation(
@@ -1665,8 +1656,6 @@ object Build {
16651656
BuildInfoPlugin.buildInfoScopedSettings(Test),
16661657
BuildInfoPlugin.buildInfoScopedSettings(Compile),
16671658
BuildInfoPlugin.buildInfoDefaultSettings,
1668-
// Uncomment to debug dokka processing (require to run debug in listen mode on 5005 port)
1669-
// javaOptions.in(run) += "-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y"
16701659
)
16711660
}
16721661

scala3doc/README.md

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

33
Scala3doc (name subject to change) is the documentation tool for
44
[Dotty](https://github.com/lampepfl/dotty), which is scheduled to become
5-
Scala 3. It's based on [Dokka](https://github.com/Kotlin/dokka), the
6-
documentation tool for Kotlin. It uses the TastyInspector to access definitions,
5+
Scala 3. It uses the TastyInspector to access definitions,
76
which is an officially supported way to access Dotty's perspective of a
87
codebase.
98

@@ -48,9 +47,7 @@ CLI command for running our tool is in form: `sbt main -n <name> -o <output> -t
4847
- `<classpath>`: classpath that was used to generate tasty files
4948
- `<sources>`: links to source files of module that are used to link symbols on pages to their source file. They need to be supplied in form:
5049
`local_dir=remote_dir#line_suffix` e.g. `src/main/scala=https://github.com/lampepfl/scala3doc/tree/master/src/main/scala#L`
51-
- `<documentation>`: directory of static documentation that you would like to render with API documentation. This feature is provided by dokka-site plugin:
52-
- [GitHub](https://github.com/VirtusLab/dokka-site)
53-
- [Documentation](https://virtuslab.github.io/dokka-site/index.html)
50+
- `<documentation>`: directory of static documentation that you would like to render with API documentation.
5451

5552
## Developing
5653

@@ -164,16 +161,6 @@ Make sure all the tests pass (simply run `sbt test` to verify that).
164161

165162
## FAQ
166163

167-
### Why depend on Dokka?
168-
169-
We have two primary reasons for depending on Dokka. One of them is division of
170-
labour - Dokka already has a team of maintainers, and it supports an excellent
171-
API which already allowed us to quite easily generate documentation with it. By
172-
depending on Dokka, we will be able to share a large portion of the maintenance
173-
burden. The second reason is very pragmatic - on our own, it'd be difficult for
174-
us to reach even feature parity with Scaladoc, simply because of workforce
175-
constraints. Meanwhile, Dokka maintainers from VirtusLab reached out to us with
176-
an offer of help, which we were happy to take.
177164

178165
### Why use TASTy?
179166

scala3doc/src/dotty/dokka/Main.scala

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,7 @@ import dotty.tools.dotc.config.Settings._
1212
import dotty.tools.dotc.config.CommonScalaSettings
1313
import dotty.tools.dotc.core.Contexts._
1414

15-
/** Main class for the doctool.
16-
*
17-
* The `main` method is mostly responsible just for parsing arguments and
18-
* configuring Dokka. After that, we hand control to Dokka.
19-
*
20-
* Other important classes:
21-
*
22-
* - [](package.DottyDokkaPlugin) is our class that Dokka calls back and which
23-
* actually generates the documentation.
24-
* - [](package.DocContext) is our config for Dokka
25-
*/
15+
/** Main class for the doctool when used from cli. */
2616
object Main:
2717
def main(args: Array[String]): Unit =
2818
try

scala3doc/src/dotty/dokka/ScalaModuleCreator.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dotty.dokka
33
import dotty.dokka.tasty.DokkaTastyInspector
44
import dotty.dokka.model.api._
55
import collection.JavaConverters._
6-
import kotlin.coroutines.Continuation
76

87
case class Module(rootPackage: Member, members: Map[DRI, Member])
98

scala3doc/src/dotty/dokka/compat.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dotty.dokka
33
import java.util.stream.Stream // comment out - wrong error!
44
import java.util.stream.Collectors
55
import java.util.Collections
6-
import kotlin.jvm.JvmClassMappingKt.getKotlinClass
76
import java.nio.file.Path
87
import com.vladsch.flexmark.util.ast.{Node => MdNode}
98
import dotty.dokka.tasty.comments.wiki.WikiDocElement

scala3doc/src/dotty/dokka/site/SidebarParser.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ object Sidebar:
2020
def setUrl(u: String) = this.url = u
2121
def setSubsection(l: JList[RawInput]) = this.subsection = l
2222

23-
private object RawTypeRef extends TypeReference[JMap[String, JList[RawInput]]]
23+
type RawInnerTpe = JMap[String, JList[RawInput]]
24+
private object RawTypeRef extends TypeReference[RawInnerTpe]
2425

2526
private def toSidebar(r: RawInput): Sidebar = r match
2627
case RawInput(title, url, list) if title.nonEmpty && url.nonEmpty && list.isEmpty() =>
@@ -30,6 +31,6 @@ object Sidebar:
3031

3132
def load(content: String): Seq[Sidebar] =
3233
val mapper = ObjectMapper(YAMLFactory())
33-
val raw = mapper.readValue(content, RawTypeRef)
34+
val raw: RawInnerTpe = mapper.readValue(content, RawTypeRef)
3435

3536
raw.get("sidebar").asScala.toList.map(toSidebar)

scala3doc/src/dotty/dokka/tasty/ScalaDocSupport.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dotty.dokka.tasty
33
import scala.jdk.CollectionConverters._
44

55
import dotty.dokka.Scala3doc.CommentSyntax
6-
import comments.{kt, dkk}
76
import dotty.dokka.tasty.comments.Comment
87

98
trait ScaladocSupport { self: TastyParser =>

scala3doc/src/dotty/dokka/tasty/comments/package.scala

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,8 @@ package tasty.comments
33

44
import scala.jdk.CollectionConverters._
55

6-
import org.jetbrains.dokka.model.{doc => dkkd}
76
import com.vladsch.flexmark.util.{ast => mdu}
87

9-
object kt:
10-
import kotlin.collections.builders.{ListBuilder => KtListBuilder, MapBuilder => KtMapBuilder}
11-
12-
def emptyList[T] = new KtListBuilder[T]().build()
13-
def emptyMap[A, B] = new KtMapBuilder[A, B]().build()
14-
15-
object dkk:
16-
def p(children: dkkd.DocTag*) =
17-
dkkd.P(children.asJava, Map.empty.asJava)
18-
def p(params: (String, String)*)(children: dkkd.DocTag*) =
19-
dkkd.P(children.asJava, params.toMap.asJava)
20-
21-
def text(str: String) = dkkd.Text(str, JList(), Map.empty.asJava)
22-
23-
def a(children: dkkd.DocTag*) =
24-
dkkd.A(children.asJava, Map.empty.asJava)
25-
def a(params: (String, String)*)(children: dkkd.DocTag*) =
26-
dkkd.A(children.asJava, params.toMap.asJava)
27-
28-
def pre(params: (String, String)*)(children: dkkd.DocTag*) =
29-
dkkd.Pre(children.asJava, params.toMap.asJava)
30-
31-
def codeInline(children: dkkd.DocTag*) =
32-
dkkd.CodeInline(children.asJava, Map.empty.asJava)
33-
def codeInline(params: (String, String)*)(children: dkkd.DocTag*) =
34-
dkkd.CodeInline(children.asJava, params.toMap.asJava)
35-
def codeBlock(children: dkkd.DocTag*) =
36-
dkkd.CodeBlock(children.asJava, Map.empty.asJava)
37-
def codeBlock(params: (String, String)*)(children: dkkd.DocTag*) =
38-
dkkd.CodeBlock(children.asJava, params.toMap.asJava)
39-
40-
def ul(children: dkkd.DocTag*) =
41-
dkkd.Ul(children.asJava, Map.empty.asJava)
42-
def ul(params: (String, String)*)(children: dkkd.DocTag*) =
43-
dkkd.Ul(children.asJava, params.toMap.asJava)
44-
def ol(children: dkkd.DocTag*) =
45-
dkkd.Ol(children.asJava, Map.empty.asJava)
46-
def ol(params: (String, String)*)(children: dkkd.DocTag*) =
47-
dkkd.Ol(children.asJava, params.toMap.asJava)
48-
def li(children: dkkd.DocTag*) =
49-
dkkd.Li(children.asJava, Map.empty.asJava)
50-
def li(params: (String, String)*)(children: dkkd.DocTag*) =
51-
dkkd.Li(children.asJava, params.toMap.asJava)
52-
538
object dbg:
549
case class See(n: mdu.Node, c: Seq[See]) {
5510
def show(sb: StringBuilder, indent: Int): Unit = {

scala3doc/src/dotty/renderers/HtmlRenderer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class HtmlRenderer(rootPackage: Member, val members: Map[DRI, Member])(using ctx
6666
case m: Member =>
6767
val signatureRenderer = new SignatureRenderer:
6868
def currentDri: DRI = page.link.dri
69-
def link(dri: DRI): Option[String] = Some(pathToPage(dri, page.link.dri))
69+
def link(dri: DRI): Option[String] =
70+
Some(pathToPage(currentDri, dri)).filter(_ != UnresolvedLocationLink)
7071

7172
MemberRenderer(signatureRenderer).fullMember(m)
7273
case t: ResolvedTemplate => siteContent(page.link.dri, t)

scala3doc/src/dotty/renderers/Locations.scala

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@ import java.nio.file.Files
1515
import java.io.File
1616
import scala.util.matching._
1717

18+
val UnresolvedLocationLink = "#"
19+
1820
trait Locations(using ctx: DocContext):
1921
def members: Map[DRI, Member]
2022

2123
// TODO verify if location exisits
22-
def rawLocation(dri: DRI): Seq[String] = dri match
23-
case `docsDRI` => List("docs", "index")
24-
case `docsRootDRI` => List("index")
25-
case `apiPageDRI` => List("api", "index")
26-
case dri if dri.isStaticFile =>
27-
Paths.get(dri.location).iterator.asScala.map(_.toString).toList
28-
case dri =>
29-
val loc = dri.location
30-
if loc == null then List("index") // Dokka leftovers
31-
else
24+
def rawLocation(dri: DRI): Seq[String] =
25+
dri match
26+
case `docsDRI` => List("docs", "index")
27+
case `docsRootDRI` => List("index")
28+
case `apiPageDRI` => List("api", "index")
29+
case dri if dri.isStaticFile =>
30+
Paths.get(dri.location).iterator.asScala.map(_.toString).toList
31+
case dri =>
32+
val loc = dri.location
3233
val fqn = loc.split(Array('.')).toList match
3334
case List("<empty>") => List("index")
3435
case other => other
@@ -38,12 +39,12 @@ trait Locations(using ctx: DocContext):
3839
private def unknownPage(dri: DRI): String =
3940
// TODO we should switch that to warning probably or has dedicated setting
4041
report.inform(s"Unrecognized page for ${dri.location} ($dri)")
41-
"#"
42+
UnresolvedLocationLink
4243

4344
def pathToPage(from: DRI, to: DRI): String =
4445
if to.isStaticFile || members.contains(to) then
4546
val anchor = if to.anchor.isEmpty then "" else "#" + to.anchor
46-
pathTo(rawLocation(from), rawLocation(to)) +".html" + anchor
47+
pathToRaw(rawLocation(from), rawLocation(to)) +".html" + anchor
4748
else
4849
to.origin match
4950
case "" =>
@@ -55,11 +56,11 @@ trait Locations(using ctx: DocContext):
5556

5657

5758

58-
def pathTo(to: Seq[String], fullFrom: Seq[String]): String =
59-
val from = fullFrom.dropRight(1)
60-
val commonPaths = to.zip(from).takeWhile{ case (a, b) => a == b }.size
59+
def pathToRaw(from: Seq[String], to: Seq[String]): String =
60+
val fromDir = from.dropRight(1)
61+
val commonPaths = to.zip(fromDir).takeWhile{ case (a, b) => a == b }.size
6162

62-
val contextPath = from.drop(commonPaths).map(_ => "..")
63+
val contextPath = fromDir.drop(commonPaths).map(_ => "..")
6364
val nodePath = to.drop(commonPaths) match
6465
case Nil if contextPath.isEmpty && to.nonEmpty=> Seq("..", to.last)
6566
case Nil => to.lastOption.fold(Seq("index"))(".." :: _ :: Nil)
@@ -68,7 +69,7 @@ trait Locations(using ctx: DocContext):
6869
(contextPath ++ nodePath).mkString("/")
6970

7071
def resolveRoot(from: Seq[String], to: String): String =
71-
pathTo(to.split("/").toList, from)
72+
pathToRaw(from, to.split("/").toList)
7273

7374
def resolveRoot(dri: DRI, path: String): String = resolveRoot(rawLocation(dri), path)
7475
def absolutePath(dri: DRI): String = rawLocation(dri).mkString("", "/", ".html")

scala3doc/src/dotty/renderers/SignatureRenderer.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ import collection.JavaConverters._
55
import java.net.URI
66
import java.net.URL
77
import java.util.{List => JList, Set => JSet}
8-
import kotlinx.html.FlowContent
9-
import kotlinx.html.stream.StreamKt
10-
import kotlinx.html.Gen_consumer_tagsKt
11-
import kotlinx.html.ApiKt
12-
import kotlinx.html.HTMLTag
13-
import kotlinx.html.DIV
148
import dotty.dokka.model.api.Link
159
import dotty.dokka.model.api.HierarchyGraph
1610
import scala.util.Try

scala3doc/src/dotty/renderers/SiteRenderer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ trait SiteRenderer(using DocContext) extends Locations:
3636

3737
val res = ctx.driForLink(content.template.templateFile, path).filter(driExisits)
3838
if res.isEmpty then report.warn(s"Unable to resolve link '$str'", content.template.file)
39-
res.headOption.fold(str)(pathToPage(_, pageDri) + prefix)
39+
res.headOption.fold(str)(pathToPage(pageDri, _) + prefix)
4040

4141
def processLocalLink(str: String): String =
4242
if str.startsWith("#") || str.isEmpty then str

scala3doc/test/dotty/dokka/ExternalLocationProviderIntegrationTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ abstract class ExternalLocationProviderIntegrationTest(
6464
linksBuilder ++= hrefValues
6565
}
6666

67-
67+
println(output)
6868
IO.foreachFileIn(output, processFile)
6969
val links = linksBuilder.result
7070
val errors = expectedLinks.flatMap(expect => Option.when(!links.contains(expect))(expect))

scala3doc/test/dotty/dokka/renderers/LocationTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class LocationTests:
1919
@Test
2020
def testLinks() =
2121
def path(from: String, to: String) =
22-
locations.pathTo(to.split('/').toList, from.split('/').toList)
22+
locations.pathToRaw(from.split('/').toList, to.split('/').toList)
2323

24-
assertEquals("a/b", locations.pathTo(Seq("a", "b"), Nil))
24+
assertEquals("a/b", locations.pathToRaw(Nil, Seq("a", "b")))
2525

2626
assertEquals(
2727
"../comments",

scala3doc/test/dotty/dokka/tasty/comments/DocFlexmarkParserTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dotty.dokka.tasty.comments
22

33
import org.junit.{Test, Rule}
44
import org.junit.Assert.{assertSame, assertTrue, assertEquals}
5+
import dotty.dokka.tasty.comments.markdown.DocFlexmarkParser
56

67
class DocFlexmarkParserTests {
78
@Test def test(): Unit = {

0 commit comments

Comments
 (0)