aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin/format
diff options
context:
space:
mode:
authorEugene Petrenko <eugene.petrenko@gmail.com>2018-09-11 14:03:29 +0300
committerEugene Petrenko <eugene.petrenko@gmail.com>2018-09-11 14:03:29 +0300
commita54070f5db04d05b48c369b211efe044fbc02a8d (patch)
treeaac5889906f49f68c39e1416ea39d4d19bad008e /core/src/test/kotlin/format
parente29f1c966056b0f7ee31dd9bd7d55f9e526fa7fe (diff)
parent0df19264ccae3d294946caf634ee15eea0c4fe4a (diff)
downloaddokka-a54070f5db04d05b48c369b211efe044fbc02a8d.tar.gz
dokka-a54070f5db04d05b48c369b211efe044fbc02a8d.tar.bz2
dokka-a54070f5db04d05b48c369b211efe044fbc02a8d.zip
Merge remote-tracking branch 'zub/dev-multiplatf' into kotlin-website-jonnyzzz
Diffstat (limited to 'core/src/test/kotlin/format')
-rw-r--r--core/src/test/kotlin/format/FileGeneratorTestCase.kt35
-rw-r--r--core/src/test/kotlin/format/GFMFormatTest.kt31
-rw-r--r--core/src/test/kotlin/format/HtmlFormatTest.kt168
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt56
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt80
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt56
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt453
-rw-r--r--core/src/test/kotlin/format/PackageDocsTest.kt45
8 files changed, 592 insertions, 332 deletions
diff --git a/core/src/test/kotlin/format/FileGeneratorTestCase.kt b/core/src/test/kotlin/format/FileGeneratorTestCase.kt
new file mode 100644
index 00000000..ef9e815d
--- /dev/null
+++ b/core/src/test/kotlin/format/FileGeneratorTestCase.kt
@@ -0,0 +1,35 @@
+package org.jetbrains.dokka.tests
+
+import org.jetbrains.dokka.*
+import org.junit.Before
+import org.junit.Rule
+import org.junit.rules.TemporaryFolder
+
+
+abstract class FileGeneratorTestCase {
+ abstract val formatService: FormatService
+
+ @get:Rule
+ var folder = TemporaryFolder()
+
+ val fileGenerator = FileGenerator(folder.apply { create() }.root)
+
+ @Before
+ fun bindGenerator() {
+ fileGenerator.formatService = formatService
+ }
+
+ fun buildPagesAndReadInto(nodes: List<DocumentationNode>, sb: StringBuilder) = with(fileGenerator) {
+ buildPages(nodes)
+ val byLocations = nodes.groupBy { location(it) }
+ byLocations.forEach { (loc, _) ->
+ if (byLocations.size > 1) {
+ if (sb.isNotBlank() && !sb.endsWith('\n')) {
+ sb.appendln()
+ }
+ sb.appendln("<!-- File: ${loc.file.relativeTo(root).toUnixString()} -->")
+ }
+ sb.append(loc.file.readText())
+ }
+ }
+} \ No newline at end of file
diff --git a/core/src/test/kotlin/format/GFMFormatTest.kt b/core/src/test/kotlin/format/GFMFormatTest.kt
index c097c5c8..60de7d29 100644
--- a/core/src/test/kotlin/format/GFMFormatTest.kt
+++ b/core/src/test/kotlin/format/GFMFormatTest.kt
@@ -2,22 +2,35 @@ package org.jetbrains.dokka.tests
import org.jetbrains.dokka.GFMFormatService
import org.jetbrains.dokka.KotlinLanguageService
+import org.jetbrains.dokka.Platform
import org.junit.Test
-class GFMFormatTest {
- private val gfmService = GFMFormatService(InMemoryLocationService, KotlinLanguageService(), listOf())
+abstract class BaseGFMFormatTest(val analysisPlatform: Platform) : FileGeneratorTestCase() {
+ override val formatService = GFMFormatService(fileGenerator, KotlinLanguageService(), listOf())
+ private val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
- @Test fun sample() {
- verifyGFMNodeByName("sample", "Foo")
+
+ @Test
+ fun sample() {
+ verifyGFMNodeByName("sample", "Foo", defaultModelConfig)
}
- @Test fun listInTableCell() {
- verifyGFMNodeByName("listInTableCell", "Foo")
+ @Test
+ fun listInTableCell() {
+ verifyGFMNodeByName("listInTableCell", "Foo", defaultModelConfig)
}
- private fun verifyGFMNodeByName(fileName: String, name: String) {
- verifyOutput("testdata/format/gfm/$fileName.kt", ".md") { model, output ->
- gfmService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.filter { it.name == name })
+ private fun verifyGFMNodeByName(fileName: String, name: String, modelConfig: ModelConfig) {
+ verifyOutput("testdata/format/gfm/$fileName.kt", ".md", modelConfig) { model, output ->
+ buildPagesAndReadInto(
+ model.members.single().members.filter { it.name == name },
+ output
+ )
}
}
}
+
+
+class JsGFMFormatTest : BaseGFMFormatTest(Platform.js)
+class JvmGFMFormatTest : BaseGFMFormatTest(Platform.jvm)
+class CommonGFMFormatTest : BaseGFMFormatTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/format/HtmlFormatTest.kt b/core/src/test/kotlin/format/HtmlFormatTest.kt
index 01e4559e..20891963 100644
--- a/core/src/test/kotlin/format/HtmlFormatTest.kt
+++ b/core/src/test/kotlin/format/HtmlFormatTest.kt
@@ -3,175 +3,191 @@ package org.jetbrains.dokka.tests
import org.jetbrains.dokka.*
import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
import org.jetbrains.kotlin.config.KotlinSourceRoot
+import org.junit.Before
import org.junit.Test
import java.io.File
-class HtmlFormatTest {
- private val htmlService = HtmlFormatService(InMemoryLocationService, KotlinLanguageService(), HtmlTemplateService.default(), listOf())
+abstract class BaseHtmlFormatTest(val analysisPlatform: Platform): FileGeneratorTestCase() {
+ protected val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
+ override val formatService = HtmlFormatService(fileGenerator, KotlinLanguageService(), HtmlTemplateService.default(), listOf())
@Test fun classWithCompanionObject() {
- verifyHtmlNode("classWithCompanionObject")
+ verifyHtmlNode("classWithCompanionObject", defaultModelConfig)
}
@Test fun htmlEscaping() {
- verifyHtmlNode("htmlEscaping")
+ verifyHtmlNode("htmlEscaping", defaultModelConfig)
}
@Test fun overloads() {
- verifyHtmlNodes("overloads") { model -> model.members }
+ verifyHtmlNodes("overloads", defaultModelConfig) { model -> model.members }
}
@Test fun overloadsWithDescription() {
- verifyHtmlNode("overloadsWithDescription")
+ verifyHtmlNode("overloadsWithDescription", defaultModelConfig)
}
@Test fun overloadsWithDifferentDescriptions() {
- verifyHtmlNode("overloadsWithDifferentDescriptions")
+ verifyHtmlNode("overloadsWithDifferentDescriptions", defaultModelConfig)
}
@Test fun deprecated() {
- verifyOutput("testdata/format/deprecated.kt", ".package.html") { model, output ->
- htmlService.createOutputBuilder(output, tempLocation).appendNodes(model.members)
+ verifyOutput("testdata/format/deprecated.kt", ".package.html", defaultModelConfig) { model, output ->
+ buildPagesAndReadInto(model.members, output)
}
- verifyOutput("testdata/format/deprecated.kt", ".class.html") { model, output ->
- htmlService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members)
+ verifyOutput("testdata/format/deprecated.kt", ".class.html", defaultModelConfig) { model, output ->
+ buildPagesAndReadInto(model.members.single().members, output)
}
}
@Test fun brokenLink() {
- verifyHtmlNode("brokenLink")
+ verifyHtmlNode("brokenLink", defaultModelConfig)
}
@Test fun codeSpan() {
- verifyHtmlNode("codeSpan")
+ verifyHtmlNode("codeSpan", defaultModelConfig)
}
@Test fun parenthesis() {
- verifyHtmlNode("parenthesis")
+ verifyHtmlNode("parenthesis", defaultModelConfig)
}
@Test fun bracket() {
- verifyHtmlNode("bracket")
+ verifyHtmlNode("bracket", defaultModelConfig)
}
@Test fun see() {
- verifyHtmlNode("see")
+ verifyHtmlNode("see", defaultModelConfig)
}
@Test fun tripleBackticks() {
- verifyHtmlNode("tripleBackticks")
+ verifyHtmlNode("tripleBackticks", defaultModelConfig)
}
@Test fun typeLink() {
- verifyHtmlNodes("typeLink") { model -> model.members.single().members.filter { it.name == "Bar" } }
+ verifyHtmlNodes("typeLink", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Bar" } }
}
@Test fun parameterAnchor() {
- verifyHtmlNode("parameterAnchor")
- }
-
- @Test fun javaSupertypeLink() {
- verifyJavaHtmlNodes("JavaSupertype") { model ->
- model.members.single().members.single { it.name == "JavaSupertype" }.members.filter { it.name == "Bar" }
- }
+ verifyHtmlNode("parameterAnchor", defaultModelConfig)
}
@Test fun codeBlock() {
- verifyHtmlNode("codeBlock")
- }
-
- @Test fun javaLinkTag() {
- verifyJavaHtmlNode("javaLinkTag")
- }
-
- @Test fun javaLinkTagWithLabel() {
- verifyJavaHtmlNode("javaLinkTagWithLabel")
- }
-
- @Test fun javaSeeTag() {
- verifyJavaHtmlNode("javaSeeTag")
- }
-
- @Test fun javaDeprecated() {
- verifyJavaHtmlNodes("javaDeprecated") { model ->
- model.members.single().members.single { it.name == "Foo" }.members.filter { it.name == "foo" }
- }
+ verifyHtmlNode("codeBlock", defaultModelConfig)
}
-
- @Test fun crossLanguageKotlinExtendsJava() {
- verifyOutput(arrayOf(KotlinSourceRoot("testdata/format/crossLanguage/kotlinExtendsJava/Bar.kt"),
- JavaSourceRoot(File("testdata/format/crossLanguage/kotlinExtendsJava"), null)),
- ".html") { model, output ->
- htmlService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.filter { it.name == "Bar" })
- }
- }
-
@Test fun orderedList() {
- verifyHtmlNodes("orderedList") { model -> model.members.single().members.filter { it.name == "Bar" } }
+ verifyHtmlNodes("orderedList", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Bar" } }
}
@Test fun linkWithLabel() {
- verifyHtmlNodes("linkWithLabel") { model -> model.members.single().members.filter { it.name == "Bar" } }
+ verifyHtmlNodes("linkWithLabel", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Bar" } }
}
@Test fun entity() {
- verifyHtmlNodes("entity") { model -> model.members.single().members.filter { it.name == "Bar" } }
+ verifyHtmlNodes("entity", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Bar" } }
}
@Test fun uninterpretedEmphasisCharacters() {
- verifyHtmlNode("uninterpretedEmphasisCharacters")
+ verifyHtmlNode("uninterpretedEmphasisCharacters", defaultModelConfig)
}
@Test fun markdownInLinks() {
- verifyHtmlNode("markdownInLinks")
+ verifyHtmlNode("markdownInLinks", defaultModelConfig)
}
@Test fun returnWithLink() {
- verifyHtmlNode("returnWithLink")
+ verifyHtmlNode("returnWithLink", defaultModelConfig)
}
@Test fun linkWithStarProjection() {
- verifyHtmlNode("linkWithStarProjection", withKotlinRuntime = true)
+ verifyHtmlNode("linkWithStarProjection", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
}
@Test fun functionalTypeWithNamedParameters() {
- verifyHtmlNode("functionalTypeWithNamedParameters")
+ verifyHtmlNode("functionalTypeWithNamedParameters", defaultModelConfig)
}
@Test fun sinceKotlin() {
- verifyHtmlNode("sinceKotlin")
+ verifyHtmlNode("sinceKotlin", defaultModelConfig)
}
@Test fun blankLineInsideCodeBlock() {
- verifyHtmlNode("blankLineInsideCodeBlock")
+ verifyHtmlNode("blankLineInsideCodeBlock", defaultModelConfig)
}
@Test fun indentedCodeBlock() {
- verifyHtmlNode("indentedCodeBlock")
+ verifyHtmlNode("indentedCodeBlock", defaultModelConfig)
}
- private fun verifyHtmlNode(fileName: String, withKotlinRuntime: Boolean = false) {
- verifyHtmlNodes(fileName, withKotlinRuntime) { model -> model.members.single().members }
+ private fun verifyHtmlNode(fileName: String, modelConfig: ModelConfig = ModelConfig()) {
+ verifyHtmlNodes(fileName, modelConfig) { model -> model.members.single().members }
}
private fun verifyHtmlNodes(fileName: String,
- withKotlinRuntime: Boolean = false,
+ modelConfig: ModelConfig = ModelConfig(),
nodeFilter: (DocumentationModule) -> List<DocumentationNode>) {
- verifyOutput("testdata/format/$fileName.kt", ".html", withKotlinRuntime = withKotlinRuntime) { model, output ->
- htmlService.createOutputBuilder(output, tempLocation).appendNodes(nodeFilter(model))
+ verifyOutput("testdata/format/$fileName.kt", ".html", modelConfig) { model, output ->
+ buildPagesAndReadInto(nodeFilter(model), output)
+ }
+ }
+
+ protected fun verifyJavaHtmlNode(fileName: String, modelConfig: ModelConfig = ModelConfig()) {
+ verifyJavaHtmlNodes(fileName, modelConfig) { model -> model.members.single().members }
+ }
+
+ protected fun verifyJavaHtmlNodes(fileName: String,
+ modelConfig: ModelConfig = ModelConfig(),
+ nodeFilter: (DocumentationModule) -> List<DocumentationNode>) {
+ verifyJavaOutput("testdata/format/$fileName.java", ".html", modelConfig) { model, output ->
+ buildPagesAndReadInto(nodeFilter(model), output)
+ }
+ }
+}
+
+class JSHtmlFormatTest: BaseHtmlFormatTest(Platform.js)
+
+class JVMHtmlFormatTest: BaseHtmlFormatTest(Platform.jvm) {
+ @Test
+ fun javaSeeTag() {
+ verifyJavaHtmlNode("javaSeeTag", defaultModelConfig)
+ }
+
+ @Test fun javaDeprecated() {
+ verifyJavaHtmlNodes("javaDeprecated", defaultModelConfig) { model ->
+ model.members.single().members.single { it.name == "Foo" }.members.filter { it.name == "foo" }
+ }
+ }
+
+ @Test fun crossLanguageKotlinExtendsJava() {
+ verifyOutput(
+ ModelConfig(
+ roots = arrayOf(
+ KotlinSourceRoot("testdata/format/crossLanguage/kotlinExtendsJava/Bar.kt"),
+ JavaSourceRoot(File("testdata/format/crossLanguage/kotlinExtendsJava"), null)
+ ),
+ analysisPlatform = analysisPlatform
+ ), ".html") { model, output ->
+ buildPagesAndReadInto(
+ model.members.single().members.filter { it.name == "Bar" },
+ output
+ )
}
}
- private fun verifyJavaHtmlNode(fileName: String, withKotlinRuntime: Boolean = false) {
- verifyJavaHtmlNodes(fileName, withKotlinRuntime) { model -> model.members.single().members }
+ @Test fun javaLinkTag() {
+ verifyJavaHtmlNode("javaLinkTag", defaultModelConfig)
+ }
+
+ @Test fun javaLinkTagWithLabel() {
+ verifyJavaHtmlNode("javaLinkTagWithLabel", defaultModelConfig)
}
- private fun verifyJavaHtmlNodes(fileName: String,
- withKotlinRuntime: Boolean = false,
- nodeFilter: (DocumentationModule) -> List<DocumentationNode>) {
- verifyJavaOutput("testdata/format/$fileName.java", ".html", withKotlinRuntime = withKotlinRuntime) { model, output ->
- htmlService.createOutputBuilder(output, tempLocation).appendNodes(nodeFilter(model))
+ @Test fun javaSupertypeLink() {
+ verifyJavaHtmlNodes("JavaSupertype", defaultModelConfig) { model ->
+ model.members.single().members.single { it.name == "JavaSupertype" }.members.filter { it.name == "Bar" }
}
}
+
}
+class CommonHtmlFormatTest: BaseHtmlFormatTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
index af44b048..4f292e37 100644
--- a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
+++ b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
@@ -5,8 +5,8 @@ import org.junit.Ignore
import org.junit.Test
@Ignore
-class KotlinWebSiteFormatTest {
- private val kwsService = KotlinWebsiteFormatService(InMemoryLocationService, KotlinLanguageService(), listOf(), DokkaConsoleLogger)
+class KotlinWebSiteFormatTest: FileGeneratorTestCase() {
+ override val formatService = KotlinWebsiteFormatService(fileGenerator, KotlinLanguageService(), listOf(), DokkaConsoleLogger)
@Test fun sample() {
verifyKWSNodeByName("sample", "foo")
@@ -29,36 +29,64 @@ class KotlinWebSiteFormatTest {
val path = "dataTagsInGroupNode"
val module = buildMultiplePlatforms(path)
verifyModelOutput(module, ".md", "testdata/format/website/$path/multiplatform.kt") { model, output ->
- kwsService.createOutputBuilder(output, tempLocation).appendNodes(listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }))
+ 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", format = "kotlin-website") { model, output ->
- kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.filter { it.name == name })
+ 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 options = DocumentationOptions(
- outputDir = "",
- outputFormat = "html",
- generateIndexPages = false,
- noStdlibLink = true,
+ val passConfiguration = PassConfigurationImpl(noStdlibLink = true,
+ noJdkLink = true,
languageVersion = null,
apiVersion = null
)
- appendDocumentation(module, contentRootFromPath("testdata/format/website/$path/jvm.kt"), defaultPlatforms = listOf("JVM"), options = options)
- appendDocumentation(module, contentRootFromPath("testdata/format/website/$path/jre7.kt"), defaultPlatforms = listOf("JVM", "JRE7"), options = options)
- appendDocumentation(module, contentRootFromPath("testdata/format/website/$path/js.kt"), defaultPlatforms = listOf("JS"), options = options)
+ 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 ->
- kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members)
+ buildPagesAndReadInto(model.members, output)
}
}
diff --git a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
index 433c9c13..1901154f 100644
--- a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
+++ b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
@@ -3,36 +3,36 @@ package org.jetbrains.dokka.tests
import org.jetbrains.dokka.*
import org.junit.Test
-class KotlinWebSiteHtmlFormatTest {
- private val kwsService = KotlinWebsiteHtmlFormatService(InMemoryLocationService, KotlinLanguageService(), listOf())
-
+abstract class BaseKotlinWebSiteHtmlFormatTest(val analysisPlatform: Platform): FileGeneratorTestCase() {
+ val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
+ override val formatService = KotlinWebsiteHtmlFormatService(fileGenerator, KotlinLanguageService(), listOf(), EmptyHtmlTemplateService)
@Test fun dropImport() {
- verifyKWSNodeByName("dropImport", "foo")
+ verifyKWSNodeByName("dropImport", "foo", defaultModelConfig)
}
@Test fun sample() {
- verifyKWSNodeByName("sample", "foo")
+ verifyKWSNodeByName("sample", "foo", defaultModelConfig)
}
@Test fun sampleWithAsserts() {
- verifyKWSNodeByName("sampleWithAsserts", "a")
+ verifyKWSNodeByName("sampleWithAsserts", "a", defaultModelConfig)
}
@Test fun newLinesInSamples() {
- verifyKWSNodeByName("newLinesInSamples", "foo")
+ verifyKWSNodeByName("newLinesInSamples", "foo", defaultModelConfig)
}
@Test fun newLinesInImportList() {
- verifyKWSNodeByName("newLinesInImportList", "foo")
+ verifyKWSNodeByName("newLinesInImportList", "foo", defaultModelConfig)
}
@Test fun returnTag() {
- verifyKWSNodeByName("returnTag", "indexOf")
+ verifyKWSNodeByName("returnTag", "indexOf", defaultModelConfig)
}
@Test fun overloadGroup() {
- verifyKWSNodeByName("overloadGroup", "magic")
+ verifyKWSNodeByName("overloadGroup", "magic", defaultModelConfig)
}
@Test fun dataTags() {
@@ -44,37 +44,73 @@ class KotlinWebSiteHtmlFormatTest {
val path = "dataTagsInGroupNode"
val module = buildMultiplePlatforms(path)
verifyModelOutput(module, ".html", "testdata/format/website-html/$path/multiplatform.kt") { model, output ->
- kwsService.createOutputBuilder(output, tempLocation).appendNodes(listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }))
+ 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-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 verifyKWSNodeByName(fileName: String, name: String, modelConfig: ModelConfig) {
+ verifyOutput(
+ "testdata/format/website-html/$fileName.kt",
+ ".html",
+ ModelConfig(analysisPlatform = modelConfig.analysisPlatform, format = "kotlin-website-html")
+ ) { model, output ->
+ buildPagesAndReadInto(model.members.single().members.filter { it.name == name }, output)
}
}
private fun buildMultiplePlatforms(path: String): DocumentationModule {
val module = DocumentationModule("test")
- val options = DocumentationOptions(
- outputDir = "",
- outputFormat = "kotlin-website-html",
- generateIndexPages = false,
+ val passConfiguration = PassConfigurationImpl(
noStdlibLink = true,
+ noJdkLink = true,
languageVersion = null,
apiVersion = null
)
- 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)
+
+ val dokkaConfiguration = DokkaConfigurationImpl(
+ outputDir = "",
+ format = "kotlin-website-html",
+ generateIndexPages = false,
+ passesConfigurations = listOf(
+ passConfiguration
+ )
+
+ )
+
+ appendDocumentation(
+ module, dokkaConfiguration, passConfiguration, ModelConfig(
+ roots = arrayOf(contentRootFromPath("testdata/format/website-html/$path/jvm.kt")),
+ defaultPlatforms = listOf("JVM")
+ )
+ )
+ appendDocumentation(
+ module, dokkaConfiguration, passConfiguration, ModelConfig(
+ roots = arrayOf(contentRootFromPath("testdata/format/website-html/$path/jre7.kt")),
+ defaultPlatforms = listOf("JVM", "JRE7")
+ )
+ )
+ appendDocumentation(
+ module, dokkaConfiguration, passConfiguration, ModelConfig(
+ roots = arrayOf(contentRootFromPath("testdata/format/website-html/$path/js.kt")),
+ defaultPlatforms = listOf("JS")
+ )
+ )
+
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)
+ buildPagesAndReadInto(model.members, output)
}
}
}
+
+class JsKotlinWebSiteHtmlFormatTest: BaseKotlinWebSiteHtmlFormatTest(Platform.js)
+class JvmKotlinWebSiteHtmlFormatTest: BaseKotlinWebSiteHtmlFormatTest(Platform.jvm)
+class CommonKotlinWebSiteHtmlFormatTest: BaseKotlinWebSiteHtmlFormatTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt
index 44155004..453b1de8 100644
--- a/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt
+++ b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt
@@ -8,32 +8,32 @@ 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 })
- }
- }
+// 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 })
+// }
+// }
}
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index 820af361..29d2d20f 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -3,272 +3,215 @@ package org.jetbrains.dokka.tests
import org.jetbrains.dokka.*
import org.junit.Test
-class MarkdownFormatTest {
- private val markdownService = MarkdownFormatService(InMemoryLocationService, KotlinLanguageService(), listOf())
+abstract class BaseMarkdownFormatTest(val analysisPlatform: Platform): FileGeneratorTestCase() {
+ override val formatService = MarkdownFormatService(fileGenerator, KotlinLanguageService(), listOf())
+
+ protected val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
@Test fun emptyDescription() {
- verifyMarkdownNode("emptyDescription")
+ verifyMarkdownNode("emptyDescription", defaultModelConfig)
}
@Test fun classWithCompanionObject() {
- verifyMarkdownNode("classWithCompanionObject")
+ verifyMarkdownNode("classWithCompanionObject", defaultModelConfig)
}
@Test fun annotations() {
- verifyMarkdownNode("annotations")
+ verifyMarkdownNode("annotations", defaultModelConfig)
}
@Test fun annotationClass() {
- verifyMarkdownNode("annotationClass", withKotlinRuntime = true)
- verifyMarkdownPackage("annotationClass", withKotlinRuntime = true)
- }
-
- @Test fun exceptionClass() {
- verifyMarkdownNode("exceptionClass", withKotlinRuntime = true)
- verifyMarkdownPackage("exceptionClass", withKotlinRuntime = true)
- }
-
- @Test fun annotationParams() {
- verifyMarkdownNode("annotationParams", withKotlinRuntime = true)
- }
-
- @Test fun extensions() {
- verifyOutput("testdata/format/extensions.kt", ".package.md") { model, output ->
- markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members)
- }
- verifyOutput("testdata/format/extensions.kt", ".class.md") { model, output ->
- markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members)
- }
+ verifyMarkdownNode("annotationClass", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
+ verifyMarkdownPackage("annotationClass", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
}
@Test fun enumClass() {
- verifyOutput("testdata/format/enumClass.kt", ".md") { model, output ->
- markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members)
+ verifyOutput("testdata/format/enumClass.kt", ".md", defaultModelConfig) { model, output ->
+ buildPagesAndReadInto(model.members.single().members, output)
}
- verifyOutput("testdata/format/enumClass.kt", ".value.md") { model, output ->
+ verifyOutput("testdata/format/enumClass.kt", ".value.md", defaultModelConfig) { model, output ->
val enumClassNode = model.members.single().members[0]
- markdownService.createOutputBuilder(output, tempLocation).appendNodes(
- enumClassNode.members.filter { it.name == "LOCAL_CONTINUE_AND_BREAK" })
+ buildPagesAndReadInto(
+ enumClassNode.members.filter { it.name == "LOCAL_CONTINUE_AND_BREAK" },
+ output
+ )
}
}
@Test fun varargsFunction() {
- verifyMarkdownNode("varargsFunction")
+ verifyMarkdownNode("varargsFunction", defaultModelConfig)
}
@Test fun overridingFunction() {
- verifyMarkdownNodes("overridingFunction") { model->
+ verifyMarkdownNodes("overridingFunction", defaultModelConfig) { model->
val classMembers = model.members.single().members.first { it.name == "D" }.members
classMembers.filter { it.name == "f" }
}
}
@Test fun propertyVar() {
- verifyMarkdownNode("propertyVar")
+ verifyMarkdownNode("propertyVar", defaultModelConfig)
}
@Test fun functionWithDefaultParameter() {
- verifyMarkdownNode("functionWithDefaultParameter")
+ verifyMarkdownNode("functionWithDefaultParameter", defaultModelConfig)
}
@Test fun accessor() {
- verifyMarkdownNodes("accessor") { model ->
+ verifyMarkdownNodes("accessor", defaultModelConfig) { model ->
model.members.single().members.first { it.name == "C" }.members.filter { it.name == "x" }
}
}
@Test fun paramTag() {
- verifyMarkdownNode("paramTag")
+ verifyMarkdownNode("paramTag", defaultModelConfig)
}
@Test fun throwsTag() {
- verifyMarkdownNode("throwsTag")
+ verifyMarkdownNode("throwsTag", defaultModelConfig)
}
@Test fun typeParameterBounds() {
- verifyMarkdownNode("typeParameterBounds")
+ verifyMarkdownNode("typeParameterBounds", defaultModelConfig)
}
@Test fun typeParameterVariance() {
- verifyMarkdownNode("typeParameterVariance")
+ verifyMarkdownNode("typeParameterVariance", defaultModelConfig)
}
@Test fun typeProjectionVariance() {
- verifyMarkdownNode("typeProjectionVariance")
- }
-
- @Test fun javadocHtml() {
- verifyJavaMarkdownNode("javadocHtml")
- }
-
- @Test fun javaCodeLiteralTags() {
- verifyJavaMarkdownNode("javaCodeLiteralTags")
- }
-
- @Test fun javaCodeInParam() {
- verifyJavaMarkdownNode("javaCodeInParam")
- }
-
- @Test fun javaSpaceInAuthor() {
- verifyJavaMarkdownNode("javaSpaceInAuthor")
- }
-
- @Test fun nullability() {
- verifyMarkdownNode("nullability")
- }
-
- @Test fun operatorOverloading() {
- verifyMarkdownNodes("operatorOverloading") { model->
- model.members.single().members.single { it.name == "C" }.members.filter { it.name == "plus" }
- }
- }
-
- @Test fun javadocOrderedList() {
- verifyJavaMarkdownNodes("javadocOrderedList") { model ->
- model.members.single().members.filter { it.name == "Bar" }
- }
+ verifyMarkdownNode("typeProjectionVariance", defaultModelConfig)
}
@Test fun codeBlockNoHtmlEscape() {
- verifyMarkd