aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin/format
diff options
context:
space:
mode:
authorDoug Sigelbaum <sigelbaum@google.com>2018-06-18 18:02:34 -0400
committerDoug Sigelbaum <sigelbaum@google.com>2018-06-19 14:29:00 -0400
commitdd8a2a20e28e30444e735b16b140c0be7d695c55 (patch)
tree55fa01ce1eb95cf0cfe672c4ce4cf944f0dbc9ad /core/src/test/kotlin/format
parent244f97fc9ec5745b377e594e54b2f465489fef8b (diff)
downloaddokka-dd8a2a20e28e30444e735b16b140c0be7d695c55.tar.gz
Replace Dokka source with a Dokka maven repo (see ./maven).
Artifacts pulled from https://teamcity.jetbrains.com/viewLog.html?tab=artifacts&buildId=1485600. Bug: 72394196 Change-Id: I36ba18127bec9a2c393a9a7740623b98500f2d73
Diffstat (limited to 'core/src/test/kotlin/format')
-rw-r--r--core/src/test/kotlin/format/FileGeneratorTestCase.kt38
-rw-r--r--core/src/test/kotlin/format/GFMFormatTest.kt28
-rw-r--r--core/src/test/kotlin/format/HtmlFormatTest.kt181
-rw-r--r--core/src/test/kotlin/format/JavaLayoutHtmlFormatTest.kt113
-rw-r--r--core/src/test/kotlin/format/JavaLayoutHtmlFormatTestCase.kt115
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt72
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt83
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt39
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt502
-rw-r--r--core/src/test/kotlin/format/PackageDocsTest.kt65
10 files changed, 0 insertions, 1236 deletions
diff --git a/core/src/test/kotlin/format/FileGeneratorTestCase.kt b/core/src/test/kotlin/format/FileGeneratorTestCase.kt
deleted file mode 100644
index 644d5baa1..000000000
--- a/core/src/test/kotlin/format/FileGeneratorTestCase.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.DocumentationNode
-import org.jetbrains.dokka.FileGenerator
-import org.jetbrains.dokka.FormatService
-import org.jetbrains.dokka.relativeToRoot
-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: ${relativeToRoot(loc)} -->")
- }
- 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
deleted file mode 100644
index b90ab2bf2..000000000
--- a/core/src/test/kotlin/format/GFMFormatTest.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.GFMFormatService
-import org.jetbrains.dokka.KotlinLanguageService
-import org.junit.Test
-
-class GFMFormatTest : FileGeneratorTestCase() {
- override val formatService = GFMFormatService(fileGenerator, KotlinLanguageService(), listOf())
-
- @Test
- fun sample() {
- verifyGFMNodeByName("sample", "Foo")
- }
-
- @Test
- fun listInTableCell() {
- verifyGFMNodeByName("listInTableCell", "Foo")
- }
-
- private fun verifyGFMNodeByName(fileName: String, name: String) {
- verifyOutput("testdata/format/gfm/$fileName.kt", ".md") { model, output ->
- buildPagesAndReadInto(
- model.members.single().members.filter { it.name == name },
- output
- )
- }
- }
-}
diff --git a/core/src/test/kotlin/format/HtmlFormatTest.kt b/core/src/test/kotlin/format/HtmlFormatTest.kt
deleted file mode 100644
index 54c367fd7..000000000
--- a/core/src/test/kotlin/format/HtmlFormatTest.kt
+++ /dev/null
@@ -1,181 +0,0 @@
-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: FileGeneratorTestCase() {
- override val formatService = HtmlFormatService(fileGenerator, KotlinLanguageService(), HtmlTemplateService.default(), listOf())
-
- @Test fun classWithCompanionObject() {
- verifyHtmlNode("classWithCompanionObject")
- }
-
- @Test fun htmlEscaping() {
- verifyHtmlNode("htmlEscaping")
- }
-
- @Test fun overloads() {
- verifyHtmlNodes("overloads") { model -> model.members }
- }
-
- @Test fun overloadsWithDescription() {
- verifyHtmlNode("overloadsWithDescription")
- }
-
- @Test fun overloadsWithDifferentDescriptions() {
- verifyHtmlNode("overloadsWithDifferentDescriptions")
- }
-
- @Test fun deprecated() {
- verifyOutput("testdata/format/deprecated.kt", ".package.html") { model, output ->
- buildPagesAndReadInto(model.members, output)
- }
- verifyOutput("testdata/format/deprecated.kt", ".class.html") { model, output ->
- buildPagesAndReadInto(model.members.single().members, output)
- }
- }
-
- @Test fun brokenLink() {
- verifyHtmlNode("brokenLink")
- }
-
- @Test fun codeSpan() {
- verifyHtmlNode("codeSpan")
- }
-
- @Test fun parenthesis() {
- verifyHtmlNode("parenthesis")
- }
-
- @Test fun bracket() {
- verifyHtmlNode("bracket")
- }
-
- @Test fun see() {
- verifyHtmlNode("see")
- }
-
- @Test fun tripleBackticks() {
- verifyHtmlNode("tripleBackticks")
- }
-
- @Test fun typeLink() {
- verifyHtmlNodes("typeLink") { 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" }
- }
- }
-
- @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" }
- }
- }
-
- @Test fun crossLanguageKotlinExtendsJava() {
- verifyOutput(arrayOf(KotlinSourceRoot("testdata/format/crossLanguage/kotlinExtendsJava/Bar.kt"),
- JavaSourceRoot(File("testdata/format/crossLanguage/kotlinExtendsJava"), null)),
- ".html") { model, output ->
- buildPagesAndReadInto(
- model.members.single().members.filter { it.name == "Bar" },
- output
- )
- }
- }
-
- @Test fun orderedList() {
- verifyHtmlNodes("orderedList") { model -> model.members.single().members.filter { it.name == "Bar" } }
- }
-
- @Test fun linkWithLabel() {
- verifyHtmlNodes("linkWithLabel") { model -> model.members.single().members.filter { it.name == "Bar" } }
- }
-
- @Test fun entity() {
- verifyHtmlNodes("entity") { model -> model.members.single().members.filter { it.name == "Bar" } }
- }
-
- @Test fun uninterpretedEmphasisCharacters() {
- verifyHtmlNode("uninterpretedEmphasisCharacters")
- }
-
- @Test fun markdownInLinks() {
- verifyHtmlNode("markdownInLinks")
- }
-
- @Test fun returnWithLink() {
- verifyHtmlNode("returnWithLink")
- }
-
- @Test fun linkWithStarProjection() {
- verifyHtmlNode("linkWithStarProjection", withKotlinRuntime = true)
- }
-
- @Test fun functionalTypeWithNamedParameters() {
- verifyHtmlNode("functionalTypeWithNamedParameters")
- }
-
- @Test fun sinceKotlin() {
- verifyHtmlNode("sinceKotlin")
- }
-
- @Test fun blankLineInsideCodeBlock() {
- verifyHtmlNode("blankLineInsideCodeBlock")
- }
-
- @Test fun indentedCodeBlock() {
- verifyHtmlNode("indentedCodeBlock")
- }
-
- private fun verifyHtmlNode(fileName: String, withKotlinRuntime: Boolean = false) {
- verifyHtmlNodes(fileName, withKotlinRuntime) { model -> model.members.single().members }
- }
-
- private fun verifyHtmlNodes(fileName: String,
- withKotlinRuntime: Boolean = false,
- nodeFilter: (DocumentationModule) -> List<DocumentationNode>) {
- verifyOutput("testdata/format/$fileName.kt", ".html", withKotlinRuntime = withKotlinRuntime) { model, output ->
- buildPagesAndReadInto(nodeFilter(model), output)
- }
- }
-
- private fun verifyJavaHtmlNode(fileName: String, withKotlinRuntime: Boolean = false) {
- verifyJavaHtmlNodes(fileName, withKotlinRuntime) { model -> model.members.single().members }
- }
-
- private fun verifyJavaHtmlNodes(fileName: String,
- withKotlinRuntime: Boolean = false,
- nodeFilter: (DocumentationModule) -> List<DocumentationNode>) {
- verifyJavaOutput("testdata/format/$fileName.java", ".html", withKotlinRuntime = withKotlinRuntime) { model, output ->
- buildPagesAndReadInto(nodeFilter(model), output)
- }
- }
-}
-
diff --git a/core/src/test/kotlin/format/JavaLayoutHtmlFormatTest.kt b/core/src/test/kotlin/format/JavaLayoutHtmlFormatTest.kt
deleted file mode 100644
index a3cf0e3db..000000000
--- a/core/src/test/kotlin/format/JavaLayoutHtmlFormatTest.kt
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.*
-import org.jetbrains.dokka.Formats.JavaLayoutHtmlFormatDescriptor
-import org.junit.Test
-import java.io.File
-import java.net.URL
-
-class JavaLayoutHtmlFormatTest : JavaLayoutHtmlFormatTestCase() {
- override val formatDescriptor = JavaLayoutHtmlFormatDescriptor()
-
- @Test
- fun simple() {
- verifyNode("simple.kt")
- }
-
-// @Test
-// fun topLevel() {
-// verifyPackageNode("topLevel.kt")
-// }
-
- @Test
- fun codeBlocks() {
- verifyNode("codeBlocks.kt") { model ->
- listOf(model.members.single().members.single { it.name == "foo" })
- }
- }
-
- @Test
- fun const() {
- verifyPackageNode("const.kt", noStdlibLink = true)
- verifyNode("const.kt", noStdlibLink = true) { model ->
- model.members.single().members.filter { it.kind in NodeKind.classLike }
- }
- }
-
- @Test
- fun externalClassExtension() {
- verifyPackageNode("externalClassExtension.kt")
- }
-
- @Test
- fun unresolvedExternalClass() {
- verifyNode("unresolvedExternalClass.kt", noStdlibLink = true) { model ->
- listOf(model.members.single().members.single { it.name == "MyException" })
- }
- }
-
- @Test
- fun genericExtension() {
- verifyNode("genericExtension.kt", noStdlibLink = true) { model ->
- model.members.single().members(NodeKind.Class)
- }
- }
-
-
- @Test
- fun sections() {
- verifyNode("sections.kt", noStdlibLink = true) { model ->
- model.members.single().members.filter { it.name == "sectionsTest" }
- }
- }
-
- @Test
- fun constJava() {
- verifyNode("ConstJava.java", noStdlibLink = true)
- }
-
- @Test
- fun inboundLinksInKotlinMode() {
- val root = "./testdata/format/java-layout-html"
-
- val options = DocumentationOptions(
- "",
- "java-layout-html",
- sourceLinks = listOf(),
- generateIndexPages = false,
- noStdlibLink = true,
- apiVersion = null,
- languageVersion = null,
- perPackageOptions = listOf(PackageOptionsImpl("foo", suppress = true)),
- externalDocumentationLinks =
- listOf(
- DokkaConfiguration.ExternalDocumentationLink.Builder(
- URL("file:///"),
- File(root, "inboundLinksTestPackageList").toURI().toURL()
- ).build()
- )
- )
-
-
- val sourcePath = "$root/inboundLinksInKotlinMode.kt"
- val documentation = DocumentationModule("test")
-
- appendDocumentation(
- documentation,
- contentRootFromPath(sourcePath),
- contentRootFromPath("$root/inboundLinksInKotlinMode.Dep.kt"),
- withJdk = false,
- withKotlinRuntime = false,
- options = options
- )
- documentation.prepareForGeneration(options)
-
- verifyModelOutput(documentation, ".html", sourcePath) { model, output ->
- buildPagesAndReadInto(
- model,
- model.members.single { it.name == "bar" }.members,
- output
- )
- }
- }
-} \ No newline at end of file
diff --git a/core/src/test/kotlin/format/JavaLayoutHtmlFormatTestCase.kt b/core/src/test/kotlin/format/JavaLayoutHtmlFormatTestCase.kt
deleted file mode 100644
index 50af8f2f7..000000000
--- a/core/src/test/kotlin/format/JavaLayoutHtmlFormatTestCase.kt
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import com.google.inject.Guice
-import com.google.inject.Injector
-import com.google.inject.Module
-import com.google.inject.name.Names
-import org.jetbrains.dokka.DocumentationNode
-import org.jetbrains.dokka.DocumentationOptions
-import org.jetbrains.dokka.DokkaLogger
-import org.jetbrains.dokka.Formats.JavaLayoutHtmlFormatDescriptorBase
-import org.jetbrains.dokka.Formats.JavaLayoutHtmlFormatGenerator
-import org.jetbrains.dokka.Generator
-import org.jetbrains.dokka.Utilities.bind
-import org.junit.Rule
-import org.junit.rules.TemporaryFolder
-import java.io.File
-import java.net.URI
-
-abstract class JavaLayoutHtmlFormatTestCase {
-
- abstract val formatDescriptor: JavaLayoutHtmlFormatDescriptorBase
-
- @get:Rule
- var folder = TemporaryFolder()
-
- var options =
- DocumentationOptions(
- "",
- "java-layout-html",
- apiVersion = null,
- languageVersion = null,
- generateIndexPages = false,
- noStdlibLink = false,
- collectInheritedExtensionsFromLibraries = true
- )
-
- val injector: Injector by lazy {
- Guice.createInjector(Module { binder ->
- binder.bind<File>().annotatedWith(Names.named("outputDir")).toInstance(folder.apply { create() }.root)
-
- binder.bind<DocumentationOptions>().toProvider { options }
- binder.bind<DokkaLogger>().toInstance(object : DokkaLogger {
- override fun info(message: String) {
- println(message)
- }
-
- override fun warn(message: String) {
- println("WARN: $message")
- }
-
- override fun error(message: String) {
- println("ERROR: $message")
- }
-
- })
-
- formatDescriptor.configureOutput(binder)
- })
- }
-
-
- protected fun buildPagesAndReadInto(model: DocumentationNode, nodes: List<DocumentationNode>, sb: StringBuilder) =
- with(injector.getInstance(Generator::class.java)) {
- this as JavaLayoutHtmlFormatGenerator
- buildPages(listOf(model))
- val byLocations = nodes.groupBy { mainUri(it) }
- byLocations.forEach { (loc, _) ->
- sb.appendln("<!-- File: $loc -->")
- sb.append(folder.root.toURI().resolve(URI("/").relativize(loc)).toURL().readText())
- }
- }
-
-
- protected fun verifyNode(
- fileName: String,
- noStdlibLink: Boolean = false,
- fileExtension: String = ".html",
- select: (model: DocumentationNode) -> List<DocumentationNode>
- ) {
- verifyOutput(
- "testdata/format/java-layout-html/$fileName",
- fileExtension,
- format = "java-layout-html",
- withKotlinRuntime = true,
- noStdlibLink = noStdlibLink,
- collectInheritedExtensionsFromLibraries = true
- ) { model, output ->
- buildPagesAndReadInto(
- model,
- select(model),
- output
- )
- }
- }
-
- protected fun verifyNode(fileName: String, noStdlibLink: Boolean = false) {
- verifyNode(fileName, noStdlibLink) { model -> listOf(model.members.single().members.single()) }
- }
-
- protected fun verifyPackageNode(fileName: String, noStdlibLink: Boolean = false) {
- verifyOutput(
- "testdata/format/java-layout-html/$fileName",
- ".package-summary.html",
- format = "java-layout-html",
- withKotlinRuntime = true,
- noStdlibLink = noStdlibLink
- ) { model, output ->
- buildPagesAndReadInto(
- model,
- listOf(model.members.single()),
- output
- )
- }
- }
-} \ 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 b971b54d8..000000000
--- a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.*
-import org.junit.Before
-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", 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,
- 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)
- 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/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
deleted file mode 100644
index 49fa6d2fe..000000000
--- a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.*
-import org.junit.Before
-import org.junit.Test
-
-class KotlinWebSiteHtmlFormatTest: FileGeneratorTestCase() {
- override val formatService = KotlinWebsiteHtmlFormatService(fileGenerator, KotlinLanguageService(), listOf(), EmptyHtmlTemplateService)
-
- @Test fun dropImport() {
- verifyKWSNodeByName("dropImport", "foo")
- }
-
- @Test fun sample() {
- verifyKWSNodeByName("sample", "foo")
- }
-
- @Test fun sampleWithAsserts() {
- verifyKWSNodeByName("sampleWithAsserts", "a")
- }
-
- @Test fun newLinesInSamples() {
- verifyKWSNodeByName("newLinesInSamples", "foo")
- }
-
- @Test fun newLinesInImportList() {
- verifyKWSNodeByName("newLinesInImportList", "foo")
- }
-
- @Test fun returnTag() {
- verifyKWSNodeByName("returnTag", "indexOf")
- }
-
- @Test fun overloadGroup() {
- verifyKWSNodeByName("overloadGroup", "magic")
- }
-
- @Test fun dataTags() {
- val module = buildMultiplePlatforms("dataTags")
- verifyMultiplatformPackage(module, "dataTags")
- }
-
- @Test fun dataTagsInGroupNode() {
- val path = "dataTagsInGroupNode"
- val module = buildMultiplePlatforms(path)
- verifyModelOutput(module, ".html", "testdata/format/website-html/$path/multiplatform.kt") { model, output ->
- 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 ->
- 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,
- noStdlibLink = 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)
- return module
- }
-
- private fun verifyMultiplatformPackage(module: DocumentationModule, path: String) {
- verifyModelOutput(module, ".package.html", "testdata/format/website-html/$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 453b1de85..000000000
--- 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 })
-// }
-// }
-}
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
deleted file mode 100644
index 14405abcc..000000000
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ /dev/null
@@ -1,502 +0,0 @@
-package org.jetbrains.dokka.tests
-
-import org.jetbrains.dokka.*
-import org.junit.Before
-import org.junit.Test
-
-class MarkdownFormatTest: FileGeneratorTestCase() {
- override val formatService = MarkdownFormatService(fileGenerator, KotlinLanguageService(), listOf())
-
- @Test fun emptyDescription() {
- verifyMarkdownNode("emptyDescription")
- }
-
- @Test fun classWithCompanionObject() {
- verifyMarkdownNode("classWithCompanionObject")
- }
-
- @Test fun annotations() {
- verifyMarkdownNode("annotations")
- }
-
- @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 ->
- buildPagesAndReadInto(model.members, output)
- }
- verifyOutput("testdata/format/extensions.kt", ".class.md") { model, output ->
- buildPagesAndReadInto(model.members.single().members, output)
- }
- }
-
- @Test fun enumClass() {
- verifyOutput("testdata/format/enumClass.kt", ".md") { model, output ->
- buildPagesAndReadInto(model.members.single().members, output)
- }
- verifyOutput("testdata/format/enumClass.kt", ".value.md") { model, output ->
- val enumClassNode = model.members.single().members[0]
- buildPagesAndReadInto(
- enumClassNode.members.filter { it.name == "LOCAL_CONTINUE_AND_BREAK" },
- output
- )
- }
- }
-
- @Test fun varargsFunction() {
- verifyMarkdownNode("varargsFunction")
- }
-
- @Test fun overridingFunction() {
- verifyMarkdownNodes("overridingFunction") { model->
- val classMembers = model.members.single().members.first { it.name == "D" }.members
- classMembers.filter { it.name == "f" }
- }
- }
-
- @Test fun propertyVar() {
- verifyMarkdownNode("propertyVar")
- }
-
- @Test fun functionWithDefaultParameter() {
- verifyMarkdownNode("functionWithDefaultParameter")
- }
-
- @Test fun accessor() {
- verifyMarkdownNodes("accessor") { model ->
- model.members.single().members.first { it.name == "C" }.members.filter { it.name == "x" }
- }
- }
-
- @Test fun paramTag() {
- verifyMarkdownNode("paramTag")
- }
-
- @Test fun throwsTag() {
- verifyMarkdownNode("throwsTag")
- }
-
- @Test fun typeParameterBounds() {
- verifyMarkdownNode("typeParameterBounds")
- }
-
- @Test fun typeParameterVariance() {
- verifyMarkdownNode("typeParameterVariance")
- }
-
- @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" }
- }
- }
-
- @Test fun codeBlockNoHtmlEscape() {
- verifyMarkdownNodeByName("codeBlockNoHtmlEscape", "hackTheArithmetic")
- }
-
- @Test fun companionObjectExtension() {
- verifyMarkdownNodeByName("companionObjectExtension", "Foo")
- }
-
- @Test fun starProjection() {
- verifyMarkdownNode("starProjection")
- }
-
- @Test fun extensionFunctionParameter() {
- verifyMarkdownNode("extensionFunctionParameter")
- }
-
- @Test fun summarizeSignatures() {
- verifyMarkdownNodes("summarizeSignatures") { model -> model.members }
- }
-
- @Test fun summarizeSignaturesProperty() {
- verifyMarkdownNodes("summarizeSignaturesProperty") { model -> model.members }
- }
-
- @Test fun reifiedTypeParameter() {
- verifyMarkdownNode("reifiedTypeParameter", withKotlinRuntime = true)
- }
-
- @Test fun annotatedTypeParameter() {
- verifyMarkdownNode("annotatedTypeParameter", withKotlinRuntime = true)
- }
-
- @Test fun inheritedMembers() {
- verifyMarkdownNodeByName("inheritedMembers", "Bar")
- }
-
- @Test fun inheritedExtensions() {
- verifyMarkdownNodeByName("inheritedExtensions", "Bar")
- }
-
- @Test fun genericInheritedExtensions() {
- verifyMarkdownNodeByName("genericInheritedExtensions", "Bar")
- }
-
- @Test fun arrayAverage() {
- verifyMarkdownNodeByName("arrayAverage", "XArray")
- }
-
- @Test fun multipleTypeParameterConstraints() {
- verifyMarkdownNode("multipleTypeParameterConstraints", withKotlinRuntime = true)
- }
-
- @Test fun inheritedCompanionObjectProperties() {
- verifyMarkdownNodeByName("inheritedCompanionObjectProperties", "C")
- }
-
- @Test fun shadowedExtensionFunctions() {
- verifyMarkdownNodeByName("shadowedExtensionFunctions", "Bar")
- }
-
- @Test fun inapplicableExtensionFunctions() {
- verifyMarkdownNodeByName("inapplicableExtensionFunctions", "Bar")
- }
-
- @Test fun receiverParameterTypeBound() {
- verifyMarkdownNodeByName("receiverParameterTypeBound", "Foo")
- }
-
- @Test fun extensionWithDocumentedReceiver() {
- verifyMarkdownNodes("extensionWithDocumentedReceiver") { model ->
- model.members.single().members.single().members.filter { it.name == "fn" }
- }
- }
-
- @Test fun codeBlock() {
- verifyMarkdownNode("codeBlock")
- }
-
- @Test fun exclInCodeBlock() {
- verifyMarkdownNodeByName("exclInCodeBlock", "foo")
- }
-
- @Test fun backtickInCodeBlock() {
- verifyMarkdownNodeByName("backtickInCodeBlock", "foo")
- }
-
- @Test fun qualifiedNameLink() {
- verifyMarkdownNodeByName("qualifiedNameLink", "foo", withKotlinRuntime = true)
- }
-
- @Test fun functionalTypeWithNamedParameters() {
- verifyMarkdownNode("functionalTypeWithNamedParameters")
- }
-
- @Test fun typeAliases() {
- verifyMarkdownNode("typeAliases")
- verifyMarkdownPackage("typeAliases")
- }
-
- @Test fun sampleByFQName() {
- verifyMarkdownNode("sampleByFQName")
- }
-
- @Test fun sampleByShortName() {
- verifyMarkdownNode("sampleByShortName")
- }
-
-
- @Test fun suspendParam() {
- verifyMarkdownNode("suspendParam")
- verifyMarkdownPackage("suspendParam")
- }
-
- @Test fun sinceKotlin() {
- verifyMarkdownNode("sinceKotlin")
- verifyMarkdownPackage("sinceKotlin")
- }
-
- @Test fun sinceKotlinWide() {
- verifyMarkdownPackage("sinceKotlinWide")
- }
-
- @Test fun dynamicType() {
- verifyMarkdownNode("dynamicType")
- }
-
- @Test fun dynamicExtension() {
- verifyMarkdownNodes("dynamicExtension") { model -> model.members.single().members.filter { it.name == "Foo" } }
- }
-
- @Test fun memberExtension() {
- verifyMarkdownNodes("memberExtension") { model -> model.members.single().members.filter { it.name == "Foo" } }
- }
-
- @Test fun renderFunctionalTypeInParenthesisWhenItIsReceiver() {
- verifyMarkdownNode("renderFunctionalTypeInParenthesisWhenItIsReceiver")
- }
-
- @Test fun multiplePlatforms() {
- verifyMultiplatformPackage(buildMultiplePlatforms("multiplatform/simple"), "multiplatform/simple")
- }
-
- @Test fun multiplePlatformsMerge() {
- verifyMultiplatformPackage(buildMultiplePlatforms("multiplatform/merge"), "multiplatform/merge")
- }
-
- @Test fun multiplePlatformsMergeMembers() {
- val module = buildMultiplePlatforms("multiplatform/mergeMembers")
- verifyModelOutput(module, ".md", "testdata/format/multiplatform/mergeMembers/foo.kt") { model, output ->
- 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 ->
- 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 ->
- 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,
- noStdlibLink = true,
- languageVersion = null,
- apiVersion = null
- )
- appendDocumentation(module, contentRootFromPath("testdata/format/$path/jvm.kt"), defaultPlatforms = listOf("JVM"), withKotlinRuntime = true, options = options)
- verifyMultiplatformIndex(module, path)
- verifyMultiplatformPackage(module, path)
- }
-
- @Test fun multiplePlatformsPackagePlatformFromMembers() {
- val path = "multiplatform/packagePlatformsFromMembers"
- val module = buildMultiplePlatforms(path)
- verifyMultiplatformIndex(module, path)
- verifyMultiplatformPackage(module, path)
- }
-
- @Test fun multiplePlatformsGroupNode() {
- val path = "multiplatform/groupNode"
- val module = buildMultiplePlatforms(path)
- verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.kt") { model, output ->
- buildPagesAndReadInto(
- listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }),
- output
- )
- }
- verifyMultiplatformPackage(module, path)
- }
-
- @Test fun multiplePlatformsBreadcrumbsInMemberOfMemberOfGroupNode() {
- val path = "multiplatform/breadcrumbsInMemberOfMemberOfGroupNode"
- val module = buildMultiplePlatforms(path)
- verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.kt") { model, output ->
- buildPagesAndReadInto(
- listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }?.member(NodeKind.Class)?.member(NodeKind.Function)),
- output
- )
- }
- }
-
- @Test fun linksInEmphasis() {
- verifyMarkdownNode("linksInEmphasis")
- }
-
- @Test fun linksInStrong() {
- verifyMarkdownNode("linksInStrong")
- }
-
- @Test fun linksInHeaders() {
- verifyMarkdownNode("linksInHeaders")
- }
-
- @Test fun tokensInEmphasis() {
- verifyMarkdownNode("tokensInEmphasis")
- }
-
- @Test fun tokensInStrong() {
- verifyMarkdownNode("tokensInStrong")
- }
-
- @Test fun tokensInHeaders() {
- verifyMarkdownNode("tokensInHeaders")
- }
-
- @Test fun unorderedLists() {
- verifyMarkdownNode("unorderedLists")
- }
-
- @Test fun nestedLists() {
- verifyMarkdownNode("nestedLists")
- }
-
- @Test fun referenceLink() {
- verifyMarkdownNode("referenceLink")
- }
-
- @Test fun externalReferenceLink() {
- verifyMarkdownNode("externalReferenceLink")
- }
-
- @Test fun newlineInTableCell() {
- verifyMarkdownPackage("newlineInTableCell")
- }
-
- @Test fun indentedCodeBlock() {
- verifyMarkdownNode("indentedCodeBlock")
- }
-
- @Test fun receiverReference() {
- verifyMarkdownNode("receiverReference")
- }
-
- @Test fun extensionScope() {
- verifyMarkdownNodeByName("extensionScope", "test")
- }
-
- @Test fun typeParameterReference() {
- verifyMarkdownNode("typeParameterReference")
- }
-
- @Test fun notPublishedTypeAliasAutoExpansion() {
- verifyMarkdownNodeByName("notPublishedTypeAliasAutoExpansion", "foo", includeNonPublic = false)
- }
-
- @Test fun companionImplements() {
- verifyMarkdownNodeByName("companionImplements", "Foo")
- }
-
- private fun buildMultiplePlatforms(path: String): DocumentationModule {
- val module = DocumentationModule("test")
- val options = DocumentationOptions(
- outputDir = "",
- outputFormat = "html",
- generateIndexPages = false,
- noStdlibLink = 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)
- return module
- }
-
- private fun verifyMultiplatformPackage(module: DocumentationModule, path: String) {
- verifyModelOutput(module, ".package.md", "testdata/format/$path/multiplatform.kt") { model, output ->
- buildPagesAndReadInto(model.members, output)
- }
- }
-
- private fun verifyMultiplatformIndex(module: DocumentationModule, path: String) {
- verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.index.kt") {
- model, output ->
- val service = MarkdownFormatService(fileGenerator, KotlinLanguageService(), listOf())
- fileGenerator.formatService = service
- buildPagesAndReadInto(listOf(model), output)
- }
- }
-
- @Test fun blankLineInsideCodeBlock() {
- verifyMarkdownNode("blankLineInsideCodeBlock")
- }
-
- private fun verifyMarkdownPackage(fileName: String, withKotlinRuntime: Boolean = false) {
- verifyOutput("testdata/format/$fileName.kt", ".package.md", withKotlinRuntime = withKotlinRuntime) { model, output ->
- buildPagesAndReadInto(model.members, output)
- }
- }
-
- private fun verifyMarkdownNode(fileName: String, withKotlinRuntime: Boolean = false) {
- verifyMarkdownNodes(fileName, withKotlinRuntime) { model -> model.members.single().members }
- }
-
- private fun verifyMarkdownNodes(
- fileName: String,
- withKotlinRuntime: Boolean = false,
- includeNonPublic: Boolean = true,
- nodeFilter: (DocumentationModule) -> List<DocumentationNode>
- ) {
- verifyOutput(
- "testdata/format/$fileName.kt",
- ".md",
- withKotlinRuntime = withKotlinRuntime,
- includeNonPublic = includeNonPublic
- ) { model, output ->
- buildPagesAndReadInto(nodeFilter(model), output)
- }
- }
-
- private fun verifyJavaMarkdownNode(fileName: String, withKotlinRuntime: Boolean = false) {
- verifyJavaMarkdownNodes(fileName, withKotlinRuntime) { 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 ->
- buildPagesAndReadInto(nodeFilter(model), output)
- }
- }
-
- private fun verifyMarkdownNodeByName(
- fileName: String,
- name: String,
- withKotlinRuntime: Boolean = false,
- includeNonPublic: Boolean = true
- ) {
- verifyMarkdownNodes(fileName, withKotlinRuntime, includeNonPublic) { model->
- val nodesWithName = model.members.single().members.filter { it.name == name }
- if (nodesWithName.isEmpty()) {
- throw IllegalArgumentException("Found no nodes named $name")
- }
- nodesWithName
- }
- }
-}
diff --git a/core/src/test/kotlin/format/PackageDocsTest.kt b/core/src/test/kotlin/format/PackageDocsTest.kt
deleted file mode 100644
index 704f7b998..000000000
--- a/core/src/test/kotlin/format/PackageDocsTest.kt
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.jetbrains.dokka.tests.format
-
-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.assertEqualsIgnoringSeparators
-import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
-import org.junit.Assert.assertEquals
-import org.junit.Test
-import java.io.File
-
-class PackageDocsTest {
- @Test fun verifyParse() {
- val docs = PackageDocs(null, DokkaConsoleLogger)
- docs.parse("testdata/packagedocs/stdlib.md", emptyList())
- val packageContent = docs.packageContent["kotlin"]!!
- val block = (packageContent.children.single() as ContentBlock).children.first() as ContentText
- assertEquals("Core functions and types", block.text)
- }
-
- @Test fun testReferenceLinksInPackageDocs() {
- val mockLinkResolver = mock<DeclarationLinkResolver> {
- val exampleCom = "http://example.com"
- on { tryResolveContentLink(any(), eq(exampleCom)) } doAnswer { ContentExternalLink(exampleCom) }
- }
-
- val mockPackageDescriptor = mock<PackageFragmentDescriptor> {}
-
- val docs = PackageDocs(mockLinkResolver, DokkaConsoleLogger)
- docs.parse("testdata/packagedocs/referenceLinks.md", listOf(mockPackageDescriptor))
-
- checkMarkdownOutput(docs, "testdata/packagedocs/referenceLinks")
- }
-
- fun checkMarkdownOutput(docs: PackageDocs, expectedFilePrefix: String) {
-
- val generator = FileGenerator(File(""))
-
- val out = StringBuilder()
- 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)
- assertEqualsIgnoringSeparators(expectedFile, out.toString())
- out.setLength(0)
- }
-
- checkOutput(docs.moduleContent, ".module.md")
-
- docs.packageContent.forEach {
- (name, content) ->
- checkOutput(content, ".$name.md")
- }
-
- }
-}