From b11052baa306585f0dc41427444be986574dc644 Mon Sep 17 00:00:00 2001 From: KrystianUjma Date: Thu, 18 Apr 2019 14:46:01 +0200 Subject: remove kotlin-website --- .../kotlin/Formats/KotlinWebsiteFormatService.kt | 224 --------------------- core/src/main/kotlin/Formats/StandardFormats.kt | 11 - .../dokka/format/kotlin-website-samples.properties | 2 - .../dokka/format/kotlin-website.properties | 2 - .../test/kotlin/format/KotlinWebSiteFormatTest.kt | 93 --------- .../KotlinWebSiteRunnableSamplesFormatTest.kt | 39 ---- 6 files changed, 371 deletions(-) delete mode 100644 core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt delete mode 100644 core/src/main/resources/dokka/format/kotlin-website-samples.properties delete mode 100644 core/src/main/resources/dokka/format/kotlin-website.properties delete mode 100644 core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt delete mode 100644 core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt (limited to 'core') diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt deleted file mode 100644 index 51ceb47e..00000000 --- a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt +++ /dev/null @@ -1,224 +0,0 @@ -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 - - -open class KotlinWebsiteOutputBuilder( - to: StringBuilder, - location: Location, - generator: NodeLocationAwareGenerator, - languageService: LanguageService, - extension: String, - impliedPlatforms: List -) : JekyllOutputBuilder(to, location, generator, languageService, extension, impliedPlatforms) { - private var needHardLineBreaks = false - private var insideDiv = 0 - - override fun appendFrontMatter(nodes: Iterable, to: StringBuilder) { - super.appendFrontMatter(nodes, to) - to.appendln("layout: api") - } - - 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 = "", markdown: Boolean = false, block: () -> Unit) { - to.append("
") - if (!markdown) insideDiv++ - block() - if (!markdown) 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: PlatformsData, block: () -> Unit) { - div(to, "overload-group", calculateDataAttributes(platforms.keys), true) { - 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 appendLine() { - if (insideDiv > 0) { - to.appendln("
") - } else { - super.appendLine() - } - } - - 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 appendBlockCode(language: String, body: () -> Unit) { - if (language.isNotEmpty()) { - super.appendBlockCode(language, body) - } else { - wrap("
", "
", body) - } - } - - 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: PlatformsData, block: () -> Unit) { - if (platforms.isNotEmpty()) - wrap("", "", block) - else - appendTableRow(block) - } - - override fun appendPlatforms(platforms: PlatformsData) { - - } -} - -class KotlinWebsiteFormatService @Inject constructor( - generator: NodeLocationAwareGenerator, - signatureGenerator: LanguageService, - @Named(impliedPlatformsName) impliedPlatforms: List, - logger: DokkaLogger -) : JekyllFormatService(generator, signatureGenerator, "html", impliedPlatforms) { - init { - logger.warn("Format kotlin-website deprecated and will be removed in next release") - } - - override fun createOutputBuilder(to: StringBuilder, location: Location) = - KotlinWebsiteOutputBuilder(to, location, generator, languageService, extension, impliedPlatforms) -} - - -class KotlinWebsiteRunnableSamplesOutputBuilder( - to: StringBuilder, - location: Location, - generator: NodeLocationAwareGenerator, - languageService: LanguageService, - extension: String, - impliedPlatforms: List -) : KotlinWebsiteOutputBuilder(to, location, generator, languageService, extension, impliedPlatforms) { - - override fun appendSampleBlockCode(language: String, imports: () -> Unit, body: () -> Unit) { - div(to, "sample", markdown = true) { - appendBlockCode(language) { - imports() - wrap("\n\nfun main(args: Array) {", "}") { - wrap("\n//sampleStart\n", "\n//sampleEnd\n", body) - } - } - } - } -} - -class KotlinWebsiteRunnableSamplesFormatService @Inject constructor( - generator: NodeLocationAwareGenerator, - signatureGenerator: LanguageService, - @Named(impliedPlatformsName) impliedPlatforms: List, - logger: DokkaLogger -) : JekyllFormatService(generator, signatureGenerator, "html", impliedPlatforms) { - - init { - logger.warn("Format kotlin-website-samples deprecated and will be removed in next release") - } - - override fun createOutputBuilder(to: StringBuilder, location: Location) = - KotlinWebsiteRunnableSamplesOutputBuilder(to, location, generator, languageService, extension, impliedPlatforms) -} - diff --git a/core/src/main/kotlin/Formats/StandardFormats.kt b/core/src/main/kotlin/Formats/StandardFormats.kt index dd67ac97..86f70a37 100644 --- a/core/src/main/kotlin/Formats/StandardFormats.kt +++ b/core/src/main/kotlin/Formats/StandardFormats.kt @@ -31,17 +31,6 @@ class HtmlFormatDescriptor : HtmlFormatDescriptorBase(), DefaultAnalysisComponen class HtmlAsJavaFormatDescriptor : HtmlFormatDescriptorBase(), DefaultAnalysisComponentServices by KotlinAsJava -class KotlinWebsiteFormatDescriptor : KotlinFormatDescriptorBase() { - override val formatServiceClass = KotlinWebsiteFormatService::class - override val outlineServiceClass = YamlOutlineService::class -} - -class KotlinWebsiteFormatRunnableSamplesDescriptor : KotlinFormatDescriptorBase() { - override val formatServiceClass = KotlinWebsiteRunnableSamplesFormatService::class - override val sampleProcessingService = KotlinWebsiteSampleProcessingService::class - override val outlineServiceClass = YamlOutlineService::class -} - class KotlinWebsiteHtmlFormatDescriptor : KotlinFormatDescriptorBase() { override val formatServiceClass = KotlinWebsiteHtmlFormatService::class override val sampleProcessingService = KotlinWebsiteSampleProcessingService::class diff --git a/core/src/main/resources/dokka/format/kotlin-website-samples.properties b/core/src/main/resources/dokka/format/kotlin-website-samples.properties deleted file mode 100644 index bda616a4..00000000 --- a/core/src/main/resources/dokka/format/kotlin-website-samples.properties +++ /dev/null @@ -1,2 +0,0 @@ -class=org.jetbrains.dokka.Formats.KotlinWebsiteFormatRunnableSamplesDescriptor -description=Generates Kotlin website documentation \ No newline at end of file diff --git a/core/src/main/resources/dokka/format/kotlin-website.properties b/core/src/main/resources/dokka/format/kotlin-website.properties deleted file mode 100644 index c13e7675..00000000 --- a/core/src/main/resources/dokka/format/kotlin-website.properties +++ /dev/null @@ -1,2 +0,0 @@ -class=org.jetbrains.dokka.Formats.KotlinWebsiteFormatDescriptor -description=Generates Kotlin website documentation \ No newline at end of file diff --git a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt deleted file mode 100644 index 4f292e37..00000000 --- a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt +++ /dev/null @@ -1,93 +0,0 @@ -package org.jetbrains.dokka.tests - -import org.jetbrains.dokka.* -import org.junit.Ignore -import org.junit.Test - -@Ignore -class KotlinWebSiteFormatTest: FileGeneratorTestCase() { - override val formatService = KotlinWebsiteFormatService(fileGenerator, KotlinLanguageService(), listOf(), DokkaConsoleLogger) - - @Test fun sample() { - verifyKWSNodeByName("sample", "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, ".md", "testdata/format/website/$path/multiplatform.kt") { model, output -> - buildPagesAndReadInto( - listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }), - output - ) - } - verifyMultiplatformPackage(module, path) - } - - private fun verifyKWSNodeByName(fileName: String, name: String) { - verifyOutput("testdata/format/website/$fileName.kt", ".md", ModelConfig(format = "kotlin-website")) { model, output -> - buildPagesAndReadInto( - model.members.single().members.filter { it.name == name }, - output - ) - } - } - - private fun buildMultiplePlatforms(path: String): DocumentationModule { - val module = DocumentationModule("test") - val passConfiguration = PassConfigurationImpl(noStdlibLink = true, - noJdkLink = true, - languageVersion = null, - apiVersion = null - ) - val configuration = DokkaConfigurationImpl( - outputDir = "", - format = "html", - generateIndexPages = false, - passesConfigurations = listOf(passConfiguration) - ) - - appendDocumentation( - module, configuration, passConfiguration, ModelConfig( - roots = arrayOf(contentRootFromPath("testdata/format/website/$path/jvm.kt")), - defaultPlatforms = listOf("JVM") - ) - - ) - - - appendDocumentation( - module, configuration, passConfiguration, ModelConfig( - roots = arrayOf(contentRootFromPath("testdata/format/website/$path/jre7.kt")), - defaultPlatforms = listOf("JVM", "JRE7") - ) - ) - appendDocumentation( - module, configuration, passConfiguration, ModelConfig( - roots = arrayOf(contentRootFromPath("testdata/format/website/$path/js.kt")), - defaultPlatforms = listOf("JS") - ) - ) - return module - } - - private fun verifyMultiplatformPackage(module: DocumentationModule, path: String) { - verifyModelOutput(module, ".package.md", "testdata/format/website/$path/multiplatform.kt") { model, output -> - buildPagesAndReadInto(model.members, output) - } - } - -} diff --git a/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt deleted file mode 100644 index 453b1de8..00000000 --- a/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -package org.jetbrains.dokka.tests - -import org.jetbrains.dokka.DokkaConsoleLogger -import org.jetbrains.dokka.KotlinLanguageService -import org.jetbrains.dokka.KotlinWebsiteRunnableSamplesFormatService -import org.junit.Ignore -import org.junit.Test - -@Ignore -class KotlinWebSiteRunnableSamplesFormatTest { -// private val kwsService = KotlinWebsiteRunnableSamplesFormatService(InMemoryLocationService, KotlinLanguageService(), listOf(), DokkaConsoleLogger) -// -// -// @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") -// } -// -// 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 }) -// } -// } -} -- cgit