1
+ package dotty .dokka
2
+
3
+ import org .jetbrains .dokka .pages .ContentPage
4
+ import org .jetbrains .dokka .pages .PageNode
5
+ import org .jetbrains .dokka .pages .RootPageNode
6
+ import org .jetbrains .dokka .pages .ModulePage
7
+ import org .jetbrains .dokka .pages .ClasslikePageNode
8
+ import org .jetbrains .dokka .model .DPackage
9
+ import org .jetbrains .dokka .plugability .DokkaContext
10
+ import org .jetbrains .dokka .base .resolvers .external ._
11
+ import org .jetbrains .dokka .base .resolvers .shared .{ExternalDocumentation => ED , _ }
12
+ import org .jetbrains .dokka .base .resolvers .local ._
13
+ import org .jetbrains .dokka .model .DisplaySourceSet
14
+ import dotty .dokka .withNoOrigin
15
+ import dotty .dokka .tasty ._
16
+
17
+ import scala .collection .JavaConverters ._
18
+ import java .nio .file .Paths
19
+ import java .nio .file .Path
20
+ import scala .util .matching ._
21
+ import dotty .dokka .model .api ._
22
+ import java .net .URL
23
+ import org .junit .{Test }
24
+ import org .junit .Assert ._
25
+
26
+ import scala .quoted ._
27
+
28
+ class ExternalLocationProviderTest :
29
+ def createExternalLocationProvider (docURL : String , ext : String , kind : DocumentationKind ) = {
30
+ val emptyExtDoc = ED (
31
+ URL (docURL),
32
+ PackageList (
33
+ RecognizedLinkFormat .Javadoc1 , JSet (), JMap (), URL (docURL)
34
+ )
35
+ )
36
+ ScalaExternalLocationProvider (emptyExtDoc, ext, kind)
37
+ }
38
+
39
+ def testResolvedLinks (provider : ScalaExternalLocationProvider , testcases : List [(DRI , String )]) = testcases.foreach {
40
+ case (dri, expect) => assertEquals(provider.resolve(dri), expect)
41
+ }
42
+
43
+ @ Test
44
+ def javadocExternalLocationProviderTest (): Unit = {
45
+ val provider = createExternalLocationProvider(" https://docs.oracle.com/javase/8/docs/api/" , " .html" , DocumentationKind .Javadoc )
46
+ val testcases = List (
47
+ (DRI (" java.util.Map$$Entry" ), " https://docs.oracle.com/javase/8/docs/api/java/util/Map.Entry.html" ),
48
+ (DRI (" javax.swing.plaf.nimbus.AbstractRegionPainter$$PaintContext$$CacheMode" ), " https://docs.oracle.com/javase/8/docs/api/javax/swing/plaf/nimbus/AbstractRegionPainter.PaintContext.CacheMode.html" ),
49
+ (DRI (" java.lang.CharSequence" ), " https://docs.oracle.com/javase/8/docs/api/java/lang/CharSequence.html" )
50
+ )
51
+ testResolvedLinks(provider, testcases)
52
+ }
53
+
54
+ @ Test
55
+ def scaladocExternalLocationProviderTest (): Unit = {
56
+ val provider = createExternalLocationProvider(" https://www.scala-lang.org/api/current/" , " .html" , DocumentationKind .Scaladoc )
57
+ val testcases = List (
58
+ (DRI (" scala.Predef$" )," https://www.scala-lang.org/api/current/scala/Predef$.html" ),
59
+ (DRI (" scala.util.package$$chaining$" ), " https://www.scala-lang.org/api/current/scala/util/package$$chaining$.html" ),
60
+ (DRI (" scala.util.Using$" ), " https://www.scala-lang.org/api/current/scala/util/Using$.html" ),
61
+ (DRI (" scala.util.matching.Regex$$Match" ), " https://www.scala-lang.org/api/current/scala/util/matching/Regex$$Match.html" )
62
+ )
63
+ testResolvedLinks(provider, testcases)
64
+ }
65
+
66
+ @ Test
67
+ def scala3docExternalLocationProviderTest (): Unit = {
68
+ val provider = createExternalLocationProvider(" https://dotty.epfl.ch/api/" , " .html" , DocumentationKind .Scala3doc )
69
+ val testcases = List (
70
+ (DRI (" scala.Predef$" )," https://dotty.epfl.ch/api/scala/Predef$.html" ),
71
+ (DRI (" scala.util.package$$chaining$" ), " https://dotty.epfl.ch/api/scala/util/package$$chaining$.html" ),
72
+ (DRI (" scala.util.Using$" ), " https://dotty.epfl.ch/api/scala/util/Using$.html" ),
73
+ (DRI (" scala.util.matching.Regex$$Match" ), " https://dotty.epfl.ch/api/scala/util/matching/Regex$$Match.html" )
74
+ )
75
+ testResolvedLinks(provider, testcases)
76
+ }
0 commit comments