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() {
- verifyMarkdownNodeByName("codeBlockNoHtmlEscape", "hackTheArithmetic")
+ verifyMarkdownNodeByName("codeBlockNoHtmlEscape", "hackTheArithmetic", defaultModelConfig)
}
@Test fun companionObjectExtension() {
- verifyMarkdownNodeByName("companionObjectExtension", "Foo")
+ verifyMarkdownNodeByName("companionObjectExtension", "Foo", defaultModelConfig)
}
@Test fun starProjection() {
- verifyMarkdownNode("starProjection")
+ verifyMarkdownNode("starProjection", defaultModelConfig)
}
@Test fun extensionFunctionParameter() {
- verifyMarkdownNode("extensionFunctionParameter")
+ verifyMarkdownNode("extensionFunctionParameter", defaultModelConfig)
}
@Test fun summarizeSignatures() {
- verifyMarkdownNodes("summarizeSignatures") { model -> model.members }
- }
-
- @Test fun summarizeSignaturesProperty() {
- verifyMarkdownNodes("summarizeSignaturesProperty") { model -> model.members }
+ verifyMarkdownNodes("summarizeSignatures", defaultModelConfig) { model -> model.members }
}
@Test fun reifiedTypeParameter() {
- verifyMarkdownNode("reifiedTypeParameter", withKotlinRuntime = true)
+ verifyMarkdownNode("reifiedTypeParameter", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
}
@Test fun annotatedTypeParameter() {
- verifyMarkdownNode("annotatedTypeParameter", withKotlinRuntime = true)
+ verifyMarkdownNode("annotatedTypeParameter", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
}
@Test fun inheritedMembers() {
- verifyMarkdownNodeByName("inheritedMembers", "Bar")
+ verifyMarkdownNodeByName("inheritedMembers", "Bar", defaultModelConfig)
}
@Test fun inheritedExtensions() {
- verifyMarkdownNodeByName("inheritedExtensions", "Bar")
+ verifyMarkdownNodeByName("inheritedExtensions", "Bar", defaultModelConfig)
}
@Test fun genericInheritedExtensions() {
- verifyMarkdownNodeByName("genericInheritedExtensions", "Bar")
+ verifyMarkdownNodeByName("genericInheritedExtensions", "Bar", defaultModelConfig)
}
@Test fun arrayAverage() {
- verifyMarkdownNodeByName("arrayAverage", "XArray")
+ verifyMarkdownNodeByName("arrayAverage", "XArray", defaultModelConfig)
}
@Test fun multipleTypeParameterConstraints() {
- verifyMarkdownNode("multipleTypeParameterConstraints", withKotlinRuntime = true)
+ verifyMarkdownNode("multipleTypeParameterConstraints", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
}
@Test fun inheritedCompanionObjectProperties() {
- verifyMarkdownNodeByName("inheritedCompanionObjectProperties", "C")
+ verifyMarkdownNodeByName("inheritedCompanionObjectProperties", "C", defaultModelConfig)
}
@Test fun shadowedExtensionFunctions() {
- verifyMarkdownNodeByName("shadowedExtensionFunctions", "Bar")
+ verifyMarkdownNodeByName("shadowedExtensionFunctions", "Bar", defaultModelConfig)
}
@Test fun inapplicableExtensionFunctions() {
- verifyMarkdownNodeByName("inapplicableExtensionFunctions", "Bar")
+ verifyMarkdownNodeByName("inapplicableExtensionFunctions", "Bar", defaultModelConfig)
}
@Test fun receiverParameterTypeBound() {
- verifyMarkdownNodeByName("receiverParameterTypeBound", "Foo")
+ verifyMarkdownNodeByName("receiverParameterTypeBound", "Foo", defaultModelConfig)
}
@Test fun extensionWithDocumentedReceiver() {
- verifyMarkdownNodes("extensionWithDocumentedReceiver") { model ->
+ verifyMarkdownNodes("extensionWithDocumentedReceiver", defaultModelConfig) { model ->
model.members.single().members.single().members.filter { it.name == "fn" }
}
}
- @Test fun jdkLinks() {
- verifyMarkdownNode("jdkLinks", withKotlinRuntime = true)
- }
-
@Test fun codeBlock() {
- verifyMarkdownNode("codeBlock")
+ verifyMarkdownNode("codeBlock", defaultModelConfig)
}
@Test fun exclInCodeBlock() {
- verifyMarkdownNodeByName("exclInCodeBlock", "foo")
+ verifyMarkdownNodeByName("exclInCodeBlock", "foo", defaultModelConfig)
}
@Test fun backtickInCodeBlock() {
- verifyMarkdownNodeByName("backtickInCodeBlock", "foo")
+ verifyMarkdownNodeByName("backtickInCodeBlock", "foo", defaultModelConfig)
}
@Test fun qualifiedNameLink() {
- verifyMarkdownNodeByName("qualifiedNameLink", "foo", withKotlinRuntime = true)
+ verifyMarkdownNodeByName("qualifiedNameLink", "foo",
+ ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
}
@Test fun functionalTypeWithNamedParameters() {
- verifyMarkdownNode("functionalTypeWithNamedParameters")
+ verifyMarkdownNode("functionalTypeWithNamedParameters", defaultModelConfig)
}
@Test fun typeAliases() {
- verifyMarkdownNode("typeAliases")
- verifyMarkdownPackage("typeAliases")
- }
-
- @Test fun sampleByFQName() {
- verifyMarkdownNode("sampleByFQName")
+ verifyMarkdownNode("typeAliases", defaultModelConfig)
+ verifyMarkdownPackage("typeAliases", defaultModelConfig)
}
@Test fun sampleByShortName() {
- verifyMarkdownNode("sampleByShortName")
+ verifyMarkdownNode("sampleByShortName", defaultModelConfig)
}
@Test fun suspendParam() {
- verifyMarkdownNode("suspendParam")
- verifyMarkdownPackage("suspendParam")
+ verifyMarkdownNode("suspendParam", defaultModelConfig)
+ verifyMarkdownPackage("suspendParam", defaultModelConfig)
}
@Test fun sinceKotlin() {
- verifyMarkdownNode("sinceKotlin")
- verifyMarkdownPackage("sinceKotlin")
+ verifyMarkdownNode("sinceKotlin", defaultModelConfig)
+ verifyMarkdownPackage("sinceKotlin", defaultModelConfig)
}
@Test fun sinceKotlinWide() {
- verifyMarkdownPackage("sinceKotlinWide")
+ verifyMarkdownPackage("sinceKotlinWide", defaultModelConfig)
}
@Test fun dynamicType() {
- verifyMarkdownNode("dynamicType")
+ verifyMarkdownNode("dynamicType", defaultModelConfig)
}
@Test fun dynamicExtension() {
- verifyMarkdownNodes("dynamicExtension") { model -> model.members.single().members.filter { it.name == "Foo" } }
+ verifyMarkdownNodes("dynamicExtension", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Foo" } }
}
@Test fun memberExtension() {
- verifyMarkdownNodes("memberExtension") { model -> model.members.single().members.filter { it.name == "Foo" } }
+ verifyMarkdownNodes("memberExtension", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Foo" } }
}
@Test fun renderFunctionalTypeInParenthesisWhenItIsReceiver() {
- verifyMarkdownNode("renderFunctionalTypeInParenthesisWhenItIsReceiver")
+ verifyMarkdownNode("renderFunctionalTypeInParenthesisWhenItIsReceiver", defaultModelConfig)
}
@Test fun multiplePlatforms() {
@@ -282,37 +225,52 @@ class MarkdownFormatTest {
@Test fun multiplePlatformsMergeMembers() {
val module = buildMultiplePlatforms("multiplatform/mergeMembers")
verifyModelOutput(module, ".md", "testdata/format/multiplatform/mergeMembers/foo.kt") { model, output ->
- markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members)
+ buildPagesAndReadInto(model.members.single().members, output)
}
}
@Test fun multiplePlatformsOmitRedundant() {
val module = buildMultiplePlatforms("multiplatform/omitRedundant")
verifyModelOutput(module, ".md", "testdata/format/multiplatform/omitRedundant/foo.kt") { model, output ->
- markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members)
+ buildPagesAndReadInto(model.members.single().members, output)
}
}
@Test fun multiplePlatformsImplied() {
val module = buildMultiplePlatforms("multiplatform/implied")
verifyModelOutput(module, ".md", "testdata/format/multiplatform/implied/foo.kt") { model, output ->
- MarkdownFormatService(InMemoryLocationService, KotlinLanguageService(), listOf("JVM", "JS"))
- .createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members)
+ val service = MarkdownFormatService(fileGenerator, KotlinLanguageService(), listOf("JVM", "JS"))
+ fileGenerator.formatService = service
+ buildPagesAndReadInto(model.members.single().members, output)
}
}
@Test fun packagePlatformsWithExtExtensions() {
val path = "multiplatform/packagePlatformsWithExtExtensions"
val module = DocumentationModule("test")
- val options = DocumentationOptions(
- outputDir = "",
- outputFormat = "html",
- generateIndexPages = false,
+ val passConfiguration = PassConfigurationImpl(
noStdlibLink = true,
+ noJdkLink = true,
languageVersion = null,
apiVersion = null
)
- appendDocumentation(module, contentRootFromPath("testdata/format/$path/jvm.kt"), defaultPlatforms = listOf("JVM"), withKotlinRuntime = true, options = options)
+
+ val dokkaConfiguration = DokkaConfigurationImpl(
+ outputDir = "",
+ format = "html",
+ generateIndexPages = false,
+ passesConfigurations = listOf(
+ passConfiguration
+ )
+ )
+
+ appendDocumentation(module, dokkaConfiguration, passConfiguration, ModelConfig(
+ roots = arrayOf(contentRootFromPath("testdata/format/$path/jvm.kt")),
+ defaultPlatforms = listOf("JVM"),
+ withKotlinRuntime = true,
+ analysisPlatform = analysisPlatform
+ )
+ )
verifyMultiplatformIndex(module, path)
verifyMultiplatformPackage(module, path)
}
@@ -328,8 +286,10 @@ class MarkdownFormatTest {
val path = "multiplatform/groupNode"
val module = buildMultiplePlatforms(path)
verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.kt") { model, output ->
- markdownService.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)
}
@@ -338,155 +298,179 @@ class MarkdownFormatTest {
val path = "multiplatform/breadcrumbsInMemberOfMemberOfGroupNode"
val module = buildMultiplePlatforms(path)
verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.kt") { model, output ->
- markdownService.createOutputBuilder(output, tempLocation)
- .appendNodes(listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }?.member(NodeKind.Class)?.member(NodeKind.Function)))
+ buildPagesAndReadInto(
+ listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }?.member(NodeKind.Class)?.member(NodeKind.Function)),
+ output
+ )
}
}
@Test fun linksInEmphasis() {
- verifyMarkdownNode("linksInEmphasis")
+ verifyMarkdownNode("linksInEmphasis", defaultModelConfig)
}
@Test fun linksInStrong() {
- verifyMarkdownNode("linksInStrong")
+ verifyMarkdownNode("linksInStrong", defaultModelConfig)
}
@Test fun linksInHeaders() {
- verifyMarkdownNode("linksInHeaders")
+ verifyMarkdownNode("linksInHeaders", defaultModelConfig)
}
@Test fun tokensInEmphasis() {
- verifyMarkdownNode("tokensInEmphasis")
+ verifyMarkdownNode("tokensInEmphasis", defaultModelConfig)
}
@Test fun tokensInStrong() {
- verifyMarkdownNode("tokensInStrong")
+ verifyMarkdownNode("tokensInStrong", defaultModelConfig)
}
@Test fun tokensInHeaders() {
- verifyMarkdownNode("tokensInHeaders")
+ verifyMarkdownNode("tokensInHeaders", defaultModelConfig)
}
@Test fun unorderedLists() {
- verifyMarkdownNode("unorderedLists")
+ verifyMarkdownNode("unorderedLists", defaultModelConfig)
}
@Test fun nestedLists() {
- verifyMarkdownNode("nestedLists")
+ verifyMarkdownNode("nestedLists", defaultModelConfig)
}
@Test fun referenceLink() {
- verifyMarkdownNode("referenceLink")
+ verifyMarkdownNode("referenceLink", defaultModelConfig)
}
@Test fun externalReferenceLink() {
- verifyMarkdownNode("externalReferenceLink")
+ verifyMarkdownNode("externalReferenceLink", defaultModelConfig)
}
@Test fun newlineInTableCell() {
- verifyMarkdownPackage("newlineInTableCell")
+ verifyMarkdownPackage("newlineInTableCell", defaultModelConfig)
}
@Test fun indentedCodeBlock() {
- verifyMarkdownNode("indentedCodeBlock")
+ verifyMarkdownNode("indentedCodeBlock", defaultModelConfig)
}
@Test fun receiverReference() {
- verifyMarkdownNode("receiverReference")
+ verifyMarkdownNode("receiverReference", defaultModelConfig)
}
@Test fun extensionScope() {
- verifyMarkdownNodeByName("extensionScope", "test")
+ verifyMarkdownNodeByName("extensionScope", "test", defaultModelConfig)
}
@Test fun typeParameterReference() {
- verifyMarkdownNode("typeParameterReference")
+ verifyMarkdownNode("typeParameterReference", defaultModelConfig)
}
@Test fun notPublishedTypeAliasAutoExpansion() {
- verifyMarkdownNodeByName("notPublishedTypeAliasAutoExpansion", "foo", includeNonPublic = false)
+ verifyMarkdownNodeByName("notPublishedTypeAliasAutoExpansion", "foo", ModelConfig(
+ analysisPlatform = analysisPlatform,
+ includeNonPublic = false
+ ))
}
@Test fun companionImplements() {
- verifyMarkdownNodeByName("companionImplements", "Foo")
+ verifyMarkdownNodeByName("companionImplements", "Foo", defaultModelConfig)
}
+
private fun buildMultiplePlatforms(path: String): DocumentationModule {
val module = DocumentationModule("test")
- val options = DocumentationOptions(
- outputDir = "",
- outputFormat = "html",
- generateIndexPages = false,
+ val passConfiguration = PassConfigurationImpl(
noStdlibLink = true,
+ noJdkLink = true,
languageVersion = null,
apiVersion = null
)
- appendDocumentation(module, contentRootFromPath("testdata/format/$path/jvm.kt"), defaultPlatforms = listOf("JVM"), options = options)
- appendDocumentation(module, contentRootFromPath("testdata/format/$path/js.kt"), defaultPlatforms = listOf("JS"), options = options)
+ val dokkaConfiguration = DokkaConfigurationImpl(
+ outputDir = "",
+ format = "html",
+ generateIndexPages = false,
+ passesConfigurations = listOf(
+ passConfiguration
+ )
+
+ )
+ appendDocumentation(
+ module, dokkaConfiguration, passConfiguration, ModelConfig(
+ roots = arrayOf(contentRootFromPath("testdata/format/$path/jvm.kt")),
+ defaultPlatforms = listOf("JVM"),
+ analysisPlatform = Platform.jvm
+ )
+ )
+ appendDocumentation(
+ module, dokkaConfiguration, passConfiguration, ModelConfig(
+ roots = arrayOf(contentRootFromPath("testdata/format/$path/js.kt")),
+ defaultPlatforms = listOf("JS"),
+ analysisPlatform = Platform.js
+ )
+ )
+
return module
}
private fun verifyMultiplatformPackage(module: DocumentationModule, path: String) {
verifyModelOutput(module, ".package.md", "testdata/format/$path/multiplatform.kt") { model, output ->
- markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members)
+ buildPagesAndReadInto(model.members, output)
}
}
private fun verifyMultiplatformIndex(module: DocumentationModule, path: String) {
verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.index.kt") {
model, output ->
- MarkdownFormatService(InMemoryLocationService, KotlinLanguageService(), listOf())
- .createOutputBuilder(output, tempLocation).appendNodes(listOf(model))
+ val service = MarkdownFormatService(fileGenerator, KotlinLanguageService(), listOf())
+ fileGenerator.formatService = service
+ buildPagesAndReadInto(listOf(model), output)
}
}
@Test fun blankLineInsideCodeBlock() {
- verifyMarkdownNode("blankLineInsideCodeBlock")
+ verifyMarkdownNode("blankLineInsideCodeBlock", defaultModelConfig)
}
- private fun verifyMarkdownPackage(fileName: String, withKotlinRuntime: Boolean = false) {
- verifyOutput("testdata/format/$fileName.kt", ".package.md", withKotlinRuntime = withKotlinRuntime) { model, output ->
- markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members)
+ protected fun verifyMarkdownPackage(fileName: String, modelConfig: ModelConfig = ModelConfig()) {
+ verifyOutput("testdata/format/$fileName.kt", ".package.md", modelConfig) { model, output ->
+ buildPagesAndReadInto(model.members, output)
}
}
- private fun verifyMarkdownNode(fileName: String, withKotlinRuntime: Boolean = false) {
- verifyMarkdownNodes(fileName, withKotlinRuntime) { model -> model.members.single().members }
+ protected fun verifyMarkdownNode(fileName: String, modelConfig: ModelConfig = ModelConfig()) {
+ verifyMarkdownNodes(fileName, modelConfig) { model -> model.members.single().members }
}
- private fun verifyMarkdownNodes(
+ protected fun verifyMarkdownNodes(
fileName: String,
- withKotlinRuntime: Boolean = false,
- includeNonPublic: Boolean = true,
+ modelConfig: ModelConfig = ModelConfig(),
nodeFilter: (DocumentationModule) -> List<DocumentationNode>
) {
verifyOutput(
"testdata/format/$fileName.kt",
".md",
- withKotlinRuntime = withKotlinRuntime,
- includeNonPublic = includeNonPublic
+ modelConfig
) { model, output ->
- markdownService.createOutputBuilder(output, tempLocation).appendNodes(nodeFilter(model))
+ buildPagesAndReadInto(nodeFilter(model), output)
}
}
- private fun verifyJavaMarkdownNode(fileName: String, withKotlinRuntime: Boolean = false) {
- verifyJavaMarkdownNodes(fileName, withKotlinRuntime) { model -> model.members.single().members }
+ protected fun verifyJavaMarkdownNode(fileName: String, modelConfig: ModelConfig = ModelConfig()) {
+ verifyJavaMarkdownNodes(fileName, modelConfig) { model -> model.members.single().members }
}
- private fun verifyJavaMarkdownNodes(fileName: String, withKotlinRuntime: Boolean = false, nodeFilter: (DocumentationModule) -> List<DocumentationNode>) {
- verifyJavaOutput("testdata/format/$fileName.java", ".md", withKotlinRuntime = withKotlinRuntime) { model, output ->
- markdownService.createOutputBuilder(output, tempLocation).appendNodes(nodeFilter(model))
+ protected fun verifyJavaMarkdownNodes(fileName: String, modelConfig: ModelConfig = ModelConfig(), nodeFilter: (DocumentationModule) -> List<DocumentationNode>) {
+ verifyJavaOutput("testdata/format/$fileName.java", ".md", modelConfig) { model, output ->
+ buildPagesAndReadInto(nodeFilter(model), output)
}
}
- private fun verifyMarkdownNodeByName(
+ protected fun verifyMarkdownNodeByName(
fileName: String,
name: String,
- withKotlinRuntime: Boolean = false,
- includeNonPublic: Boolean = true
+ modelConfig: ModelConfig = ModelConfig()
) {
- verifyMarkdownNodes(fileName, withKotlinRuntime, includeNonPublic) { model->
+ verifyMarkdownNodes(fileName, modelConfig) { model->
val nodesWithName = model.members.single().members.filter { it.name == name }
if (nodesWithName.isEmpty()) {
throw IllegalArgumentException("Found no nodes named $name")
@@ -495,3 +479,116 @@ class MarkdownFormatTest {
}
}
}
+
+class JSMarkdownFormatTest: BaseMarkdownFormatTest(Platform.js)
+
+class JVMMarkdownFormatTest: BaseMarkdownFormatTest(Platform.jvm) {
+
+ @Test
+ fun enumRef() {
+ verifyMarkdownNode("enumRef", defaultModelConfig)
+ }
+
+ @Test
+ fun javaCodeLiteralTags() {
+ verifyJavaMarkdownNode("javaCodeLiteralTags", defaultModelConfig)
+ }
+
+ @Test
+ fun nullability() {
+ verifyMarkdownNode("nullability", defaultModelConfig)
+ }
+
+ @Test
+ fun exceptionClass() {
+ verifyMarkdownNode(
+ "exceptionClass", ModelConfig(
+ analysisPlatform = analysisPlatform,
+ withKotlinRuntime = true
+ )
+ )
+ verifyMarkdownPackage(
+ "exceptionClass", ModelConfig(
+ analysisPlatform = analysisPlatform,
+ withKotlinRuntime = true
+ )
+ )
+ }
+
+ @Test
+ fun operatorOverloading() {
+ verifyMarkdownNodes("operatorOverloading", defaultModelConfig) { model->
+ model.members.single().members.single { it.name == "C" }.members.filter { it.name == "plus" }
+ }
+ }
+
+ @Test
+ fun extensions() {
+ verifyOutput("testdata/format/extensions.kt", ".package.md", defaultModelConfig) { model, output ->
+ buildPagesAndReadInto(model.members, output)
+ }
+ verifyOutput("testdata/format/extensions.kt", ".class.md", defaultModelConfig) { model, output ->
+ buildPagesAndReadInto(model.members.single().members, output)
+ }
+ }
+
+ @Test
+ fun summarizeSignaturesProperty() {
+ verifyMarkdownNodes("summarizeSignaturesProperty", defaultModelConfig) { model -> model.members }
+ }
+
+ @Test
+ fun javaSpaceInAuthor() {
+ verifyJavaMarkdownNode("javaSpaceInAuthor", defaultModelConfig)
+ }
+
+ @Test
+ fun javaCodeInParam() {
+ verifyJavaMarkdownNode("javaCodeInParam", defaultModelConfig)
+ }
+
+ @Test
+ fun annotationParams() {
+ verifyMarkdownNode("annotationParams", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true))
+ }
+
+ @Test fun inheritedLink() {
+ val filePath = "testdata/format/inheritedLink"
+ verifyOutput(
+ filePath,
+ ".md",
+ ModelConfig(
+ roots = arrayOf(
+ contentRootFromPath("$filePath.kt"),
+ contentRootFromPath("$filePath.1.kt")
+ ),
+ withJdk = true,
+ withKotlinRuntime = true,
+ includeNonPublic = false,
+ analysisPlatform = analysisPlatform
+
+ )
+ ) { model, output ->
+ buildPagesAndReadInto(model.members.single { it.name == "p2" }.members.single().members, output)
+ }
+ }
+
+ @Test
+ fun javadocOrderedList() {
+ verifyJavaMarkdownNodes("javadocOrderedList", defaultModelConfig) { model ->
+ model.members.single().members.filter { it.name == "Bar" }
+ }
+ }
+
+ @Test
+ fun jdkLinks() {
+ verifyMarkdownNode("jdkLinks", ModelConfig(withKotlinRuntime = true, analysisPlatform = analysisPlatform))
+ }
+
+ @Test
+ fun javadocHtml() {
+ verifyJavaMarkdownNode("javadocHtml", defaultModelConfig)
+ }
+}
+
+class CommonMarkdownFormatTest: BaseMarkdownFormatTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/format/PackageDocsTest.kt b/core/src/test/kotlin/format/PackageDocsTest.kt
index a5547025..b7fff1e2 100644
--- a/core/src/test/kotlin/format/PackageDocsTest.kt
+++ b/core/src/test/kotlin/format/PackageDocsTest.kt
@@ -1,20 +1,46 @@
package org.jetbrains.dokka.tests.format
+import com.intellij.openapi.Disposable
+import com.intellij.openapi.util.Disposer
import com.nhaarman.mockito_kotlin.any
import com.nhaarman.mockito_kotlin.doAnswer
import com.nhaarman.mockito_kotlin.eq
import com.nhaarman.mockito_kotlin.mock
import org.jetbrains.dokka.*
-import org.jetbrains.dokka.tests.InMemoryLocationService
import org.jetbrains.dokka.tests.assertEqualsIgnoringSeparators
+import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
+import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
+import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreProjectEnvironment
+import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
+import org.junit.After
import org.junit.Assert.assertEquals
+import org.junit.Before
import org.junit.Test
import java.io.File
-public class PackageDocsTest {
+class PackageDocsTest {
+
+ private lateinit var testDisposable: Disposable
+
+ @Before
+ fun setup() {
+ testDisposable = Disposer.newDisposable()
+ }
+
+ @After
+ fun cleanup() {
+ Disposer.dispose(testDisposable)
+ }
+
+ fun createPackageDocs(linkResolver: DeclarationLinkResolver?): PackageDocs {
+ val environment = KotlinCoreEnvironment.createForTests(testDisposable, CompilerConfiguration.EMPTY, EnvironmentConfigFiles.JVM_CONFIG_FILES)
+ return PackageDocs(linkResolver, DokkaConsoleLogger, environment, mock(), mock())
+ }
+
@Test fun verifyParse() {
- val docs = PackageDocs(null, DokkaConsoleLogger)
+
+ val docs = createPackageDocs(null)
docs.parse("testdata/packagedocs/stdlib.md", emptyList())
val packageContent = docs.packageContent["kotlin"]!!
val block = (packageContent.children.single() as ContentBlock).children.first() as ContentText
@@ -29,7 +55,7 @@ public class PackageDocsTest {
val mockPackageDescriptor = mock<PackageFragmentDescriptor> {}
- val docs = PackageDocs(mockLinkResolver, DokkaConsoleLogger)
+ val docs = createPackageDocs(mockLinkResolver)
docs.parse("testdata/packagedocs/referenceLinks.md", listOf(mockPackageDescriptor))
checkMarkdownOutput(docs, "testdata/packagedocs/referenceLinks")
@@ -37,8 +63,17 @@ public class PackageDocsTest {
fun checkMarkdownOutput(docs: PackageDocs, expectedFilePrefix: String) {
+ val generator = FileGenerator(File(""))
+
val out = StringBuilder()
- val outputBuilder = MarkdownOutputBuilder(out, InMemoryLocationService.root, InMemoryLocationService, KotlinLanguageService(), ".md", emptyList())
+ val outputBuilder = MarkdownOutputBuilder(
+ out,
+ FileLocation(generator.root),
+ generator,
+ KotlinLanguageService(),
+ ".md",
+ emptyList()
+ )
fun checkOutput(content: Content, filePostfix: String) {
outputBuilder.appendContent(content)
val expectedFile = File(expectedFilePrefix + filePostfix)