From 7acc52ba723eab08fe796fcfd68755e7f0eb6a66 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Sat, 2 Dec 2017 00:50:08 +0300 Subject: WIP: Refactoring, remove LocationService, rework FormatDescriptor --- core/src/test/kotlin/TestAPI.kt | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'core/src/test') diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt index ff8a5260..aa3eff48 100644 --- a/core/src/test/kotlin/TestAPI.kt +++ b/core/src/test/kotlin/TestAPI.kt @@ -270,21 +270,6 @@ fun ContentNode.toTestString(): String { }.toString() } -class InMemoryLocation(override val path: String): Location { - override fun relativePathTo(other: Location, anchor: String?): String = - if (anchor != null) other.path + "#" + anchor else other.path -} - -object InMemoryLocationService: LocationService { - override fun location(qualifiedName: List, hasMembers: Boolean) = - InMemoryLocation(relativePathToNode(qualifiedName, hasMembers)) - - override val root: Location - get() = InMemoryLocation("") -} - -val tempLocation = InMemoryLocation("") - val ContentRoot.path: String get() = when(this) { is KotlinSourceRoot -> path -- cgit From e126ff625eba33d91b3242a4e6e951d1e9f94080 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Sat, 2 Dec 2017 05:59:01 +0300 Subject: Update tests to new reality --- core/src/test/kotlin/TestAPI.kt | 11 +++++ core/src/test/kotlin/format/GFMFormatTest.kt | 19 ++++++-- core/src/test/kotlin/format/HtmlFormatTest.kt | 21 +++++--- .../test/kotlin/format/KotlinWebSiteFormatTest.kt | 21 ++++++-- .../kotlin/format/KotlinWebSiteHtmlFormatTest.kt | 16 +++++-- .../KotlinWebSiteRunnableSamplesFormatTest.kt | 56 +++++++++++----------- core/src/test/kotlin/format/MarkdownFormatTest.kt | 52 ++++++++++++-------- core/src/test/kotlin/format/PackageDocsTest.kt | 13 +++-- 8 files changed, 140 insertions(+), 69 deletions(-) (limited to 'core/src/test') diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt index aa3eff48..4cd11390 100644 --- a/core/src/test/kotlin/TestAPI.kt +++ b/core/src/test/kotlin/TestAPI.kt @@ -276,3 +276,14 @@ val ContentRoot.path: String is JavaSourceRoot -> file.path else -> throw UnsupportedOperationException() } + + +val TestFileGenerator = FileGenerator(createTempDir()) + +fun FileGenerator.buildPagesAndReadInto(nodes: List, sb: StringBuilder) { + buildPages(nodes) + nodes.forEach { + val fileForNode = TestFileGenerator.location(it).file + sb.append(fileForNode.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..f5b833f6 100644 --- a/core/src/test/kotlin/format/GFMFormatTest.kt +++ b/core/src/test/kotlin/format/GFMFormatTest.kt @@ -2,22 +2,33 @@ package org.jetbrains.dokka.tests import org.jetbrains.dokka.GFMFormatService import org.jetbrains.dokka.KotlinLanguageService +import org.junit.Before import org.junit.Test class GFMFormatTest { - private val gfmService = GFMFormatService(InMemoryLocationService, KotlinLanguageService(), listOf()) + private val gfmService = GFMFormatService(TestFileGenerator, KotlinLanguageService(), listOf()) - @Test fun sample() { + @Before + fun prepareFileGenerator() { + TestFileGenerator.formatService = gfmService + } + + @Test + fun sample() { verifyGFMNodeByName("sample", "Foo") } - @Test fun listInTableCell() { + @Test + fun listInTableCell() { verifyGFMNodeByName("listInTableCell", "Foo") } 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 }) + TestFileGenerator.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 index 01e4559e..4906fbfa 100644 --- a/core/src/test/kotlin/format/HtmlFormatTest.kt +++ b/core/src/test/kotlin/format/HtmlFormatTest.kt @@ -3,11 +3,17 @@ 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()) + private val htmlService = HtmlFormatService(TestFileGenerator, KotlinLanguageService(), HtmlTemplateService.default(), listOf()) + + @Before + fun prepareFileGenerator() { + TestFileGenerator.formatService = htmlService + } @Test fun classWithCompanionObject() { verifyHtmlNode("classWithCompanionObject") @@ -31,10 +37,10 @@ class HtmlFormatTest { @Test fun deprecated() { verifyOutput("testdata/format/deprecated.kt", ".package.html") { model, output -> - htmlService.createOutputBuilder(output, tempLocation).appendNodes(model.members) + TestFileGenerator.buildPagesAndReadInto(model.members, output) } verifyOutput("testdata/format/deprecated.kt", ".class.html") { model, output -> - htmlService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members) + TestFileGenerator.buildPagesAndReadInto(model.members.single().members, output) } } @@ -102,7 +108,10 @@ class HtmlFormatTest { 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" }) + TestFileGenerator.buildPagesAndReadInto( + model.members.single().members.filter { it.name == "Bar" }, + output + ) } } @@ -158,7 +167,7 @@ class HtmlFormatTest { withKotlinRuntime: Boolean = false, nodeFilter: (DocumentationModule) -> List) { verifyOutput("testdata/format/$fileName.kt", ".html", withKotlinRuntime = withKotlinRuntime) { model, output -> - htmlService.createOutputBuilder(output, tempLocation).appendNodes(nodeFilter(model)) + TestFileGenerator.buildPagesAndReadInto(nodeFilter(model), output) } } @@ -170,7 +179,7 @@ class HtmlFormatTest { withKotlinRuntime: Boolean = false, nodeFilter: (DocumentationModule) -> List) { verifyJavaOutput("testdata/format/$fileName.java", ".html", withKotlinRuntime = withKotlinRuntime) { model, output -> - htmlService.createOutputBuilder(output, tempLocation).appendNodes(nodeFilter(model)) + TestFileGenerator.buildPagesAndReadInto(nodeFilter(model), output) } } } diff --git a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt index af44b048..b3ea82b7 100644 --- a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt +++ b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt @@ -1,12 +1,19 @@ package org.jetbrains.dokka.tests import org.jetbrains.dokka.* +import org.junit.Before import org.junit.Ignore import org.junit.Test @Ignore class KotlinWebSiteFormatTest { - private val kwsService = KotlinWebsiteFormatService(InMemoryLocationService, KotlinLanguageService(), listOf(), DokkaConsoleLogger) + private val kwsService = KotlinWebsiteFormatService(TestFileGenerator, KotlinLanguageService(), listOf(), DokkaConsoleLogger) + + @Before + fun prepareFileGenerator() { + TestFileGenerator.formatService = kwsService + } + @Test fun sample() { verifyKWSNodeByName("sample", "foo") @@ -29,14 +36,20 @@ 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 })) + TestFileGenerator.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 }) + TestFileGenerator.buildPagesAndReadInto( + model.members.single().members.filter { it.name == name }, + output + ) } } @@ -58,7 +71,7 @@ class KotlinWebSiteFormatTest { 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) + TestFileGenerator.buildPagesAndReadInto(model.members, output) } } diff --git a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt index 433c9c13..8c94fdcb 100644 --- a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt +++ b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt @@ -1,11 +1,16 @@ package org.jetbrains.dokka.tests import org.jetbrains.dokka.* +import org.junit.Before import org.junit.Test class KotlinWebSiteHtmlFormatTest { - private val kwsService = KotlinWebsiteHtmlFormatService(InMemoryLocationService, KotlinLanguageService(), listOf()) + private val kwsService = KotlinWebsiteHtmlFormatService(TestFileGenerator, KotlinLanguageService(), listOf(), EmptyHtmlTemplateService) + @Before + fun prepareFileGenerator() { + TestFileGenerator.formatService = kwsService + } @Test fun dropImport() { verifyKWSNodeByName("dropImport", "foo") @@ -44,14 +49,17 @@ 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 })) + TestFileGenerator.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 }) + TestFileGenerator.buildPagesAndReadInto(model.members.single().members.filter { it.name == name }, output) } } @@ -73,7 +81,7 @@ class KotlinWebSiteHtmlFormatTest { 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) + TestFileGenerator.buildPagesAndReadInto(model.members, output) } } 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..e273f6c1 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -1,10 +1,16 @@ package org.jetbrains.dokka.tests import org.jetbrains.dokka.* +import org.junit.Before import org.junit.Test class MarkdownFormatTest { - private val markdownService = MarkdownFormatService(InMemoryLocationService, KotlinLanguageService(), listOf()) + private val markdownService = MarkdownFormatService(TestFileGenerator, KotlinLanguageService(), listOf()) + + @Before + fun prepareFileGenerator() { + TestFileGenerator.formatService = markdownService + } @Test fun emptyDescription() { verifyMarkdownNode("emptyDescription") @@ -34,21 +40,23 @@ class MarkdownFormatTest { @Test fun extensions() { verifyOutput("testdata/format/extensions.kt", ".package.md") { model, output -> - markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members) + TestFileGenerator.buildPagesAndReadInto(model.members, output) } verifyOutput("testdata/format/extensions.kt", ".class.md") { model, output -> - markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members) + TestFileGenerator.buildPagesAndReadInto(model.members.single().members, output) } } @Test fun enumClass() { verifyOutput("testdata/format/enumClass.kt", ".md") { model, output -> - markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members) + TestFileGenerator.buildPagesAndReadInto(model.members.single().members, output) } verifyOutput("testdata/format/enumClass.kt", ".value.md") { model, output -> val enumClassNode = model.members.single().members[0] - markdownService.createOutputBuilder(output, tempLocation).appendNodes( - enumClassNode.members.filter { it.name == "LOCAL_CONTINUE_AND_BREAK" }) + TestFileGenerator.buildPagesAndReadInto( + enumClassNode.members.filter { it.name == "LOCAL_CONTINUE_AND_BREAK" }, + output + ) } } @@ -282,22 +290,22 @@ 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) + TestFileGenerator.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) + TestFileGenerator.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) +// MarkdownFormatService(InMemoryLocationService, KotlinLanguageService(), listOf("JVM", "JS")) +// .createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members) } } @@ -328,8 +336,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 })) + TestFileGenerator.buildPagesAndReadInto( + listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }), + output + ) } verifyMultiplatformPackage(module, path) } @@ -338,8 +348,10 @@ 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))) + TestFileGenerator.buildPagesAndReadInto( + listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }?.member(NodeKind.Class)?.member(NodeKind.Function)), + output + ) } } @@ -428,15 +440,15 @@ class MarkdownFormatTest { 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) + TestFileGenerator.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)) +// MarkdownFormatService(InMemoryLocationService, KotlinLanguageService(), listOf()) +// .createOutputBuilder(output, tempLocation).appendNodes(listOf(model)) } } @@ -446,7 +458,7 @@ class MarkdownFormatTest { 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) + TestFileGenerator.buildPagesAndReadInto(model.members, output) } } @@ -466,7 +478,7 @@ class MarkdownFormatTest { withKotlinRuntime = withKotlinRuntime, includeNonPublic = includeNonPublic ) { model, output -> - markdownService.createOutputBuilder(output, tempLocation).appendNodes(nodeFilter(model)) + TestFileGenerator.buildPagesAndReadInto(nodeFilter(model), output) } } @@ -476,7 +488,7 @@ class MarkdownFormatTest { private fun verifyJavaMarkdownNodes(fileName: String, withKotlinRuntime: Boolean = false, nodeFilter: (DocumentationModule) -> List) { verifyJavaOutput("testdata/format/$fileName.java", ".md", withKotlinRuntime = withKotlinRuntime) { model, output -> - markdownService.createOutputBuilder(output, tempLocation).appendNodes(nodeFilter(model)) + TestFileGenerator.buildPagesAndReadInto(nodeFilter(model), output) } } diff --git a/core/src/test/kotlin/format/PackageDocsTest.kt b/core/src/test/kotlin/format/PackageDocsTest.kt index a5547025..067ff775 100644 --- a/core/src/test/kotlin/format/PackageDocsTest.kt +++ b/core/src/test/kotlin/format/PackageDocsTest.kt @@ -5,14 +5,14 @@ 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.TestFileGenerator 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 -public class PackageDocsTest { +class PackageDocsTest { @Test fun verifyParse() { val docs = PackageDocs(null, DokkaConsoleLogger) docs.parse("testdata/packagedocs/stdlib.md", emptyList()) @@ -38,7 +38,14 @@ public class PackageDocsTest { fun checkMarkdownOutput(docs: PackageDocs, expectedFilePrefix: String) { val out = StringBuilder() - val outputBuilder = MarkdownOutputBuilder(out, InMemoryLocationService.root, InMemoryLocationService, KotlinLanguageService(), ".md", emptyList()) + val outputBuilder = MarkdownOutputBuilder( + out, + FileLocation(TestFileGenerator.root), + TestFileGenerator, + KotlinLanguageService(), + ".md", + emptyList() + ) fun checkOutput(content: Content, filePostfix: String) { outputBuilder.appendContent(content) val expectedFile = File(expectedFilePrefix + filePostfix) -- cgit From 3098b8e7665bcda25f8ead2496c161e10512d7b3 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 4 Dec 2017 18:12:01 +0300 Subject: Introduce test case with preset FileGenerator --- core/src/test/kotlin/TestAPI.kt | 11 -------- .../test/kotlin/format/FileGeneratorTestCase.kt | 31 ++++++++++++++++++++ core/src/test/kotlin/format/GFMFormatTest.kt | 12 ++------ core/src/test/kotlin/format/HtmlFormatTest.kt | 19 +++++-------- .../test/kotlin/format/KotlinWebSiteFormatTest.kt | 16 ++++------- .../kotlin/format/KotlinWebSiteHtmlFormatTest.kt | 15 ++++------ core/src/test/kotlin/format/MarkdownFormatTest.kt | 33 +++++++++------------- core/src/test/kotlin/format/PackageDocsTest.kt | 7 +++-- 8 files changed, 69 insertions(+), 75 deletions(-) create mode 100644 core/src/test/kotlin/format/FileGeneratorTestCase.kt (limited to 'core/src/test') diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt index 4cd11390..aa3eff48 100644 --- a/core/src/test/kotlin/TestAPI.kt +++ b/core/src/test/kotlin/TestAPI.kt @@ -276,14 +276,3 @@ val ContentRoot.path: String is JavaSourceRoot -> file.path else -> throw UnsupportedOperationException() } - - -val TestFileGenerator = FileGenerator(createTempDir()) - -fun FileGenerator.buildPagesAndReadInto(nodes: List, sb: StringBuilder) { - buildPages(nodes) - nodes.forEach { - val fileForNode = TestFileGenerator.location(it).file - sb.append(fileForNode.readText()) - } -} \ No newline at end of file diff --git a/core/src/test/kotlin/format/FileGeneratorTestCase.kt b/core/src/test/kotlin/format/FileGeneratorTestCase.kt new file mode 100644 index 00000000..7f6d6f3f --- /dev/null +++ b/core/src/test/kotlin/format/FileGeneratorTestCase.kt @@ -0,0 +1,31 @@ +package org.jetbrains.dokka.tests + +import org.jetbrains.dokka.DocumentationNode +import org.jetbrains.dokka.FileGenerator +import org.jetbrains.dokka.FormatService +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, sb: StringBuilder) = with(fileGenerator) { + buildPages(nodes) + nodes.forEach { + val fileForNode = location(it).file + sb.append(fileForNode.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 f5b833f6..b90ab2bf 100644 --- a/core/src/test/kotlin/format/GFMFormatTest.kt +++ b/core/src/test/kotlin/format/GFMFormatTest.kt @@ -2,16 +2,10 @@ package org.jetbrains.dokka.tests import org.jetbrains.dokka.GFMFormatService import org.jetbrains.dokka.KotlinLanguageService -import org.junit.Before import org.junit.Test -class GFMFormatTest { - private val gfmService = GFMFormatService(TestFileGenerator, KotlinLanguageService(), listOf()) - - @Before - fun prepareFileGenerator() { - TestFileGenerator.formatService = gfmService - } +class GFMFormatTest : FileGeneratorTestCase() { + override val formatService = GFMFormatService(fileGenerator, KotlinLanguageService(), listOf()) @Test fun sample() { @@ -25,7 +19,7 @@ class GFMFormatTest { private fun verifyGFMNodeByName(fileName: String, name: String) { verifyOutput("testdata/format/gfm/$fileName.kt", ".md") { model, output -> - TestFileGenerator.buildPagesAndReadInto( + 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 index 4906fbfa..54c367fd 100644 --- a/core/src/test/kotlin/format/HtmlFormatTest.kt +++ b/core/src/test/kotlin/format/HtmlFormatTest.kt @@ -7,13 +7,8 @@ import org.junit.Before import org.junit.Test import java.io.File -class HtmlFormatTest { - private val htmlService = HtmlFormatService(TestFileGenerator, KotlinLanguageService(), HtmlTemplateService.default(), listOf()) - - @Before - fun prepareFileGenerator() { - TestFileGenerator.formatService = htmlService - } +class HtmlFormatTest: FileGeneratorTestCase() { + override val formatService = HtmlFormatService(fileGenerator, KotlinLanguageService(), HtmlTemplateService.default(), listOf()) @Test fun classWithCompanionObject() { verifyHtmlNode("classWithCompanionObject") @@ -37,10 +32,10 @@ class HtmlFormatTest { @Test fun deprecated() { verifyOutput("testdata/format/deprecated.kt", ".package.html") { model, output -> - TestFileGenerator.buildPagesAndReadInto(model.members, output) + buildPagesAndReadInto(model.members, output) } verifyOutput("testdata/format/deprecated.kt", ".class.html") { model, output -> - TestFileGenerator.buildPagesAndReadInto(model.members.single().members, output) + buildPagesAndReadInto(model.members.single().members, output) } } @@ -108,7 +103,7 @@ class HtmlFormatTest { verifyOutput(arrayOf(KotlinSourceRoot("testdata/format/crossLanguage/kotlinExtendsJava/Bar.kt"), JavaSourceRoot(File("testdata/format/crossLanguage/kotlinExtendsJava"), null)), ".html") { model, output -> - TestFileGenerator.buildPagesAndReadInto( + buildPagesAndReadInto( model.members.single().members.filter { it.name == "Bar" }, output ) @@ -167,7 +162,7 @@ class HtmlFormatTest { withKotlinRuntime: Boolean = false, nodeFilter: (DocumentationModule) -> List) { verifyOutput("testdata/format/$fileName.kt", ".html", withKotlinRuntime = withKotlinRuntime) { model, output -> - TestFileGenerator.buildPagesAndReadInto(nodeFilter(model), output) + buildPagesAndReadInto(nodeFilter(model), output) } } @@ -179,7 +174,7 @@ class HtmlFormatTest { withKotlinRuntime: Boolean = false, nodeFilter: (DocumentationModule) -> List) { verifyJavaOutput("testdata/format/$fileName.java", ".html", withKotlinRuntime = withKotlinRuntime) { model, output -> - TestFileGenerator.buildPagesAndReadInto(nodeFilter(model), output) + buildPagesAndReadInto(nodeFilter(model), output) } } } diff --git a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt index b3ea82b7..b971b54d 100644 --- a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt +++ b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt @@ -6,14 +6,8 @@ import org.junit.Ignore import org.junit.Test @Ignore -class KotlinWebSiteFormatTest { - private val kwsService = KotlinWebsiteFormatService(TestFileGenerator, KotlinLanguageService(), listOf(), DokkaConsoleLogger) - - @Before - fun prepareFileGenerator() { - TestFileGenerator.formatService = kwsService - } - +class KotlinWebSiteFormatTest: FileGeneratorTestCase() { + override val formatService = KotlinWebsiteFormatService(fileGenerator, KotlinLanguageService(), listOf(), DokkaConsoleLogger) @Test fun sample() { verifyKWSNodeByName("sample", "foo") @@ -36,7 +30,7 @@ class KotlinWebSiteFormatTest { val path = "dataTagsInGroupNode" val module = buildMultiplePlatforms(path) verifyModelOutput(module, ".md", "testdata/format/website/$path/multiplatform.kt") { model, output -> - TestFileGenerator.buildPagesAndReadInto( + buildPagesAndReadInto( listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }), output ) @@ -46,7 +40,7 @@ class KotlinWebSiteFormatTest { private fun verifyKWSNodeByName(fileName: String, name: String) { verifyOutput("testdata/format/website/$fileName.kt", ".md", format = "kotlin-website") { model, output -> - TestFileGenerator.buildPagesAndReadInto( + buildPagesAndReadInto( model.members.single().members.filter { it.name == name }, output ) @@ -71,7 +65,7 @@ class KotlinWebSiteFormatTest { private fun verifyMultiplatformPackage(module: DocumentationModule, path: String) { verifyModelOutput(module, ".package.md", "testdata/format/website/$path/multiplatform.kt") { model, output -> - TestFileGenerator.buildPagesAndReadInto(model.members, output) + buildPagesAndReadInto(model.members, output) } } diff --git a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt index 8c94fdcb..49fa6d2f 100644 --- a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt +++ b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt @@ -4,13 +4,8 @@ import org.jetbrains.dokka.* import org.junit.Before import org.junit.Test -class KotlinWebSiteHtmlFormatTest { - private val kwsService = KotlinWebsiteHtmlFormatService(TestFileGenerator, KotlinLanguageService(), listOf(), EmptyHtmlTemplateService) - - @Before - fun prepareFileGenerator() { - TestFileGenerator.formatService = kwsService - } +class KotlinWebSiteHtmlFormatTest: FileGeneratorTestCase() { + override val formatService = KotlinWebsiteHtmlFormatService(fileGenerator, KotlinLanguageService(), listOf(), EmptyHtmlTemplateService) @Test fun dropImport() { verifyKWSNodeByName("dropImport", "foo") @@ -49,7 +44,7 @@ class KotlinWebSiteHtmlFormatTest { val path = "dataTagsInGroupNode" val module = buildMultiplePlatforms(path) verifyModelOutput(module, ".html", "testdata/format/website-html/$path/multiplatform.kt") { model, output -> - TestFileGenerator.buildPagesAndReadInto( + buildPagesAndReadInto( listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }), output ) @@ -59,7 +54,7 @@ class KotlinWebSiteHtmlFormatTest { private fun verifyKWSNodeByName(fileName: String, name: String) { verifyOutput("testdata/format/website-html/$fileName.kt", ".html", format = "kotlin-website-html") { model, output -> - TestFileGenerator.buildPagesAndReadInto(model.members.single().members.filter { it.name == name }, output) + buildPagesAndReadInto(model.members.single().members.filter { it.name == name }, output) } } @@ -81,7 +76,7 @@ class KotlinWebSiteHtmlFormatTest { private fun verifyMultiplatformPackage(module: DocumentationModule, path: String) { verifyModelOutput(module, ".package.html", "testdata/format/website-html/$path/multiplatform.kt") { model, output -> - TestFileGenerator.buildPagesAndReadInto(model.members, output) + buildPagesAndReadInto(model.members, output) } } diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index e273f6c1..b0e2a985 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -4,13 +4,8 @@ import org.jetbrains.dokka.* import org.junit.Before import org.junit.Test -class MarkdownFormatTest { - private val markdownService = MarkdownFormatService(TestFileGenerator, KotlinLanguageService(), listOf()) - - @Before - fun prepareFileGenerator() { - TestFileGenerator.formatService = markdownService - } +class MarkdownFormatTest: FileGeneratorTestCase() { + override val formatService = MarkdownFormatService(fileGenerator, KotlinLanguageService(), listOf()) @Test fun emptyDescription() { verifyMarkdownNode("emptyDescription") @@ -40,20 +35,20 @@ class MarkdownFormatTest { @Test fun extensions() { verifyOutput("testdata/format/extensions.kt", ".package.md") { model, output -> - TestFileGenerator.buildPagesAndReadInto(model.members, output) + buildPagesAndReadInto(model.members, output) } verifyOutput("testdata/format/extensions.kt", ".class.md") { model, output -> - TestFileGenerator.buildPagesAndReadInto(model.members.single().members, output) + buildPagesAndReadInto(model.members.single().members, output) } } @Test fun enumClass() { verifyOutput("testdata/format/enumClass.kt", ".md") { model, output -> - TestFileGenerator.buildPagesAndReadInto(model.members.single().members, output) + buildPagesAndReadInto(model.members.single().members, output) } verifyOutput("testdata/format/enumClass.kt", ".value.md") { model, output -> val enumClassNode = model.members.single().members[0] - TestFileGenerator.buildPagesAndReadInto( + buildPagesAndReadInto( enumClassNode.members.filter { it.name == "LOCAL_CONTINUE_AND_BREAK" }, output ) @@ -290,14 +285,14 @@ class MarkdownFormatTest { @Test fun multiplePlatformsMergeMembers() { val module = buildMultiplePlatforms("multiplatform/mergeMembers") verifyModelOutput(module, ".md", "testdata/format/multiplatform/mergeMembers/foo.kt") { model, output -> - TestFileGenerator.buildPagesAndReadInto(model.members.single().members, 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 -> - TestFileGenerator.buildPagesAndReadInto(model.members.single().members, output) + buildPagesAndReadInto(model.members.single().members, output) } } @@ -336,7 +331,7 @@ class MarkdownFormatTest { val path = "multiplatform/groupNode" val module = buildMultiplePlatforms(path) verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.kt") { model, output -> - TestFileGenerator.buildPagesAndReadInto( + buildPagesAndReadInto( listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }), output ) @@ -348,7 +343,7 @@ class MarkdownFormatTest { val path = "multiplatform/breadcrumbsInMemberOfMemberOfGroupNode" val module = buildMultiplePlatforms(path) verifyModelOutput(module, ".md", "testdata/format/$path/multiplatform.kt") { model, output -> - TestFileGenerator.buildPagesAndReadInto( + buildPagesAndReadInto( listOfNotNull(model.members.single().members.find { it.kind == NodeKind.GroupNode }?.member(NodeKind.Class)?.member(NodeKind.Function)), output ) @@ -440,7 +435,7 @@ class MarkdownFormatTest { private fun verifyMultiplatformPackage(module: DocumentationModule, path: String) { verifyModelOutput(module, ".package.md", "testdata/format/$path/multiplatform.kt") { model, output -> - TestFileGenerator.buildPagesAndReadInto(model.members, output) + buildPagesAndReadInto(model.members, output) } } @@ -458,7 +453,7 @@ class MarkdownFormatTest { private fun verifyMarkdownPackage(fileName: String, withKotlinRuntime: Boolean = false) { verifyOutput("testdata/format/$fileName.kt", ".package.md", withKotlinRuntime = withKotlinRuntime) { model, output -> - TestFileGenerator.buildPagesAndReadInto(model.members, output) + buildPagesAndReadInto(model.members, output) } } @@ -478,7 +473,7 @@ class MarkdownFormatTest { withKotlinRuntime = withKotlinRuntime, includeNonPublic = includeNonPublic ) { model, output -> - TestFileGenerator.buildPagesAndReadInto(nodeFilter(model), output) + buildPagesAndReadInto(nodeFilter(model), output) } } @@ -488,7 +483,7 @@ class MarkdownFormatTest { private fun verifyJavaMarkdownNodes(fileName: String, withKotlinRuntime: Boolean = false, nodeFilter: (DocumentationModule) -> List) { verifyJavaOutput("testdata/format/$fileName.java", ".md", withKotlinRuntime = withKotlinRuntime) { model, output -> - TestFileGenerator.buildPagesAndReadInto(nodeFilter(model), output) + buildPagesAndReadInto(nodeFilter(model), output) } } diff --git a/core/src/test/kotlin/format/PackageDocsTest.kt b/core/src/test/kotlin/format/PackageDocsTest.kt index 067ff775..704f7b99 100644 --- a/core/src/test/kotlin/format/PackageDocsTest.kt +++ b/core/src/test/kotlin/format/PackageDocsTest.kt @@ -5,7 +5,6 @@ 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.TestFileGenerator import org.jetbrains.dokka.tests.assertEqualsIgnoringSeparators import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor import org.junit.Assert.assertEquals @@ -37,11 +36,13 @@ class PackageDocsTest { fun checkMarkdownOutput(docs: PackageDocs, expectedFilePrefix: String) { + val generator = FileGenerator(File("")) + val out = StringBuilder() val outputBuilder = MarkdownOutputBuilder( out, - FileLocation(TestFileGenerator.root), - TestFileGenerator, + FileLocation(generator.root), + generator, KotlinLanguageService(), ".md", emptyList() -- cgit From 7aa5b52a7e8cd69a384ef29aeeb199061b92584f Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 5 Dec 2017 16:01:39 +0300 Subject: Check file path in testData, when more then one node --- core/src/test/kotlin/format/FileGeneratorTestCase.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'core/src/test') diff --git a/core/src/test/kotlin/format/FileGeneratorTestCase.kt b/core/src/test/kotlin/format/FileGeneratorTestCase.kt index 7f6d6f3f..6d70292f 100644 --- a/core/src/test/kotlin/format/FileGeneratorTestCase.kt +++ b/core/src/test/kotlin/format/FileGeneratorTestCase.kt @@ -3,6 +3,7 @@ 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 @@ -23,9 +24,12 @@ abstract class FileGeneratorTestCase { fun buildPagesAndReadInto(nodes: List, sb: StringBuilder) = with(fileGenerator) { buildPages(nodes) - nodes.forEach { - val fileForNode = location(it).file - sb.append(fileForNode.readText()) + val byLocations = nodes.groupBy { location(it) } + byLocations.forEach { (loc, _) -> + if (byLocations.size > 1) { + sb.appendln("") + } + sb.append(loc.file.readText()) } } } \ No newline at end of file -- cgit From b209ddcfc2d532f4dc5e508e00d89335fdb15caa Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 5 Dec 2017 18:16:04 +0300 Subject: Append line before file path in testData --- core/src/test/kotlin/format/FileGeneratorTestCase.kt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'core/src/test') diff --git a/core/src/test/kotlin/format/FileGeneratorTestCase.kt b/core/src/test/kotlin/format/FileGeneratorTestCase.kt index 6d70292f..644d5baa 100644 --- a/core/src/test/kotlin/format/FileGeneratorTestCase.kt +++ b/core/src/test/kotlin/format/FileGeneratorTestCase.kt @@ -27,6 +27,9 @@ abstract class FileGeneratorTestCase { val byLocations = nodes.groupBy { location(it) } byLocations.forEach { (loc, _) -> if (byLocations.size > 1) { + if (sb.isNotBlank() && !sb.endsWith('\n')) { + sb.appendln() + } sb.appendln("") } sb.append(loc.file.readText()) -- cgit From 1bd0f642248e09cfa95fa19bf5a38316606401a2 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 5 Dec 2017 18:16:40 +0300 Subject: Uncomment and fix some special case tests --- core/src/test/kotlin/format/MarkdownFormatTest.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'core/src/test') diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index b0e2a985..f60969fc 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -299,8 +299,9 @@ class MarkdownFormatTest: FileGeneratorTestCase() { @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) } } @@ -442,8 +443,9 @@ class MarkdownFormatTest: FileGeneratorTestCase() { 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) } } -- cgit From dbd4774ffae19ff4d52cd21c7cb3906cdc3e0b5c Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 15 Dec 2017 01:00:32 +0300 Subject: Normalize file path's when using as URI --- core/src/main/kotlin/Formats/HtmlTemplateService.kt | 2 +- core/src/main/kotlin/Locations/Location.kt | 10 ++++++---- core/src/test/kotlin/format/FileGeneratorTestCase.kt | 7 ++----- 3 files changed, 9 insertions(+), 10 deletions(-) (limited to 'core/src/test') diff --git a/core/src/main/kotlin/Formats/HtmlTemplateService.kt b/core/src/main/kotlin/Formats/HtmlTemplateService.kt index 84e01910..a65a7b18 100644 --- a/core/src/main/kotlin/Formats/HtmlTemplateService.kt +++ b/core/src/main/kotlin/Formats/HtmlTemplateService.kt @@ -24,7 +24,7 @@ interface HtmlTemplateService { to.appendln("$title") } if (css != null) { - val cssPath = basePath.resolve(css) + val cssPath = basePath.resolve(css).toUnixString() to.appendln("") } to.appendln("") diff --git a/core/src/main/kotlin/Locations/Location.kt b/core/src/main/kotlin/Locations/Location.kt index 17538ff5..0e6572d9 100644 --- a/core/src/main/kotlin/Locations/Location.kt +++ b/core/src/main/kotlin/Locations/Location.kt @@ -13,8 +13,8 @@ interface Location { * $file: [File] for this location * $path: [String] representing path of this location */ -data class FileLocation(val file: File): Location { - override val path : String +data class FileLocation(val file: File) : Location { + override val path: String get() = file.path override fun relativePathTo(other: Location, anchor: String?): String { @@ -30,7 +30,6 @@ data class FileLocation(val file: File): Location { } } - fun relativePathToNode(qualifiedName: List, hasMembers: Boolean): String { val parts = qualifiedName.map { identifierToFilename(it) }.filterNot { it.isEmpty() } return if (!hasMembers) { @@ -41,6 +40,7 @@ fun relativePathToNode(qualifiedName: List, hasMembers: Boolean): String } } + fun relativePathToNode(node: DocumentationNode) = relativePathToNode(node.path.map { it.name }, node.members.any()) fun identifierToFilename(path: String): String { @@ -56,4 +56,6 @@ fun NodeLocationAwareGenerator.relativePathToLocation(owner: DocumentationNode, fun NodeLocationAwareGenerator.relativeToRoot(from: Location): File { val file = File(from.path) return file.relativeTo(root) -} \ No newline at end of file +} + +fun File.toUnixString() = toString().replace(File.separatorChar, '/') diff --git a/core/src/test/kotlin/format/FileGeneratorTestCase.kt b/core/src/test/kotlin/format/FileGeneratorTestCase.kt index 644d5baa..948426ea 100644 --- a/core/src/test/kotlin/format/FileGeneratorTestCase.kt +++ b/core/src/test/kotlin/format/FileGeneratorTestCase.kt @@ -1,9 +1,6 @@ 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.jetbrains.dokka.* import org.junit.Before import org.junit.Rule import org.junit.rules.TemporaryFolder @@ -30,7 +27,7 @@ abstract class FileGeneratorTestCase { if (sb.isNotBlank() && !sb.endsWith('\n')) { sb.appendln() } - sb.appendln("") + sb.appendln("") } sb.append(loc.file.readText()) } -- cgit