aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2016-03-31 19:58:06 +0200
committerDmitry Jemerov <yole@jetbrains.com>2016-03-31 19:58:06 +0200
commitbebbee81476e6996064f49f2dbe5b41d3b2cf65a (patch)
treef0f3ca43ad75ae173030f03065eef518c16eb937
parent1c53c64e212b2373d8243a1dc2df242ee2f1a079 (diff)
downloaddokka-bebbee81476e6996064f49f2dbe5b41d3b2cf65a.tar.gz
dokka-bebbee81476e6996064f49f2dbe5b41d3b2cf65a.tar.bz2
dokka-bebbee81476e6996064f49f2dbe5b41d3b2cf65a.zip
Correctly format code samples in overload groups. Resolves #55
-rw-r--r--core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt3
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt19
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt2
-rw-r--r--core/testdata/format/website/sample.kt16
-rw-r--r--core/testdata/format/website/sample.md33
5 files changed, 71 insertions, 2 deletions
diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
index 14157cff..9a739216 100644
--- a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
+++ b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt
@@ -51,7 +51,8 @@ class KotlinWebsiteFormatService @Inject constructor(locationService: LocationSe
}
override fun appendAsOverloadGroup(to: StringBuilder, block: () -> Unit) {
- div(to, "overload-group", block)
+ block()
+ to.append("<div class=\"overload-group\"></div>")
}
override fun formatLink(text: String, href: String): String {
diff --git a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
new file mode 100644
index 00000000..a96139fd
--- /dev/null
+++ b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
@@ -0,0 +1,19 @@
+package org.jetbrains.dokka.tests
+
+import org.jetbrains.dokka.KotlinLanguageService
+import org.jetbrains.dokka.KotlinWebsiteFormatService
+import org.junit.Test
+
+class KotlinWebSiteFormatTest {
+ private val kwsService = KotlinWebsiteFormatService(InMemoryLocationService, KotlinLanguageService())
+
+ @Test fun sample() {
+ verifyKWSNodeByName("sample", "foo")
+ }
+
+ 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/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index f306ac74..15be6c77 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -4,7 +4,7 @@ import org.jetbrains.dokka.KotlinLanguageService
import org.jetbrains.dokka.MarkdownFormatService
import org.junit.Test
-public class MarkdownFormatTest {
+class MarkdownFormatTest {
private val markdownService = MarkdownFormatService(InMemoryLocationService, KotlinLanguageService())
@Test fun emptyDescription() {
diff --git a/core/testdata/format/website/sample.kt b/core/testdata/format/website/sample.kt
new file mode 100644
index 00000000..a664c2f5
--- /dev/null
+++ b/core/testdata/format/website/sample.kt
@@ -0,0 +1,16 @@
+/**
+ * Groups elements of the original sequence by the key returned by the given [keySelector] function
+ * applied to each element and returns a map where each group key is associated with a list of corresponding elements.
+ * @sample example1
+ */
+fun foo(): Int {
+ return 0
+}
+
+fun foo(i: Int): Int {
+ return 1
+}
+
+fun example1(node: String) = if (true) {
+ println(property)
+}
diff --git a/core/testdata/format/website/sample.md b/core/testdata/format/website/sample.md
new file mode 100644
index 00000000..1b50d76c
--- /dev/null
+++ b/core/testdata/format/website/sample.md
@@ -0,0 +1,33 @@
+---
+title: foo - test
+layout: api
+---
+
+<div class='api-docs-breadcrumbs'><a href="test/index">test</a> / <a href="test/foo">foo</a></div>
+
+
+# foo
+
+<div class="overload-group"><div class="signature"><code><span class="keyword">fun </span><span class="identifier">foo</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Int</span></code><br/>
+</div>
+
+Groups elements of the original sequence by the key returned by the given <a href="#">keySelector</a> function
+applied to each element and returns a map where each group key is associated with a list of corresponding elements.
+
+<br/>
+``` kotlin
+if (true) {
+ println(property)
+}
+```
+<br/>
+<br/>
+<br/>
+<br/>
+<br/>
+</div>
+<div class="overload-group"><div class="signature"><code><span class="keyword">fun </span><span class="identifier">foo</span><span class="symbol">(</span><span class="parameterName">i</span><span class="symbol">:</span>&nbsp;<span class="identifier">Int</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Int</span></code><br/>
+</div>
+<br/>
+<br/>
+</div>