From 3fc3e33a0eff0198ed89cc94197cb21653bf1ca2 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 30 Dec 2014 15:35:00 +0100 Subject: fix formatting of overload signatures --- src/Formats/StructuredFormatService.kt | 9 ++++++--- test/data/format/overloads.html | 24 ++++++++++++++++++++++++ test/data/format/overloads.kt | 5 +++++ test/src/format/HtmlFormatTest.kt | 6 ++++++ 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 test/data/format/overloads.html create mode 100644 test/data/format/overloads.kt diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 2131d65d..2d326854 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -148,13 +148,16 @@ public abstract class StructuredFormatService(val locationService: LocationServi appendTableCell(to) { val breakdownBySummary = members.groupBy { formatText(location, it.summary) } for ((summary, items) in breakdownBySummary) { - for (signature in items) { + val signatureTexts = items map { signature -> val signature = languageService.render(signature) val signatureAsCode = ContentCode() signatureAsCode.append(signature) - to.append(formatText(location, signatureAsCode)) + formatText(location, signatureAsCode) } - + signatureTexts.subList(0, signatureTexts.size()-1).forEach { + appendLine(to, it) + } + to.append(signatureTexts.last()) if (!summary.isEmpty()) { to.append(summary) } diff --git a/test/data/format/overloads.html b/test/data/format/overloads.html new file mode 100644 index 00000000..9ea88869 --- /dev/null +++ b/test/data/format/overloads.html @@ -0,0 +1,24 @@ + + + + +test / 
+
+

+
package 

+
+

Functions

+ + + + + + + +
+f +fun f(x: Int): Unit
+fun f(x: String): Unit

Performs an action on x.

+
+ + diff --git a/test/data/format/overloads.kt b/test/data/format/overloads.kt new file mode 100644 index 00000000..dcd2d097 --- /dev/null +++ b/test/data/format/overloads.kt @@ -0,0 +1,5 @@ +/** Performs an action on x. */ +fun f(x: Int) { } + +/** Performs an action on x. */ +fun f(x: String) { } diff --git a/test/src/format/HtmlFormatTest.kt b/test/src/format/HtmlFormatTest.kt index a47b5774..881a7828 100644 --- a/test/src/format/HtmlFormatTest.kt +++ b/test/src/format/HtmlFormatTest.kt @@ -18,4 +18,10 @@ public class HtmlFormatTest { htmlService.appendNodes(tempLocation, output, model.members.single().members) } } + + Test fun overloads() { + verifyOutput("test/data/format/overloads.kt", ".html") { model, output -> + htmlService.appendNodes(tempLocation, output, model.members) + } + } } -- cgit