diff options
Diffstat (limited to 'plugins/kotlin-as-java')
-rw-r--r-- | plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt | 3 | ||||
-rw-r--r-- | plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt | 46 |
2 files changed, 47 insertions, 2 deletions
diff --git a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt index b8e12553..531ff59f 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt @@ -26,8 +26,9 @@ class KotlinAsJavaPlugin : DokkaPlugin() { signatureProvider providing ::JavaSignatureProvider override kotlinSignatureProvider } } + val kotlinAsJavaDocumentableToPageTranslator by extending { CoreExtensions.documentableToPageTranslator providing ::KotlinAsJavaDocumentableToPageTranslator override plugin<DokkaBase>().documentableToPageTranslator } -}
\ No newline at end of file +} diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt index 655405b9..5fcb22aa 100644 --- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt +++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt @@ -15,6 +15,7 @@ import utils.A import utils.Span import utils.TestOutputWriterPlugin import utils.match +import kotlin.test.assertEquals class KotlinAsJavaPluginTest : BaseAbstractTest() { @@ -87,7 +88,7 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() { .map { it.content } val children = contentList.flatMap { content -> - content.mainContents.first().cast<ContentGroup>().children + content.mainContents.single { it is ContentGroup }.children .filterIsInstance<ContentTable>() .filter { it.children.isNotEmpty() } } @@ -437,6 +438,49 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() { } } } + + @Test + fun `should render primary kotlin constructor as a java constructor`() { + val writerPlugin = TestOutputWriterPlugin() + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + externalDocumentationLinks = listOf( + DokkaConfiguration.ExternalDocumentationLink.jdk(8), + stdlibExternalDocumentationLink + ) + } + } + } + testInline( + """ + |/src/main/kotlin/kotlinAsJavaPlugin/Test.kt + |package kotlinAsJavaPlugin + | + |class Test(val xd: Int) + """.trimMargin(), + configuration, + pluginOverrides = listOf(writerPlugin), + cleanupOutput = true + ) { + pagesGenerationStage = { root -> + val content = root.children + .flatMap { it.children<ContentPage>() } + .map { it.content }.single().mainContents + + val text = content.single { it is ContentHeader }.children + .single() as ContentText + + assertEquals("Constructors", text.text) + } + renderingStage = { _, _ -> + writerPlugin.writer.renderedContent("root/kotlinAsJavaPlugin/-test/-test.html").signature().first().match( + A("Test"), A("Test"), "(", A("Integer"), "xd)", Span(), ignoreSpanWithTokenStyle = true + ) + } + } + } } private val ContentNode.mainContents: List<ContentNode> |