aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorKrystianUjma <kujma@virtuslab.com>2019-01-18 15:36:25 +0100
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2019-02-25 18:29:13 +0300
commit5b451ab6abf60e15c8044daebc90c3a46c21c4fb (patch)
tree236746dafa9ad77a82db28db2c34bc4a0502ccae /core
parent46af103c8dd43839e898368dbda744fa522e9789 (diff)
downloaddokka-5b451ab6abf60e15c8044daebc90c3a46c21c4fb.tar.gz
dokka-5b451ab6abf60e15c8044daebc90c3a46c21c4fb.tar.bz2
dokka-5b451ab6abf60e15c8044daebc90c3a46c21c4fb.zip
Fix java doc primary constructors have duplicated parameters
#341 Fixed
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/javadoc/docbase.kt17
-rw-r--r--core/src/test/kotlin/javadoc/JavadocTest.kt10
-rw-r--r--core/testdata/javadoc/constructorParameters.kt14
3 files changed, 33 insertions, 8 deletions
diff --git a/core/src/main/kotlin/javadoc/docbase.kt b/core/src/main/kotlin/javadoc/docbase.kt
index aeb806f1..fcc017fd 100644
--- a/core/src/main/kotlin/javadoc/docbase.kt
+++ b/core/src/main/kotlin/javadoc/docbase.kt
@@ -521,12 +521,13 @@ class ModuleNodeAdapter(val module: DocumentationModule, val reporter: DocErrorR
}
private fun DocumentationNodeAdapter.collectParamTags(kind: NodeKind, sectionFilter: (ContentSection) -> Boolean) =
- (node.details(kind)
- .filter(DocumentationNode::hasNonEmptyContent)
- .map { ParamTagAdapter(module, this, it.name, true, it.content.children) }
+ (node.details(kind)
+ .filter(DocumentationNode::hasNonEmptyContent)
+ .map { ParamTagAdapter(module, this, it.name, true, it.content.children) }
- + node.content.sections
- .filter(sectionFilter)
- .map { ParamTagAdapter(module, this, it.subjectName ?: "?", true, it.children) })
-
- .toTypedArray() \ No newline at end of file
+ + node.content.sections
+ .filter(sectionFilter)
+ .map { ParamTagAdapter(module, this, it.subjectName ?: "?", true, it.children) }
+ )
+ .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 b18dacca..9ca668d8 100644
--- a/core/src/test/kotlin/javadoc/JavadocTest.kt
+++ b/core/src/test/kotlin/javadoc/JavadocTest.kt
@@ -223,6 +223,16 @@ class JavadocTest {
}
}
+ @Test
+ fun shouldNotHaveDuplicatedConstructorParameters() {
+ verifyJavadoc("testdata/javadoc/constructorParameters.kt") { doc ->
+ val classDoc = doc.classNamed("bar.Banana")!!
+ val paramTags = classDoc.constructors()[0].paramTags()
+
+ assertEquals(3, paramTags.size)
+ }
+ }
+
private fun verifyJavadoc(name: String,
withJdk: Boolean = false,
withKotlinRuntime: Boolean = false,
diff --git a/core/testdata/javadoc/constructorParameters.kt b/core/testdata/javadoc/constructorParameters.kt
new file mode 100644
index 00000000..c29ae912
--- /dev/null
+++ b/core/testdata/javadoc/constructorParameters.kt
@@ -0,0 +1,14 @@
+package bar
+
+/**
+ * Just a fruit
+ *
+ * @param weight in grams
+ * @param ranking quality from 0 to 10, where 10 is best
+ * @param color yellow is default
+ */
+class Banana (
+ private val weight: Double,
+ private val ranking: Int,
+ color: String = "yellow"
+) \ No newline at end of file