From f45750699d089e0101dcde5d38c7e08ec2f03708 Mon Sep 17 00:00:00 2001 From: irina-turova <31963497+irina-turova@users.noreply.github.com> Date: Wed, 31 May 2023 16:16:10 +0500 Subject: Add support for `@author`, `@since`, `@return` Javadoc tags (#2967) --- .../javadoc/JavadocClasslikeTemplateMapTest.kt | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) (limited to 'plugins/javadoc/src/test/kotlin/org/jetbrains/dokka') diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocClasslikeTemplateMapTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocClasslikeTemplateMapTest.kt index 65fbd30f..53167f71 100644 --- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocClasslikeTemplateMapTest.kt +++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocClasslikeTemplateMapTest.kt @@ -342,6 +342,104 @@ internal class JavadocClasslikeTemplateMapTest : AbstractJavadocTemplateMapTest( } } + @Test + fun `@author @since @return method tags`(){ + dualTestTemplateMapInline( + kotlin = + """ + /src/source0.kt + package com.test.package0 + class TestClass { + /** + * Testing @author @since @return method tags + * @since 1.2 + * @since 08 april 2023 + * @return parameter's value in lower case + */ + fun testFunction(testParam: String?): String { + return testParam?.lowercase() ?: "" + } + } + """, + java = + """ + /src/com/test/package0/TestClass.java + package com.test.package0; + public final class TestClass { + /** + * Testing @author @since @return method tags + * @since 1.2 + * @since 08 april 2023 + * @return parameter's value in lower case + */ + public final String testFunction(String testParam) { + return testParam.toLowerCase(); + } + } + """ + ) { + val map = singlePageOfType().templateMap + assertEquals("TestClass", map["name"]) + + val methods = assertIsInstance>(map["methods"]) + val testFunction = assertIsInstance>>(methods["own"]).single() + assertEquals("Testing @author @since @return method tags", testFunction["brief"]) + + assertEquals("testFunction", testFunction["name"]) + assertEquals(listOf("

1.2

", "

08 april 2023

"), testFunction["sinceTagContent"]) + assertEquals("

parameter's value in lower case

", testFunction["returnTagContent"]) + } + } + + @Test + fun `@author @since class tags`(){ + dualTestTemplateMapInline( + kotlin = + """ + /src/source0.kt + package com.test.package0 + /** + * Testing @author @since class tags + * @author Test Author + * @author Test Author2 + * @author Test Author3 + * @since 1.2 + * @since 08 april 2023 + */ + class TestClass { + fun testFunction(testParam: String?): String { + return testParam?.lowercase() ?: "" + } + } + """, + java = + """ + /src/com/test/package0/TestClass.java + package com.test.package0; + /** + * Testing @author @since class tags + * @author Test Author + * @author Test Author2 + * @author Test Author3 + * @since 1.2 + * @since 08 april 2023 + */ + public final class TestClass { + public final String testFunction(String testParam) { + return testParam.toLowerCase(); + } + } + """ + ) { + val map = singlePageOfType().templateMap + + assertEquals("TestClass", map["name"]) + assertEquals("

Testing @author @since class tags

", map["classlikeDocumentation"]) + assertEquals(listOf("

Test Author

", "

Test Author2

", "

Test Author3

"), map["authorTagContent"]) + assertEquals(listOf("

1.2

", "

08 april 2023

"), map["sinceTagContent"]) + } + } + private fun assertParameterNode(node: Map, expectedName: String, expectedType: String, expectedDescription: String){ assertEquals(expectedName, node["name"]) assertEquals(expectedType, node["type"]) -- cgit