aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java
diff options
context:
space:
mode:
authorAndrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com>2021-12-23 17:43:13 +0100
committerGitHub <noreply@github.com>2021-12-23 19:43:13 +0300
commit1f82c97e90c160a1cd37ed28d3a57b0e77cc6a1c (patch)
treec3fe4839a2e876a0c572cfc75d71e204f356bd16 /plugins/kotlin-as-java
parentbfd41ce2a0d43419a671961c19b7d755cffdcfc8 (diff)
downloaddokka-1f82c97e90c160a1cd37ed28d3a57b0e77cc6a1c.tar.gz
dokka-1f82c97e90c160a1cd37ed28d3a57b0e77cc6a1c.tar.bz2
dokka-1f82c97e90c160a1cd37ed28d3a57b0e77cc6a1c.zip
Remove filtering out primary constructors from constructors tab (#2277)
Diffstat (limited to 'plugins/kotlin-as-java')
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt3
-rw-r--r--plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt46
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>