diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt | 4 | ||||
-rw-r--r-- | core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt | 23 | ||||
-rw-r--r-- | core/testdata/format/website-samples/sample.kt | 16 | ||||
-rw-r--r-- | core/testdata/format/website-samples/sample.md | 38 | ||||
-rw-r--r-- | core/testdata/format/website-samples/sampleWithAsserts.kt (renamed from core/testdata/format/website/sampleWithAsserts.kt) | 0 | ||||
-rw-r--r-- | core/testdata/format/website-samples/sampleWithAsserts.md (renamed from core/testdata/format/website/sampleWithAsserts.md) | 0 | ||||
-rw-r--r-- | core/testdata/format/website/sample.md | 9 |
7 files changed, 77 insertions, 13 deletions
diff --git a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt index e7677862..3363b0a3 100644 --- a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt +++ b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt @@ -19,10 +19,6 @@ class KotlinWebSiteFormatTest { verifyKWSNodeByName("overloadGroup", "magic") } - @Test fun sampleWithAsserts() { - verifyKWSNodeByName("sampleWithAsserts", "a") - } - private fun verifyKWSNodeByName(fileName: String, name: String) { verifyOutput("testdata/format/website/$fileName.kt", ".md", format = "kotlin-website") { model, output -> kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.filter { it.name == name }) diff --git a/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt new file mode 100644 index 00000000..1f514932 --- /dev/null +++ b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt @@ -0,0 +1,23 @@ +package org.jetbrains.dokka.tests + +import org.jetbrains.dokka.KotlinLanguageService +import org.jetbrains.dokka.KotlinWebsiteRunnableSamplesFormatService +import org.junit.Test + +class KotlinWebSiteRunnableSamplesFormatTest { + private val kwsService = KotlinWebsiteRunnableSamplesFormatService(InMemoryLocationService, KotlinLanguageService()) + + @Test fun sample() { + verifyKWSNodeByName("sample", "foo") + } + + @Test fun sampleWithAsserts() { + verifyKWSNodeByName("sampleWithAsserts", "a") + } + + private fun verifyKWSNodeByName(fileName: String, name: String) { + verifyOutput("testdata/format/website-samples/$fileName.kt", ".md", format = "kotlin-website-samples") { model, output -> + kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.filter { it.name == name }) + } + } +} diff --git a/core/testdata/format/website-samples/sample.kt b/core/testdata/format/website-samples/sample.kt new file mode 100644 index 00000000..a664c2f5 --- /dev/null +++ b/core/testdata/format/website-samples/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-samples/sample.md b/core/testdata/format/website-samples/sample.md new file mode 100644 index 00000000..203f1b02 --- /dev/null +++ b/core/testdata/format/website-samples/sample.md @@ -0,0 +1,38 @@ +--- +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" markdown="1"> + +<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></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. + +<div class="sample" markdown="1"> + +``` kotlin + +fun main(args: Array<String>) { +//sampleStart +if (true) { + println(property) +} +//sampleEnd +} +``` + +</div> + +</div> + +<div class="overload-group" markdown="1"> + +<div class="signature"><code><span class="keyword">fun </span><span class="identifier">foo</span><span class="symbol">(</span><span class="parameterName" id="$foo(kotlin.Int)/i">i</span><span class="symbol">:</span> <span class="identifier">Int</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Int</span></code></div> + +</div> diff --git a/core/testdata/format/website/sampleWithAsserts.kt b/core/testdata/format/website-samples/sampleWithAsserts.kt index bb9732d5..bb9732d5 100644 --- a/core/testdata/format/website/sampleWithAsserts.kt +++ b/core/testdata/format/website-samples/sampleWithAsserts.kt diff --git a/core/testdata/format/website/sampleWithAsserts.md b/core/testdata/format/website-samples/sampleWithAsserts.md index 98d7df33..98d7df33 100644 --- a/core/testdata/format/website/sampleWithAsserts.md +++ b/core/testdata/format/website-samples/sampleWithAsserts.md diff --git a/core/testdata/format/website/sample.md b/core/testdata/format/website/sample.md index 203f1b02..7c11790f 100644 --- a/core/testdata/format/website/sample.md +++ b/core/testdata/format/website/sample.md @@ -14,23 +14,14 @@ layout: api 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. -<div class="sample" markdown="1"> - ``` kotlin - -fun main(args: Array<String>) { -//sampleStart if (true) { println(property) } -//sampleEnd -} ``` </div> -</div> - <div class="overload-group" markdown="1"> <div class="signature"><code><span class="keyword">fun </span><span class="identifier">foo</span><span class="symbol">(</span><span class="parameterName" id="$foo(kotlin.Int)/i">i</span><span class="symbol">:</span> <span class="identifier">Int</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Int</span></code></div> |