diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-10-01 16:15:14 +0200 |
---|---|---|
committer | Kamil Doległo <9080183+kamildoleglo@users.noreply.github.com> | 2020-10-01 17:01:21 +0200 |
commit | 71b03f6d311c6ebfdf67c593e97a7483a64844f4 (patch) | |
tree | 6409cea41bdcde2a56159de86e9610e94e72375e /plugins/base/src/test | |
parent | fbee5a49ee4c21bf0f31362bf1f9af46adba7a44 (diff) | |
download | dokka-71b03f6d311c6ebfdf67c593e97a7483a64844f4.tar.gz dokka-71b03f6d311c6ebfdf67c593e97a7483a64844f4.tar.bz2 dokka-71b03f6d311c6ebfdf67c593e97a7483a64844f4.zip |
Add parsing of package-info in java sources
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r-- | plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt | 71 |
1 files changed, 60 insertions, 11 deletions
diff --git a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt index eb682b14..5d3f7398 100644 --- a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt +++ b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt @@ -1,9 +1,9 @@ package translators -import org.jetbrains.dokka.model.DModule -import org.jetbrains.dokka.model.doc.Description import org.jetbrains.dokka.model.doc.Text +import org.jetbrains.dokka.model.firstMemberOfType import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test @@ -22,21 +22,21 @@ class DefaultPsiToDocumentableTranslatorTest : AbstractCoreTest() { testInline( """ |/src/main/java/sample/BaseClass1.java - |package sample + |package sample; |public class BaseClass1 { | /** B1 */ | void x() { } |} | |/src/main/java/sample/BaseClass2.java - |package sample + |package sample; |public class BaseClass2 extends BaseClass1 { | /** B2 */ | void x() { } |} | |/src/main/java/sample/X.java - |package sample + |package sample; |public class X extends BaseClass2 { | void x() { } |} @@ -67,21 +67,21 @@ class DefaultPsiToDocumentableTranslatorTest : AbstractCoreTest() { testInline( """ |/src/main/java/sample/BaseClass1.java - |package sample + |package sample; |public class BaseClass1 { | /** B1 */ | void x() { } |} | |/src/main/java/sample/Interface1.java - |package sample + |package sample; |public interface Interface1 { | /** I1 */ | void x() {} |} | |/src/main/java/sample/X.java - |package sample + |package sample; |public class X extends BaseClass1 implements Interface1 { | void x() { } |} @@ -112,20 +112,20 @@ class DefaultPsiToDocumentableTranslatorTest : AbstractCoreTest() { testInline( """ |/src/main/java/sample/BaseClass1.java - |package sample + |package sample; |public class BaseClass1 { | /** B1 */ | void x() { } |} | |/src/main/java/sample/BaseClass2.java - |package sample + |package sample; |public class BaseClass2 extends BaseClass1 { | void x() {} |} | |/src/main/java/sample/X.java - |package sample + |package sample; |public class X extends BaseClass2 { | void x() { } |} @@ -141,4 +141,53 @@ class DefaultPsiToDocumentableTranslatorTest : AbstractCoreTest() { } } } + + @Test + fun `java package-info package description`() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/main/java") + } + } + } + + testInline( + """ + |/src/main/java/sample/BaseClass1.java + |package sample; + |public class BaseClass1 { + | /** B1 */ + | void x() { } + |} + | + |/src/main/java/sample/BaseClass2.java + |package sample; + |public class BaseClass2 extends BaseClass1 { + | void x() {} + |} + | + |/src/main/java/sample/X.java + |package sample; + |public class X extends BaseClass2 { + | void x() { } + |} + | + |/src/main/java/sample/package-info.java + |/** + | * Here comes description from package-info + | */ + |package sample; + """.trimMargin(), + configuration + ) { + documentablesMergingStage = { module -> + val documentationOfPackage = module.packages.single().documentation.values.single().children.single() + .firstMemberOfType<Text>().body + assertEquals( + "Here comes description from package-info", documentationOfPackage + ) + } + } + } } |