-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix link to javadoc enum entry (#2131)
- Loading branch information
1 parent
3dae816
commit c420522
Showing
7 changed files
with
370 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
plugins/base/src/test/kotlin/locationProvider/JavadocExternalLocationProviderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package locationProvider | ||
|
||
import org.jetbrains.dokka.base.resolvers.external.DefaultExternalLocationProvider | ||
import org.jetbrains.dokka.base.resolvers.external.javadoc.JavadocExternalLocationProvider | ||
import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation | ||
import org.jetbrains.dokka.base.resolvers.shared.PackageList | ||
import org.jetbrains.dokka.plugability.DokkaContext | ||
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest | ||
import org.jetbrains.dokka.links.* | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
import java.net.URL | ||
|
||
class JavadocExternalLocationProviderTest : BaseAbstractTest() { | ||
private val testDataDir = | ||
getTestDataDir("locationProvider").toAbsolutePath().toString().removePrefix("/").let { "/$it" } | ||
|
||
private val jdk = "https://docs.oracle.com/javase/8/docs/api/" | ||
private val jdkPackageListURL = URL("file://$testDataDir/jdk8-package-list") | ||
|
||
private val configuration = dokkaConfiguration { | ||
sourceSets { | ||
sourceSet { | ||
sourceRoots = listOf("src/") | ||
classpath += jvmStdlibPath!! | ||
} | ||
} | ||
} | ||
|
||
private fun getTestLocationProvider(context: DokkaContext? = null): DefaultExternalLocationProvider { | ||
val dokkaContext = context ?: DokkaContext.create(configuration, logger, emptyList()) | ||
val packageList = PackageList.load(jdkPackageListURL, 8, true)!! | ||
val externalDocumentation = | ||
ExternalDocumentation(URL(jdk), packageList) | ||
return JavadocExternalLocationProvider(externalDocumentation, "--", "-", dokkaContext) | ||
} | ||
|
||
@Test | ||
fun `link to enum entity of javadoc`() { | ||
val locationProvider = getTestLocationProvider() | ||
val ktDri = DRI( | ||
"java.nio.file", | ||
"StandardOpenOption.CREATE", | ||
extra = DRIExtraContainer().also { it[EnumEntryDRIExtra] = EnumEntryDRIExtra }.encode() | ||
) | ||
val javaDri = DRI( | ||
"java.nio.file", | ||
"StandardOpenOption", | ||
Callable("CREATE", null, emptyList()), | ||
PointingToDeclaration, | ||
DRIExtraContainer().also { it[EnumEntryDRIExtra] = EnumEntryDRIExtra }.encode() | ||
) | ||
|
||
assertEquals( | ||
"https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardOpenOption.html#CREATE", | ||
locationProvider.resolve(ktDri) | ||
) | ||
|
||
assertEquals( | ||
"https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardOpenOption.html#CREATE", | ||
locationProvider.resolve(javaDri) | ||
) | ||
} | ||
|
||
@Test | ||
fun `link to nested class of javadoc`() { | ||
val locationProvider = getTestLocationProvider() | ||
val dri = DRI( | ||
"java.rmi.activation", | ||
"ActivationGroupDesc.CommandEnvironment" | ||
) | ||
|
||
assertEquals( | ||
"https://docs.oracle.com/javase/8/docs/api/java/rmi/activation/ActivationGroupDesc.CommandEnvironment.html", | ||
locationProvider.resolve(dri) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.