aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2020-10-15 15:34:25 +0200
committerKamil Doległo <9080183+kamildoleglo@users.noreply.github.com>2020-10-15 17:04:49 +0200
commit7f948864077388e10ba3608b0d5e1d9a4ea0f4d9 (patch)
tree98ec83ad745315787d79cd662eba8a86b1f7ddcb
parent9b16f25eb2c29c362f69e5e33fce164ce0dc00e1 (diff)
downloaddokka-7f948864077388e10ba3608b0d5e1d9a4ea0f4d9.tar.gz
dokka-7f948864077388e10ba3608b0d5e1d9a4ea0f4d9.tar.bz2
dokka-7f948864077388e10ba3608b0d5e1d9a4ea0f4d9.zip
Fix displaying authors
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt4
-rw-r--r--plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt86
2 files changed, 88 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
index 261f98dd..fad5ff36 100644
--- a/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/JavadocParser.kt
@@ -240,9 +240,9 @@ class JavadocParser(
private fun PsiDocTag.contentElements(): List<PsiElement> =
dataElements.mapNotNull { it.takeIf { it is PsiDocToken && it.text.isNotBlank() } }
- private fun PsiDocTag.authorContentElements(): List<PsiElement> = listOf(
+ private fun PsiDocTag.authorContentElements(): List<PsiElement> = listOfNotNull(
dataElements[0],
- dataElements[0].nextSibling,
+ dataElements[0].nextSibling?.takeIf { it.text != dataElements.drop(1).firstOrNull()?.text },
*dataElements.drop(1).toTypedArray()
)
diff --git a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt
index cf4fa2e7..efe8949c 100644
--- a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt
+++ b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt
@@ -160,6 +160,92 @@ class ContentForParamsTest : AbstractCoreTest() {
}
@Test
+ fun `multiple authors`() {
+ testInline(
+ """
+ |/src/main/java/sample/DocGenProcessor.java
+ |package sample;
+ |/**
+ | * Annotation processor which visits all classes.
+ | *
+ | * @author googler1@google.com (Googler 1)
+ | * @author googler2@google.com (Googler 2)
+ | */
+ | public class DocGenProcessor { }
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val classPage = module.children.single { it.name == "sample" }.children.single { it.name == "DocGenProcessor" } as ContentPage
+ classPage.content.assertNode {
+ group {
+ header { +"DocGenProcessor" }
+ platformHinted {
+ group {
+ skipAllNotMatching() //Signature
+ }
+ group {
+ group {
+ group {
+ +"Annotation processor which visits all classes."
+ }
+ }
+ }
+ group {
+ header(4) { +"Author" }
+ comment { +"googler1@google.com (Googler 1)" }
+ comment { +"googler2@google.com (Googler 2)" }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+
+ @Test
+ fun `author delimetered by space`() {
+ testInline(
+ """
+ |/src/main/java/sample/DocGenProcessor.java
+ |package sample;
+ |/**
+ | * Annotation processor which visits all classes.
+ | *
+ | * @author Marcin Aman Senior
+ | */
+ | public class DocGenProcessor { }
+ """.trimIndent(), testConfiguration
+ ) {
+ pagesTransformationStage = { module ->
+ val classPage = module.children.single { it.name == "sample" }.children.single { it.name == "DocGenProcessor" } as ContentPage
+ classPage.content.assertNode {
+ group {
+ header { +"DocGenProcessor" }
+ platformHinted {
+ group {
+ skipAllNotMatching() //Signature
+ }
+ group {
+ group {
+ group {
+ +"Annotation processor which visits all classes."
+ }
+ }
+ }
+ group {
+ header(4) { +"Author" }
+ comment { +"Marcin Aman Senior" }
+ }
+ }
+ }
+ skipAllNotMatching()
+ }
+ }
+ }
+ }
+
+ @Test
fun `undocumented parameter and other tags`() {
testInline(
"""