aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
authorAndrea Falcone <1848683+asfalcone@users.noreply.github.com>2022-02-08 11:50:46 -0500
committerGitHub <noreply@github.com>2022-02-08 19:50:46 +0300
commit176b7354496a9135646ba9fc81976711d4de62c3 (patch)
tree3b1092fabca8fc1c3c59e7fba04242adeb57e01a /plugins/base
parenta3baeaded708f2cd4d174f1d412c25d88b14b9a5 (diff)
downloaddokka-176b7354496a9135646ba9fc81976711d4de62c3.tar.gz
dokka-176b7354496a9135646ba9fc81976711d4de62c3.tar.bz2
dokka-176b7354496a9135646ba9fc81976711d4de62c3.zip
Add support for header tags in Javadoc (#2345)
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/parsers/JavadocParser.kt3
-rw-r--r--plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt47
2 files changed, 50 insertions, 0 deletions
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 fd8a49c8..13d17f52 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()))
}
}
diff --git a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
index c066075a..4f37923b 100644
--- a/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
+++ b/plugins/base/src/test/kotlin/parsers/JavadocParserTest.kt
@@ -349,4 +349,51 @@ 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
+ | * <h1>A header</h1>
+ | * <h2>A second level header</h2>
+ | * <h3>A third level header</h3>
+ | */
+ | 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("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
+ )
+ }
+ }
+ }
}