From 68318a6e3960ffb965b77ca66e9e28ad6ea06442 Mon Sep 17 00:00:00 2001
From: Dmitry Jemerov
Date: Fri, 1 Apr 2016 16:30:47 +0200
Subject: KT-11329: improve formatting of KDoc sections
---
.../main/kotlin/Formats/StructuredFormatService.kt | 7 ++++--
.../test/kotlin/format/KotlinWebSiteFormatTest.kt | 4 ++++
core/testdata/format/accessor.md | 4 ++++
core/testdata/format/javaSeeTag.html | 4 ++--
core/testdata/format/javaSpaceInAuthor.md | 2 ++
core/testdata/format/see.html | 4 ++--
core/testdata/format/website/returnTag.kt | 11 ++++++++++
core/testdata/format/website/returnTag.md | 25 ++++++++++++++++++++++
8 files changed, 55 insertions(+), 6 deletions(-)
create mode 100644 core/testdata/format/website/returnTag.kt
create mode 100644 core/testdata/format/website/returnTag.md
(limited to 'core')
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index 15a4dfba..4f64baa1 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -256,8 +256,11 @@ abstract class StructuredFormatService(locationService: LocationService,
}
for (section in content.sections.filter { it.subjectName == null }) {
- appendLine(to, formatStrong(formatText(section.tag)))
- appendLine(to, formatText(location, section))
+ val sectionText = buildString {
+ appendLine(this, formatStrong(formatText(section.tag)))
+ append(formatText(location, section))
+ }
+ appendParagraph(to, sectionText)
}
}
diff --git a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
index a96139fd..d4738b2f 100644
--- a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
+++ b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
@@ -11,6 +11,10 @@ class KotlinWebSiteFormatTest {
verifyKWSNodeByName("sample", "foo")
}
+ @Test fun returnTag() {
+ verifyKWSNodeByName("returnTag", "indexOf")
+ }
+
private fun verifyKWSNodeByName(fileName: String, name: String) {
verifyOutput("testdata/format/website/$fileName.kt", ".md") { model, output ->
kwsService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == name })
diff --git a/core/testdata/format/accessor.md b/core/testdata/format/accessor.md
index 8279f452..eb326727 100644
--- a/core/testdata/format/accessor.md
+++ b/core/testdata/format/accessor.md
@@ -4,11 +4,14 @@
# x
`var x: String`
+
**Getter**
The getter returns an empty string.
+
+
**Setter**
The setter does nothing.
@@ -16,3 +19,4 @@ The setter does nothing.
+
diff --git a/core/testdata/format/javaSeeTag.html b/core/testdata/format/javaSeeTag.html
index e5e17f6d..3269c5a0 100644
--- a/core/testdata/format/javaSeeTag.html
+++ b/core/testdata/format/javaSeeTag.html
@@ -8,8 +8,8 @@
Foo
open class Foo
-See Also
-#bar
+See Also
+#bar
Constructors
diff --git a/core/testdata/format/javaSpaceInAuthor.md b/core/testdata/format/javaSpaceInAuthor.md
index 4d19ed01..e464f0a0 100644
--- a/core/testdata/format/javaSpaceInAuthor.md
+++ b/core/testdata/format/javaSpaceInAuthor.md
@@ -7,11 +7,13 @@
+
**Author**
Dmitry Jemerov
+
### Constructors
diff --git a/core/testdata/format/see.html b/core/testdata/format/see.html
index e5ae4669..e39711bb 100644
--- a/core/testdata/format/see.html
+++ b/core/testdata/format/see.html
@@ -7,10 +7,10 @@
quux
fun quux(): Unit
-See Also
+See Also
foo
bar
-
+
test / foo
diff --git a/core/testdata/format/website/returnTag.kt b/core/testdata/format/website/returnTag.kt
new file mode 100644
index 00000000..669c14f9
--- /dev/null
+++ b/core/testdata/format/website/returnTag.kt
@@ -0,0 +1,11 @@
+class Foo
+
+/**
+ * Returns the index within this string of the first occurrence of the specified character, starting from the specified [startIndex].
+ *
+ * @param ignoreCase `true` to ignore character case when matching a character. By default `false`.
+ * @returns An index of the first occurrence of [char] or -1 if none is found.
+ */
+fun Foo.indexOf(char: Char, startIndex: Int = 0, ignoreCase: Boolean = false): Int {
+ return -1
+}
diff --git a/core/testdata/format/website/returnTag.md b/core/testdata/format/website/returnTag.md
new file mode 100644
index 00000000..301635ad
--- /dev/null
+++ b/core/testdata/format/website/returnTag.md
@@ -0,0 +1,25 @@
+---
+title: indexOf - test
+layout: api
+---
+
+
+
+
+# indexOf
+
+fun Foo.indexOf(
char: Char,
startIndex: Int = 0,
ignoreCase: Boolean = false
): Int
+
+
+Returns the index within this string of the first occurrence of the specified character, starting from the specified startIndex.
+
+
+### Parameters
+
+ignoreCase
- true
to ignore character case when matching a character. By default false
.
+
+**Returns**
+An index of the first occurrence of char or -1 if none is found.
+
+
+
--
cgit