From 0b373bb669c65ec67873fef77fc3a6cb72fb9023 Mon Sep 17 00:00:00 2001
From: Andrea Falcone <1848683+asfalcone@users.noreply.github.com>
Date: Fri, 4 Feb 2022 16:30:10 -0500
Subject: [PATCH 1/6] Add support for header tags in Javadoc
---
.../src/main/kotlin/translators/psi/parsers/JavadocParser.kt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt
index fd8a49c89b..13d17f521e 100644
--- a/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt
@@ -421,6 +421,9 @@ class JavadocParser(
parsed
}
}
+ "h1" -> ifChildrenPresent { H1(children) }
+ "h2" -> ifChildrenPresent { H2(children) }
+ "h3" -> ifChildrenPresent { H3(children) }
else -> listOf(Text(body = element.ownText()))
}
}
From b00eeecfdfac2a0a6a1d6551a33b5cad93407a6d Mon Sep 17 00:00:00 2001
From: Andrea Falcone <1848683+asfalcone@users.noreply.github.com>
Date: Fri, 4 Feb 2022 16:46:35 -0500
Subject: [PATCH 2/6] Add test for H1, H2, H3
---
.../test/kotlin/parsers/JavadocParserTest.kt | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
index c066075aca..c9ca69b80a 100644
--- a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
+++ b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
@@ -349,4 +349,41 @@ class JavadocParserTest : BaseAbstractTest() {
}
}
}
+
+ @Test
+ fun `header tags are handled properly`() {
+ val source = """
+ |/src/main/kotlin/test/Test.java
+ |package example
+ |
+ | /**
+ | * An example of using the header tags
+ | *
A header
+ | * A second level header
+ | * A third level header
+ | */
+ | public class Test {}
+ """.trimIndent()
+ testInline(
+ source,
+ configuration,
+ ) {
+ documentablesCreationStage = { modules ->
+ val docs = modules.first().packages.first().classlikes.single().documentation.first().value
+ val root = docs.children.first().root
+
+ kotlin.test.assertEquals(
+ listOf(
+ P(children = listOf(
+ Text(body = "An example of using the header tags"),
+ H1(body = "A header"),
+ H1(body = "A second level header"),
+ H3(body = "A third level header")
+ )),
+ ),
+ root.children
+ )
+ }
+ }
+ }
}
From 211eceebc6d4bb819b6d986a5e6877d30c1b47ec Mon Sep 17 00:00:00 2001
From: Andrea Falcone <1848683+asfalcone@users.noreply.github.com>
Date: Fri, 4 Feb 2022 20:23:12 -0500
Subject: [PATCH 3/6] fix test
---
.../test/kotlin/parsers/JavadocParserTest.kt | 20 +++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
index c9ca69b80a..b7aa854025 100644
--- a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
+++ b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
@@ -375,10 +375,22 @@ class JavadocParserTest : BaseAbstractTest() {
kotlin.test.assertEquals(
listOf(
P(children = listOf(
- Text(body = "An example of using the header tags"),
- H1(body = "A header"),
- H1(body = "A second level header"),
- H3(body = "A third level header")
+ Text("An example of using the header tags),
+ H1(
+ listOf(
+ Text("A header")
+ )
+ ),
+ H1(
+ listOf(
+ Text("A second level header")
+ )
+ ),
+ H3(
+ listOf(
+ Text("A third level header")
+ )
+ )
)),
),
root.children
From 4aa138af049fc3cd49e4bd49408fcfe06a2abbb3 Mon Sep 17 00:00:00 2001
From: Andrea Falcone <1848683+asfalcone@users.noreply.github.com>
Date: Fri, 4 Feb 2022 20:35:15 -0500
Subject: [PATCH 4/6] fix test
---
plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
index b7aa854025..e9c299de97 100644
--- a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
+++ b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
@@ -375,13 +375,13 @@ class JavadocParserTest : BaseAbstractTest() {
kotlin.test.assertEquals(
listOf(
P(children = listOf(
- Text("An example of using the header tags),
+ Text("An example of using the header tags"),
H1(
listOf(
Text("A header")
)
),
- H1(
+ H2(
listOf(
Text("A second level header")
)
@@ -391,7 +391,7 @@ class JavadocParserTest : BaseAbstractTest() {
Text("A third level header")
)
)
- )),
+ ))
),
root.children
)
From 12490b0f01bff1818035683ebfbf5d40e0ba6146 Mon Sep 17 00:00:00 2001
From: Andrea Falcone <1848683+asfalcone@users.noreply.github.com>
Date: Fri, 4 Feb 2022 21:12:23 -0500
Subject: [PATCH 5/6] fix test
---
plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
index e9c299de97..56d8ec705b 100644
--- a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
+++ b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
@@ -375,7 +375,7 @@ class JavadocParserTest : BaseAbstractTest() {
kotlin.test.assertEquals(
listOf(
P(children = listOf(
- Text("An example of using the header tags"),
+ Text("An example of using the header tags "),
H1(
listOf(
Text("A header")
From 8bf32cd9c8a777fc48759fb2362f367e3b8e7e5e Mon Sep 17 00:00:00 2001
From: Andrea Falcone <1848683+asfalcone@users.noreply.github.com>
Date: Mon, 7 Feb 2022 16:28:10 -0500
Subject: [PATCH 6/6] fix test
---
.../test/kotlin/parsers/JavadocParserTest.kt | 32 +++++++++----------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
index 56d8ec705b..4f37923b19 100644
--- a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
+++ b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
@@ -374,24 +374,22 @@ class JavadocParserTest : BaseAbstractTest() {
kotlin.test.assertEquals(
listOf(
- P(children = listOf(
- Text("An example of using the header tags "),
- H1(
- listOf(
- Text("A header")
- )
- ),
- H2(
- listOf(
- Text("A second level header")
- )
- ),
- H3(
- listOf(
- Text("A third level header")
- )
+ P(children = listOf(Text("An example of using the header tags "))),
+ H1(
+ listOf(
+ Text("A header")
+ )
+ ),
+ H2(
+ listOf(
+ Text("A second level header")
)
- ))
+ ),
+ H3(
+ listOf(
+ Text("A third level header")
+ )
+ )
),
root.children
)