aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-10-30 18:43:48 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-10-30 18:43:48 +0100
commite4b2ae90bf0e84f76ceb7c56b7c128d28adad917 (patch)
treeb1e7d86b808b41909679d44da8ac97bec1928c44 /test
parent17492c5f48c459dd44eafb0e747c1164193ca7f7 (diff)
downloaddokka-e4b2ae90bf0e84f76ceb7c56b7c128d28adad917.tar.gz
dokka-e4b2ae90bf0e84f76ceb7c56b7c128d28adad917.tar.bz2
dokka-e4b2ae90bf0e84f76ceb7c56b7c128d28adad917.zip
initial support for generating javadoc from Kotlin light classes
Diffstat (limited to 'test')
-rw-r--r--test/src/TestAPI.kt12
-rw-r--r--test/src/model/KotlinAsJavaTest.kt32
2 files changed, 42 insertions, 2 deletions
diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt
index 59b6495b..c4be6623 100644
--- a/test/src/TestAPI.kt
+++ b/test/src/TestAPI.kt
@@ -16,6 +16,7 @@ import kotlin.test.fail
public fun verifyModel(vararg roots: ContentRoot,
withJdk: Boolean = false,
withKotlinRuntime: Boolean = false,
+ packageDocumentationBuilder: PackageDocumentationBuilder? = null,
verifier: (DocumentationModule) -> Unit) {
val messageCollector = object : MessageCollector {
override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation) {
@@ -46,7 +47,9 @@ public fun verifyModel(vararg roots: ContentRoot,
addRoots(roots.toList())
}
val options = DocumentationOptions(includeNonPublic = true, skipEmptyPackages = false, sourceLinks = listOf<SourceLinkDefinition>())
- val documentation = buildDocumentationModule(environment, "test", options, logger = DokkaConsoleLogger)
+ val documentation = buildDocumentationModule(environment, "test", options,
+ packageDocumentationBuilder = packageDocumentationBuilder,
+ logger = DokkaConsoleLogger)
verifier(documentation)
Disposer.dispose(environment)
}
@@ -54,8 +57,13 @@ public fun verifyModel(vararg roots: ContentRoot,
public fun verifyModel(source: String,
withJdk: Boolean = false,
withKotlinRuntime: Boolean = false,
+ packageDocumentationBuilder: PackageDocumentationBuilder? = null,
verifier: (DocumentationModule) -> Unit) {
- verifyModel(contentRootFromPath(source), withJdk = withJdk, withKotlinRuntime = withKotlinRuntime, verifier = verifier)
+ verifyModel(contentRootFromPath(source),
+ withJdk = withJdk,
+ withKotlinRuntime = withKotlinRuntime,
+ packageDocumentationBuilder = packageDocumentationBuilder,
+ verifier = verifier)
}
public fun verifyPackageMember(kotlinSource: String,
diff --git a/test/src/model/KotlinAsJavaTest.kt b/test/src/model/KotlinAsJavaTest.kt
new file mode 100644
index 00000000..25ee5fad
--- /dev/null
+++ b/test/src/model/KotlinAsJavaTest.kt
@@ -0,0 +1,32 @@
+package org.jetbrains.dokka.tests
+
+import org.jetbrains.dokka.DocumentationModule
+import org.jetbrains.dokka.DocumentationNode
+import org.jetbrains.dokka.KotlinAsJavaDocumentationBuilder
+import org.junit.Test
+import kotlin.test.assertEquals
+
+class KotlinAsJavaTest {
+ @Test fun function() {
+ verifyModelAsJava("test/data/functions/function.kt") { model ->
+ val pkg = model.members.single()
+
+ val facadeClass = pkg.members.single { it.name == "FunctionKt" }
+ assertEquals(DocumentationNode.Kind.Class, facadeClass.kind)
+
+ val fn = facadeClass.members.single()
+ assertEquals("fn", fn.name)
+ assertEquals(DocumentationNode.Kind.CompanionObjectFunction, fn.kind)
+ }
+ }
+}
+
+fun verifyModelAsJava(source: String,
+ withJdk: Boolean = false,
+ withKotlinRuntime: Boolean = false,
+ verifier: (DocumentationModule) -> Unit) {
+ verifyModel(source,
+ withJdk = withJdk, withKotlinRuntime = withKotlinRuntime,
+ packageDocumentationBuilder = KotlinAsJavaDocumentationBuilder(),
+ verifier = verifier)
+}