From 9d7f9fec41d33a636b19125b582c2aeb24a8b6e5 Mon Sep 17 00:00:00 2001 From: KrystianUjma Date: Thu, 23 May 2019 16:26:02 +0200 Subject: #465 - fix javadoc parameters generation for java classes --- core/src/main/kotlin/javadoc/docbase.kt | 10 +++++++--- core/src/test/kotlin/javadoc/JavadocTest.kt | 8 ++++++++ core/src/test/kotlin/model/KotlinAsJavaTest.kt | 2 +- core/testdata/javadoc/functionParameters.java | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 core/testdata/javadoc/functionParameters.java (limited to 'core') diff --git a/core/src/main/kotlin/javadoc/docbase.kt b/core/src/main/kotlin/javadoc/docbase.kt index ace4ae0c..62d0ee26 100644 --- a/core/src/main/kotlin/javadoc/docbase.kt +++ b/core/src/main/kotlin/javadoc/docbase.kt @@ -531,7 +531,11 @@ private fun DocumentationNodeAdapter.collectParamTags(kind: NodeKind, sectionFil + node.content.sections .filter(sectionFilter) - .map { ParamTagAdapter(module, this, it.subjectName ?: "?", true, it.children) } + .map { + ParamTagAdapter(module, this, it.subjectName ?: "?", true, + it.children.filterNot { contentNode -> contentNode is LazyContentBlock } ) - .distinctBy { it.parameterName } - .toTypedArray() \ No newline at end of file + } + ) + .distinctBy { it.parameterName } + .toTypedArray() \ No newline at end of file diff --git a/core/src/test/kotlin/javadoc/JavadocTest.kt b/core/src/test/kotlin/javadoc/JavadocTest.kt index d4f82571..64ada1d5 100644 --- a/core/src/test/kotlin/javadoc/JavadocTest.kt +++ b/core/src/test/kotlin/javadoc/JavadocTest.kt @@ -304,6 +304,14 @@ class JavadocTest { } } + @Test + fun functionParameters() { + verifyJavadoc("testdata/javadoc/functionParameters.java") { doc -> + val tags = doc.classNamed("bar.Foo")!!.methods().first().paramTags() + assertEquals((tags.first() as ParamTagAdapter).content.size, 1) + assertEquals((tags[1] as ParamTagAdapter).content.size, 1) + } + } private fun verifyJavadoc(name: String, modelConfig: ModelConfig = ModelConfig(), diff --git a/core/src/test/kotlin/model/KotlinAsJavaTest.kt b/core/src/test/kotlin/model/KotlinAsJavaTest.kt index b5c15618..8249dd0f 100644 --- a/core/src/test/kotlin/model/KotlinAsJavaTest.kt +++ b/core/src/test/kotlin/model/KotlinAsJavaTest.kt @@ -5,8 +5,8 @@ import org.jetbrains.dokka.NodeKind import org.jetbrains.dokka.Platform import org.jetbrains.dokka.RefKind import org.junit.Assert -import org.junit.Test import org.junit.Assert.assertEquals +import org.junit.Test class KotlinAsJavaTest { @Test fun function() { diff --git a/core/testdata/javadoc/functionParameters.java b/core/testdata/javadoc/functionParameters.java new file mode 100644 index 00000000..8d5f5143 --- /dev/null +++ b/core/testdata/javadoc/functionParameters.java @@ -0,0 +1,17 @@ +package bar; + +/** + * Foo + */ + +public class Foo { + + /** perfom request + * + * @param name user name + * @param password user password + */ + public void request(String name, String password) { + + } +} \ No newline at end of file -- cgit