From 2eb805e47505388c0e47102e9257f6f79681e699 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 9 Mar 2017 17:47:09 +0300 Subject: Create HTML based format for kotlin-website --- .../Formats/KotlinWebsiteHtmlFormatService.kt | 193 +++++++++++++++++++++ core/src/main/kotlin/Formats/StandardFormats.kt | 6 + .../main/kotlin/Formats/StructuredFormatService.kt | 2 +- .../dokka/format/kotlin-website-html.properties | 2 + .../kotlin/format/KotlinWebSiteHtmlFormatTest.kt | 74 ++++++++ core/testdata/format/website-html/dataTags/jre7.kt | 11 ++ core/testdata/format/website-html/dataTags/js.kt | 11 ++ core/testdata/format/website-html/dataTags/jvm.kt | 11 ++ .../dataTags/multiplatform.package.html | 63 +++++++ .../website-html/dataTagsInGroupNode/jre7.kt | 0 .../format/website-html/dataTagsInGroupNode/js.kt | 8 + .../format/website-html/dataTagsInGroupNode/jvm.kt | 9 + .../dataTagsInGroupNode/multiplatform.html | 38 ++++ .../dataTagsInGroupNode/multiplatform.package.html | 33 ++++ core/testdata/format/website-html/dropImport.html | 11 ++ core/testdata/format/website-html/dropImport.kt | 12 ++ .../format/website-html/newLinesInImportList.html | 12 ++ .../format/website-html/newLinesInImportList.kt | 12 ++ .../format/website-html/newLinesInSamples.html | 19 ++ .../format/website-html/newLinesInSamples.kt | 19 ++ .../format/website-html/overloadGroup.html | 18 ++ core/testdata/format/website-html/overloadGroup.kt | 15 ++ core/testdata/format/website-html/returnTag.html | 9 + core/testdata/format/website-html/returnTag.kt | 11 ++ core/testdata/format/website-html/sample.html | 21 +++ core/testdata/format/website-html/sample.kt | 16 ++ .../format/website-html/sampleWithAsserts.html | 12 ++ .../format/website-html/sampleWithAsserts.kt | 15 ++ 28 files changed, 662 insertions(+), 1 deletion(-) create mode 100644 core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt create mode 100644 core/src/main/resources/dokka/format/kotlin-website-html.properties create mode 100644 core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt create mode 100644 core/testdata/format/website-html/dataTags/jre7.kt create mode 100644 core/testdata/format/website-html/dataTags/js.kt create mode 100644 core/testdata/format/website-html/dataTags/jvm.kt create mode 100644 core/testdata/format/website-html/dataTags/multiplatform.package.html create mode 100644 core/testdata/format/website-html/dataTagsInGroupNode/jre7.kt create mode 100644 core/testdata/format/website-html/dataTagsInGroupNode/js.kt create mode 100644 core/testdata/format/website-html/dataTagsInGroupNode/jvm.kt create mode 100644 core/testdata/format/website-html/dataTagsInGroupNode/multiplatform.html create mode 100644 core/testdata/format/website-html/dataTagsInGroupNode/multiplatform.package.html create mode 100644 core/testdata/format/website-html/dropImport.html create mode 100644 core/testdata/format/website-html/dropImport.kt create mode 100644 core/testdata/format/website-html/newLinesInImportList.html create mode 100644 core/testdata/format/website-html/newLinesInImportList.kt create mode 100644 core/testdata/format/website-html/newLinesInSamples.html create mode 100644 core/testdata/format/website-html/newLinesInSamples.kt create mode 100644 core/testdata/format/website-html/overloadGroup.html create mode 100644 core/testdata/format/website-html/overloadGroup.kt create mode 100644 core/testdata/format/website-html/returnTag.html create mode 100644 core/testdata/format/website-html/returnTag.kt create mode 100644 core/testdata/format/website-html/sample.html create mode 100644 core/testdata/format/website-html/sample.kt create mode 100644 core/testdata/format/website-html/sampleWithAsserts.html create mode 100644 core/testdata/format/website-html/sampleWithAsserts.kt diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt new file mode 100644 index 00000000..d2962911 --- /dev/null +++ b/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt @@ -0,0 +1,193 @@ +package org.jetbrains.dokka + +import com.google.inject.Inject +import com.google.inject.name.Named +import org.jetbrains.dokka.Utilities.impliedPlatformsName +import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty +import java.nio.file.Path + + +private object EmptyHtmlTemplateServie : HtmlTemplateService { + override fun appendFooter(to: StringBuilder) { + + } + + override fun appendHeader(to: StringBuilder, title: String?, basePath: Path) { + + } +} + + +open class KotlinWebsiteHtmlOutputBuilder(to: StringBuilder, + location: Location, + locationService: LocationService, + languageService: LanguageService, + extension: String, + impliedPlatforms: List) + : HtmlOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms, EmptyHtmlTemplateServie) { + private var needHardLineBreaks = false + private var insideDiv = 0 + + override fun appendLine() { + + } + + override fun appendBreadcrumbs(path: Iterable) { + if (path.count() > 1) { + to.append("
") + super.appendBreadcrumbs(path) + to.append("
") + } + } + + override fun appendCode(body: () -> Unit) = wrapIfNotEmpty("", "", body) + + override fun appendStrikethrough(body: () -> Unit) = wrapInTag("s", body) + + protected fun div(to: StringBuilder, cssClass: String, otherAttributes: String = "", block: () -> Unit) { + to.append("
") + insideDiv++ + block() + insideDiv-- + to.append("
\n") + } + + override fun appendAsSignature(node: ContentNode, block: () -> Unit) { + val contentLength = node.textLength + if (contentLength == 0) return + div(to, "signature") { + needHardLineBreaks = contentLength >= 62 + try { + block() + } finally { + needHardLineBreaks = false + } + } + } + + override fun appendAsOverloadGroup(to: StringBuilder, platforms: Set, block: () -> Unit) { + div(to, "overload-group", calculateDataAttributes(platforms)) { + ensureParagraph() + block() + ensureParagraph() + } + } + + override fun appendLink(href: String, body: () -> Unit) = wrap("", "", body) + + override fun appendHeader(level: Int, body: () -> Unit) { + if (insideDiv > 0) { + wrapInTag("p", body, newlineAfterClose = true) + } else { + super.appendHeader(level, body) + } + } + + override fun appendTable(vararg columns: String, body: () -> Unit) { + to.appendln("") + body() + to.appendln("
") + } + + override fun appendTableBody(body: () -> Unit) { + to.appendln("") + body() + to.appendln("") + } + + override fun appendTableRow(body: () -> Unit) { + to.appendln("") + body() + to.appendln("") + } + + override fun appendTableCell(body: () -> Unit) { + to.appendln("") + body() + to.appendln("\n") + } + + override fun appendSymbol(text: String) { + to.append("${text.htmlEscape()}") + } + + override fun appendKeyword(text: String) { + to.append("${text.htmlEscape()}") + } + + override fun appendIdentifier(text: String, kind: IdentifierKind, signature: String?) { + val id = signature?.let { " id=\"$it\"" }.orEmpty() + to.append("${text.htmlEscape()}") + } + + override fun appendSoftLineBreak() { + if (needHardLineBreaks) + to.append("
") + } + + override fun appendIndentedSoftLineBreak() { + if (needHardLineBreaks) { + to.append("
    ") + } + } + + private fun identifierClassName(kind: IdentifierKind) = when (kind) { + IdentifierKind.ParameterName -> "parameterName" + IdentifierKind.SummarizedTypeName -> "summarizedTypeName" + else -> "identifier" + } + + fun calculateDataAttributes(platforms: Set): String { + fun String.isKotlinVersion() = this.startsWith("Kotlin") + fun String.isJREVersion() = this.startsWith("JRE") + val kotlinVersion = platforms.singleOrNull(String::isKotlinVersion) + val jreVersion = platforms.singleOrNull(String::isJREVersion) + val targetPlatforms = platforms.filterNot { it.isKotlinVersion() || it.isJREVersion() } + + val kotlinVersionAttr = kotlinVersion?.let { " data-kotlin-version=\"$it\"" } ?: "" + val jreVersionAttr = jreVersion?.let { " data-jre-version=\"$it\"" } ?: "" + val platformsAttr = targetPlatforms.ifNotEmpty { " data-platform=\"${targetPlatforms.joinToString()}\"" } ?: "" + return "$platformsAttr$kotlinVersionAttr$jreVersionAttr" + } + + override fun appendIndexRow(platforms: Set, block: () -> Unit) { + if (platforms.isNotEmpty()) + wrap("", "", block) + else + appendTableRow(block) + } + + override fun appendPlatforms(platforms: Set) { + + } + + override fun appendBreadcrumbSeparator() { + to.append(" / ") + } + + override fun appendSampleBlockCode(language: String, imports: () -> Unit, body: () -> Unit) { + div(to, "sample") { + appendBlockCode(language) { + imports() + wrap("\n\nfun main(args: Array) {", "}") { + wrap("\n//sampleStart\n", "\n//sampleEnd\n", body) + } + } + } + } +} + +class KotlinWebsiteHtmlFormatService @Inject constructor(locationService: LocationService, + signatureGenerator: LanguageService, + @Named(impliedPlatformsName) impliedPlatforms: List) + : HtmlFormatService(locationService, signatureGenerator, EmptyHtmlTemplateServie, impliedPlatforms) { + + override fun enumerateSupportFiles(callback: (String, String) -> Unit) { + + } + + override fun createOutputBuilder(to: StringBuilder, location: Location) = + KotlinWebsiteHtmlOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms) +} + diff --git a/core/src/main/kotlin/Formats/StandardFormats.kt b/core/src/main/kotlin/Formats/StandardFormats.kt index 6b077444..c67386af 100644 --- a/core/src/main/kotlin/Formats/StandardFormats.kt +++ b/core/src/main/kotlin/Formats/StandardFormats.kt @@ -40,6 +40,12 @@ class KotlinWebsiteFormatRunnableSamplesDescriptor : KotlinFormatDescriptorBase( override val outlineServiceClass = YamlOutlineService::class } +class KotlinWebsiteHtmlFormatDescriptor : KotlinFormatDescriptorBase() { + override val formatServiceClass = KotlinWebsiteHtmlFormatService::class + override val sampleProcessingService = KotlinWebsiteSampleProcessingService::class + override val outlineServiceClass = YamlOutlineService::class +} + class JekyllFormatDescriptor : KotlinFormatDescriptorBase() { override val formatServiceClass = JekyllFormatService::class } diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index 84f91d9c..743a6ac8 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -253,7 +253,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } for ((path, nodes) in breakdownByLocation) { - if (!noHeader) { + if (!noHeader && path.isNotEmpty()) { appendBreadcrumbs(path) appendLine() appendLine() diff --git a/core/src/main/resources/dokka/format/kotlin-website-html.properties b/core/src/main/resources/dokka/format/kotlin-website-html.properties new file mode 100644 index 00000000..f4c320b9 --- /dev/null +++ b/core/src/main/resources/dokka/format/kotlin-website-html.properties @@ -0,0 +1,2 @@ +class=org.jetbrains.dokka.Formats.KotlinWebsiteHtmlFormatDescriptor +description=Generates Kotlin website documentation \ No newline at end of file diff --git a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt new file mode 100644 index 00000000..5c2fbe75 --- /dev/null +++ b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt @@ -0,0 +1,74 @@ +package org.jetbrains.dokka.tests + +import org.jetbrains.dokka.* +import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList +import org.junit.Test + +class KotlinWebSiteHtmlFormatTest { + private val kwsService = KotlinWebsiteHtmlFormatService(InMemoryLocationService, KotlinLanguageService(), listOf()) + + + @Test fun dropImport() { + verifyKWSNodeByName("dropImport", "foo") + } + + @Test fun sample() { + verifyKWSNodeByName("sample", "foo") + } + + @Test fun sampleWithAsserts() { + verifyKWSNodeByName("sampleWithAsserts", "a") + } + + @Test fun newLinesInSamples() { + verifyKWSNodeByName("newLinesInSamples", "foo") + } + + @Test fun newLinesInImportList() { + verifyKWSNodeByName("newLinesInImportList", "foo") + } + + @Test fun returnTag() { + verifyKWSNodeByName("returnTag", "indexOf") + } + + @Test fun overloadGroup() { + verifyKWSNodeByName("overloadGroup", "magic") + } + + @Test fun dataTags() { + val module = buildMultiplePlatforms("dataTags") + verifyMultiplatformPackage(module, "dataTags") + } + + @Test fun dataTagsInGroupNode() { + val path = "dataTagsInGroupNode" + val module = buildMultiplePlatforms(path) + verifyModelOutput(module, ".html", "testdata/format/website-html/$path/multiplatform.kt") { model, output -> + kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.find { it.kind == NodeKind.GroupNode }.singletonOrEmptyList()) + } + verifyMultiplatformPackage(module, path) + } + + private fun verifyKWSNodeByName(fileName: String, name: String) { + verifyOutput("testdata/format/website-html/$fileName.kt", ".html", format = "kotlin-website-html") { model, output -> + kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.filter { it.name == name }) + } + } + + private fun buildMultiplePlatforms(path: String): DocumentationModule { + val module = DocumentationModule("test") + val options = DocumentationOptions("", "html", generateIndexPages = false) + appendDocumentation(module, contentRootFromPath("testdata/format/website-html/$path/jvm.kt"), defaultPlatforms = listOf("JVM"), options = options) + appendDocumentation(module, contentRootFromPath("testdata/format/website-html/$path/jre7.kt"), defaultPlatforms = listOf("JVM", "JRE7"), options = options) + appendDocumentation(module, contentRootFromPath("testdata/format/website-html/$path/js.kt"), defaultPlatforms = listOf("JS"), options = options) + return module + } + + private fun verifyMultiplatformPackage(module: DocumentationModule, path: String) { + verifyModelOutput(module, ".package.html", "testdata/format/website-html/$path/multiplatform.kt") { model, output -> + kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members) + } + } + +} diff --git a/core/testdata/format/website-html/dataTags/jre7.kt b/core/testdata/format/website-html/dataTags/jre7.kt new file mode 100644 index 00000000..d21b8d7b --- /dev/null +++ b/core/testdata/format/website-html/dataTags/jre7.kt @@ -0,0 +1,11 @@ +package foo + +@SinceKotlin("1.1") +fun jre7New() {} + +fun jre7() {} + +fun shared() {} + +@SinceKotlin("1.1") +fun sharedNew() {} \ No newline at end of file diff --git a/core/testdata/format/website-html/dataTags/js.kt b/core/testdata/format/website-html/dataTags/js.kt new file mode 100644 index 00000000..b22d7088 --- /dev/null +++ b/core/testdata/format/website-html/dataTags/js.kt @@ -0,0 +1,11 @@ +package foo + +@SinceKotlin("1.1") +fun jsNew() {} + +fun js() {} + +fun shared() {} + +@SinceKotlin("1.1") +fun sharedNew() {} \ No newline at end of file diff --git a/core/testdata/format/website-html/dataTags/jvm.kt b/core/testdata/format/website-html/dataTags/jvm.kt new file mode 100644 index 00000000..02d04226 --- /dev/null +++ b/core/testdata/format/website-html/dataTags/jvm.kt @@ -0,0 +1,11 @@ +package foo + +@SinceKotlin("1.1") +fun jvmNew() {} + +fun jvm() {} + +fun shared() {} + +@SinceKotlin("1.1") +fun sharedNew() {} \ No newline at end of file diff --git a/core/testdata/format/website-html/dataTags/multiplatform.package.html b/core/testdata/format/website-html/dataTags/multiplatform.package.html new file mode 100644 index 00000000..0430c6f2 --- /dev/null +++ b/core/testdata/format/website-html/dataTags/multiplatform.package.html @@ -0,0 +1,63 @@ + +

Package foo

+

Functions

+ + + + + + + + + + + + + + + + + + + +
+jre7 + +
fun jre7(): Unit
+ +
+jre7New + +
fun jre7New(): Unit
+ +
+js + +
fun js(): Unit
+ +
+jsNew + +
fun jsNew(): Unit
+ +
+jvm + +
fun jvm(): Unit
+ +
+jvmNew + +
fun jvmNew(): Unit
+ +
+shared + +
fun shared(): Unit
+ +
+sharedNew + +
fun sharedNew(): Unit
+ +
diff --git a/core/testdata/format/website-html/dataTagsInGroupNode/jre7.kt b/core/testdata/format/website-html/dataTagsInGroupNode/jre7.kt new file mode 100644 index 00000000..e69de29b diff --git a/core/testdata/format/website-html/dataTagsInGroupNode/js.kt b/core/testdata/format/website-html/dataTagsInGroupNode/js.kt new file mode 100644 index 00000000..045f3f0d --- /dev/null +++ b/core/testdata/format/website-html/dataTagsInGroupNode/js.kt @@ -0,0 +1,8 @@ +package pack + +class Some { + + fun magic() { + + } +} \ No newline at end of file diff --git a/core/testdata/format/website-html/dataTagsInGroupNode/jvm.kt b/core/testdata/format/website-html/dataTagsInGroupNode/jvm.kt new file mode 100644 index 00000000..57f36742 --- /dev/null +++ b/core/testdata/format/website-html/dataTagsInGroupNode/jvm.kt @@ -0,0 +1,9 @@ +package pack + +class SomeCoolJvmClass { + fun magic() { + + } +} + +typealias Some = SomeCoolJvmClass \ No newline at end of file diff --git a/core/testdata/format/website-html/dataTagsInGroupNode/multiplatform.html b/core/testdata/format/website-html/dataTagsInGroupNode/multiplatform.html new file mode 100644 index 00000000..bca7d36d --- /dev/null +++ b/core/testdata/format/website-html/dataTagsInGroupNode/multiplatform.html @@ -0,0 +1,38 @@ + +

Some

+

typealias Some = SomeCoolJvmClass
+

Platform and version requirements: JVM

+
+

+

class Some
+

Platform and version requirements: JS

+

Constructors

+ + + + + + + +
+<init> + +
Some()
+ +
+

Functions

+ + + + + + + +
+magic + +
fun magic(): Unit
+ +
+
+

diff --git a/core/testdata/format/website-html/dataTagsInGroupNode/multiplatform.package.html b/core/testdata/format/website-html/dataTagsInGroupNode/multiplatform.package.html new file mode 100644 index 00000000..985f9f04 --- /dev/null +++ b/core/testdata/format/website-html/dataTagsInGroupNode/multiplatform.package.html @@ -0,0 +1,33 @@ + +

Package pack

+

Types

+ + + + + + + +
+Some + +
class Some
+ +
+SomeCoolJvmClass + +
class SomeCoolJvmClass
+ +
+

Type Aliases

+ + + + + +
+Some + +
typealias Some = SomeCoolJvmClass
+ +
diff --git a/core/testdata/format/website-html/dropImport.html b/core/testdata/format/website-html/dropImport.html new file mode 100644 index 00000000..cfcb8cd5 --- /dev/null +++ b/core/testdata/format/website-html/dropImport.html @@ -0,0 +1,11 @@ + +

foo

+ +
fun foo(): Unit
+
import some.*
+
+fun main(args: Array) {
+//sampleStart
+
+//sampleEnd
+}
diff --git a/core/testdata/format/website-html/dropImport.kt b/core/testdata/format/website-html/dropImport.kt new file mode 100644 index 00000000..7b8d9f4e --- /dev/null +++ b/core/testdata/format/website-html/dropImport.kt @@ -0,0 +1,12 @@ +import samples.* +import some.* + +/** + * @sample example1 + */ +fun foo() { +} + +fun example1() { + +} \ No newline at end of file diff --git a/core/testdata/format/website-html/newLinesInImportList.html b/core/testdata/format/website-html/newLinesInImportList.html new file mode 100644 index 00000000..4862b314 --- /dev/null +++ b/core/testdata/format/website-html/newLinesInImportList.html @@ -0,0 +1,12 @@ + +

foo

+ +
fun foo(): Unit
+
import same.*
+import some.*
+
+fun main(args: Array) {
+//sampleStart
+
+//sampleEnd
+}
diff --git a/core/testdata/format/website-html/newLinesInImportList.kt b/core/testdata/format/website-html/newLinesInImportList.kt new file mode 100644 index 00000000..836d9f6f --- /dev/null +++ b/core/testdata/format/website-html/newLinesInImportList.kt @@ -0,0 +1,12 @@ +import same.* +import some.* + +/** + * @sample example1 + */ +fun foo() { +} + +fun example1() { + +} \ No newline at end of file diff --git a/core/testdata/format/website-html/newLinesInSamples.html b/core/testdata/format/website-html/newLinesInSamples.html new file mode 100644 index 00000000..0babe122 --- /dev/null +++ b/core/testdata/format/website-html/newLinesInSamples.html @@ -0,0 +1,19 @@ + +

foo

+ +
fun foo(): Unit
+

+
+fun main(args: Array) {
+//sampleStart
+val words = listOf("a", "abc", "ab", "def", "abcd")
+val byLength = words.groupBy { it.length }
+
+println(byLength.keys) // [1, 3, 2, 4]
+println(byLength.values) // [[a], [abc, def], [ab], [abcd]]
+
+val mutableByLength: MutableMap<Int, MutableList<String>> = words.groupByTo(mutableMapOf()) { it.length }
+// same content as in byLength map, but the map is mutable
+println("mutableByLength == byLength is ${mutableByLength == byLength}") // true
+//sampleEnd
+}
diff --git a/core/testdata/format/website-html/newLinesInSamples.kt b/core/testdata/format/website-html/newLinesInSamples.kt new file mode 100644 index 00000000..ee49aefc --- /dev/null +++ b/core/testdata/format/website-html/newLinesInSamples.kt @@ -0,0 +1,19 @@ +fun groupBySample() { + val words = listOf("a", "abc", "ab", "def", "abcd") + val byLength = words.groupBy { it.length } + + assertPrints(byLength.keys, "[1, 3, 2, 4]") + assertPrints(byLength.values, "[[a], [abc, def], [ab], [abcd]]") + + val mutableByLength: MutableMap> = words.groupByTo(mutableMapOf()) { it.length } + // same content as in byLength map, but the map is mutable + assertTrue(mutableByLength == byLength) +} + + +/** + * @sample groupBySample + */ +fun foo() { + +} \ No newline at end of file diff --git a/core/testdata/format/website-html/overloadGroup.html b/core/testdata/format/website-html/overloadGroup.html new file mode 100644 index 00000000..2482f8fb --- /dev/null +++ b/core/testdata/format/website-html/overloadGroup.html @@ -0,0 +1,18 @@ + +

magic

+

+
fun magic(spell: String): Int
+

Parameters

+

+spell - The text of spell, often distributed on scrolls

+

ReturnSpell ID for future casts

+
+

+

+
fun magic(spell: Int): Int
+

Parameters

+

+spell - Spell ID of previously casted spell

+

ReturnSpell ID for future casts

+
+

diff --git a/core/testdata/format/website-html/overloadGroup.kt b/core/testdata/format/website-html/overloadGroup.kt new file mode 100644 index 00000000..5bc98e3d --- /dev/null +++ b/core/testdata/format/website-html/overloadGroup.kt @@ -0,0 +1,15 @@ +/** + * @param spell The text of spell, often distributed on scrolls + * @return Spell ID for future casts + */ +fun magic(spell: String): Int { + +} + +/** + * @param spell Spell ID of previously casted spell + * @return Spell ID for future casts + */ +fun magic(spell: Int): Int { + +} \ No newline at end of file diff --git a/core/testdata/format/website-html/returnTag.html b/core/testdata/format/website-html/returnTag.html new file mode 100644 index 00000000..92253130 --- /dev/null +++ b/core/testdata/format/website-html/returnTag.html @@ -0,0 +1,9 @@ + +

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.

+

ReturnsAn index of the first occurrence of char or -1 if none is found.

diff --git a/core/testdata/format/website-html/returnTag.kt b/core/testdata/format/website-html/returnTag.kt new file mode 100644 index 00000000..669c14f9 --- /dev/null +++ b/core/testdata/format/website-html/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-html/sample.html b/core/testdata/format/website-html/sample.html new file mode 100644 index 00000000..00646a11 --- /dev/null +++ b/core/testdata/format/website-html/sample.html @@ -0,0 +1,21 @@ + +

foo

+

+
fun foo(): Int
+

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.

+

+
+fun main(args: Array) {
+//sampleStart
+if (true) {
+    println(property)
+}
+//sampleEnd
+}
+
+

+

+
fun foo(i: Int): Int
+
+

diff --git a/core/testdata/format/website-html/sample.kt b/core/testdata/format/website-html/sample.kt new file mode 100644 index 00000000..a664c2f5 --- /dev/null +++ b/core/testdata/format/website-html/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-html/sampleWithAsserts.html b/core/testdata/format/website-html/sampleWithAsserts.html new file mode 100644 index 00000000..012f91ab --- /dev/null +++ b/core/testdata/format/website-html/sampleWithAsserts.html @@ -0,0 +1,12 @@ + +

a

+ +
fun a(): String
+

+
+fun main(args: Array) {
+//sampleStart
+println(a()) // Hello, Work
+println("a() == b() is ${a() == b()}") // true
+//sampleEnd
+}
diff --git a/core/testdata/format/website-html/sampleWithAsserts.kt b/core/testdata/format/website-html/sampleWithAsserts.kt new file mode 100644 index 00000000..bb9732d5 --- /dev/null +++ b/core/testdata/format/website-html/sampleWithAsserts.kt @@ -0,0 +1,15 @@ +/** + * @sample sample + */ +fun a(): String { + return "Hello, Work" +} + +fun b(): String { + return "Hello, Rest" +} + +fun sample() { + assertPrints(a(), "Hello, Work") + assertTrue(a() == b()) +} \ No newline at end of file -- cgit