diff options
author | aleksZubakov <aleks.zubakov@gmail.com> | 2018-07-12 15:37:18 +0300 |
---|---|---|
committer | aleksZubakov <aleks.zubakov@gmail.com> | 2018-07-12 15:37:18 +0300 |
commit | 960ea9ebb01f280c4966e139c1697f083e9d8965 (patch) | |
tree | 05bb14e7faf1b74a0abf89f69a73023b4373eefd /core/src/test/kotlin/format | |
parent | 65b61e31b761071589e257381bea33557d932412 (diff) | |
download | dokka-960ea9ebb01f280c4966e139c1697f083e9d8965.tar.gz dokka-960ea9ebb01f280c4966e139c1697f083e9d8965.tar.bz2 dokka-960ea9ebb01f280c4966e139c1697f083e9d8965.zip |
Test refactoring and split by different platforms
Diffstat (limited to 'core/src/test/kotlin/format')
-rw-r--r-- | core/src/test/kotlin/format/BaseHtmlFormatTest.kt | 146 | ||||
-rw-r--r-- | core/src/test/kotlin/format/BaseMarkdownFormatTest.kt (renamed from core/src/test/kotlin/format/MarkdownFormatTest.kt) | 284 | ||||
-rw-r--r-- | core/src/test/kotlin/format/HtmlFormatTest.kt | 181 | ||||
-rw-r--r-- | core/src/test/kotlin/format/JSHtmlFormatTest.kt | 6 | ||||
-rw-r--r-- | core/src/test/kotlin/format/JSMarkdownFormatTest.kt | 7 | ||||
-rw-r--r-- | core/src/test/kotlin/format/JVMHtmlFormatTest.kt | 54 | ||||
-rw-r--r-- | core/src/test/kotlin/format/JVMMarkdownFormatTest.kt | 117 | ||||
-rw-r--r-- | core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt | 27 | ||||
-rw-r--r-- | core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt | 25 |
9 files changed, 484 insertions, 363 deletions
diff --git a/core/src/test/kotlin/format/BaseHtmlFormatTest.kt b/core/src/test/kotlin/format/BaseHtmlFormatTest.kt new file mode 100644 index 00000000..7fd331cf --- /dev/null +++ b/core/src/test/kotlin/format/BaseHtmlFormatTest.kt @@ -0,0 +1,146 @@ +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 + +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", defaultModelConfig) + } + + @Test fun htmlEscaping() { + verifyHtmlNode("htmlEscaping", defaultModelConfig) + } + + @Test fun overloads() { + verifyHtmlNodes("overloads", defaultModelConfig) { model -> model.members } + } + + @Test fun overloadsWithDescription() { + verifyHtmlNode("overloadsWithDescription", defaultModelConfig) + } + + @Test fun overloadsWithDifferentDescriptions() { + verifyHtmlNode("overloadsWithDifferentDescriptions", defaultModelConfig) + } + + @Test fun deprecated() { + verifyOutput("testdata/format/deprecated.kt", ".package.html", defaultModelConfig) { model, output -> + buildPagesAndReadInto(model.members, output) + } + verifyOutput("testdata/format/deprecated.kt", ".class.html", defaultModelConfig) { model, output -> + buildPagesAndReadInto(model.members.single().members, output) + } + } + + @Test fun brokenLink() { + verifyHtmlNode("brokenLink", defaultModelConfig) + } + + @Test fun codeSpan() { + verifyHtmlNode("codeSpan", defaultModelConfig) + } + + @Test fun parenthesis() { + verifyHtmlNode("parenthesis", defaultModelConfig) + } + + @Test fun bracket() { + verifyHtmlNode("bracket", defaultModelConfig) + } + + @Test fun see() { + verifyHtmlNode("see", defaultModelConfig) + } + + @Test fun tripleBackticks() { + verifyHtmlNode("tripleBackticks", defaultModelConfig) + } + + @Test fun typeLink() { + verifyHtmlNodes("typeLink", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Bar" } } + } + + @Test fun parameterAnchor() { + verifyHtmlNode("parameterAnchor", defaultModelConfig) + } + + @Test fun codeBlock() { + verifyHtmlNode("codeBlock", defaultModelConfig) + } + @Test fun orderedList() { + verifyHtmlNodes("orderedList", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Bar" } } + } + + @Test fun linkWithLabel() { + verifyHtmlNodes("linkWithLabel", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Bar" } } + } + + @Test fun entity() { + verifyHtmlNodes("entity", defaultModelConfig) { model -> model.members.single().members.filter { it.name == "Bar" } } + } + + @Test fun uninterpretedEmphasisCharacters() { + verifyHtmlNode("uninterpretedEmphasisCharacters", defaultModelConfig) + } + + @Test fun markdownInLinks() { + verifyHtmlNode("markdownInLinks", defaultModelConfig) + } + + @Test fun returnWithLink() { + verifyHtmlNode("returnWithLink", defaultModelConfig) + } + + @Test fun linkWithStarProjection() { + verifyHtmlNode("linkWithStarProjection", ModelConfig(analysisPlatform = analysisPlatform, withKotlinRuntime = true)) + } + + @Test fun functionalTypeWithNamedParameters() { + verifyHtmlNode("functionalTypeWithNamedParameters", defaultModelConfig) + } + + @Test fun sinceKotlin() { + verifyHtmlNode("sinceKotlin", defaultModelConfig) + } + + @Test fun blankLineInsideCodeBlock() { + verifyHtmlNode("blankLineInsideCodeBlock", defaultModelConfig) + } + + @Test fun indentedCodeBlock() { + verifyHtmlNode("indentedCodeBlock", defaultModelConfig) + } + + private fun verifyHtmlNode(fileName: String, modelConfig: ModelConfig = ModelConfig()) { + verifyHtmlNodes(fileName, modelConfig) { model -> model.members.single().members } + } + + private fun verifyHtmlNodes(fileName: String, + modelConfig: ModelConfig = ModelConfig(), + nodeFilter: (DocumentationModule) -> List<DocumentationNode>) { + 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) + } + } +} + diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/BaseMarkdownFormatTest.kt index 9e4c831d..5612b1fd 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/BaseMarkdownFormatTest.kt @@ -4,49 +4,33 @@ import org.jetbrains.dokka.* import org.junit.Before import org.junit.Test -class MarkdownFormatTest: FileGeneratorTestCase() { +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 -> - buildPagesAndReadInto(model.members, output) - } - verifyOutput("testdata/format/extensions.kt", ".class.md") { model, output -> - buildPagesAndReadInto(model.members.single().members, output) - } + 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 -> + 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] buildPagesAndReadInto( enumClassNode.members.filter { it.name == "LOCAL_CONTINUE_AND_BREAK" }, @@ -56,222 +40,179 @@ class MarkdownFormatTest: FileGeneratorTestCase() { } @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() { @@ -316,7 +257,13 @@ class MarkdownFormatTest: FileGeneratorTestCase() { languageVersion = null, apiVersion = null ) - appendDocumentation(module, contentRootFromPath("testdata/format/$path/jvm.kt"), defaultPlatforms = listOf("JVM"), withKotlinRuntime = true, options = options) + appendDocumentation(module, options, ModelConfig( + roots = arrayOf(contentRootFromPath("testdata/format/$path/jvm.kt")), + defaultPlatforms = listOf("JVM"), + withKotlinRuntime = true, + analysisPlatform = analysisPlatform + ) + ) verifyMultiplatformIndex(module, path) verifyMultiplatformPackage(module, path) } @@ -352,91 +299,74 @@ class MarkdownFormatTest: FileGeneratorTestCase() { } @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") - } - - @Test fun enumRef() { - verifyMarkdownNode("enumRef") - } - - @Test fun inheritedLink() { - val filePath = "testdata/format/inheritedLink" - verifyOutput( - arrayOf( - contentRootFromPath("$filePath.kt"), - contentRootFromPath("$filePath.1.kt") - ), - ".md", - withJdk = true, - withKotlinRuntime = true, - includeNonPublic = false - ) { model, output -> - buildPagesAndReadInto(model.members.single { it.name == "p2" }.members.single().members, output) - } + verifyMarkdownNodeByName("companionImplements", "Foo", defaultModelConfig) } @@ -450,8 +380,21 @@ class MarkdownFormatTest: FileGeneratorTestCase() { 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) + appendDocumentation( + module, options, ModelConfig( + roots = arrayOf(contentRootFromPath("testdata/format/$path/jvm.kt")), + defaultPlatforms = listOf("JVM"), + analysisPlatform = Platform.jvm + ) + ) + appendDocumentation( + module, options, ModelConfig( + roots = arrayOf(contentRootFromPath("testdata/format/$path/js.kt")), + defaultPlatforms = listOf("JS"), + analysisPlatform = Platform.js + ) + ) + return module } @@ -471,52 +414,49 @@ class MarkdownFormatTest: FileGeneratorTestCase() { } @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 -> + 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 -> 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 -> + 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") diff --git a/core/src/test/kotlin/format/HtmlFormatTest.kt b/core/src/test/kotlin/format/HtmlFormatTest.kt deleted file mode 100644 index 54c367fd..00000000 --- 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/JSHtmlFormatTest.kt b/core/src/test/kotlin/format/JSHtmlFormatTest.kt new file mode 100644 index 00000000..afa0ce0a --- /dev/null +++ b/core/src/test/kotlin/format/JSHtmlFormatTest.kt @@ -0,0 +1,6 @@ +package org.jetbrains.dokka.tests.format + +import org.jetbrains.dokka.Platform +import org.jetbrains.dokka.tests.BaseHtmlFormatTest + +class JSHtmlFormatTest: BaseHtmlFormatTest(Platform.js) {}
\ No newline at end of file diff --git a/core/src/test/kotlin/format/JSMarkdownFormatTest.kt b/core/src/test/kotlin/format/JSMarkdownFormatTest.kt new file mode 100644 index 00000000..ca92d9f6 --- /dev/null +++ b/core/src/test/kotlin/format/JSMarkdownFormatTest.kt @@ -0,0 +1,7 @@ +package org.jetbrains.dokka.tests.format + +import org.jetbrains.dokka.Platform +import org.jetbrains.dokka.tests.BaseMarkdownFormatTest + +class JSMarkdownFormatTest: BaseMarkdownFormatTest(Platform.js) { +}
\ No newline at end of file diff --git a/core/src/test/kotlin/format/JVMHtmlFormatTest.kt b/core/src/test/kotlin/format/JVMHtmlFormatTest.kt new file mode 100644 index 00000000..1696ffb2 --- /dev/null +++ b/core/src/test/kotlin/format/JVMHtmlFormatTest.kt @@ -0,0 +1,54 @@ +package org.jetbrains.dokka.tests.format + +import org.jetbrains.dokka.Platform +import org.jetbrains.dokka.tests.BaseHtmlFormatTest +import org.jetbrains.dokka.tests.ModelConfig +import org.jetbrains.dokka.tests.verifyOutput +import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot +import org.jetbrains.kotlin.config.KotlinSourceRoot +import org.junit.Test +import java.io.File + +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 + ) + } + } + + @Test fun javaLinkTag() { + verifyJavaHtmlNode("javaLinkTag", defaultModelConfig) + } + + @Test fun javaLinkTagWithLabel() { + verifyJavaHtmlNode("javaLinkTagWithLabel", defaultModelConfig) + } + + @Test fun javaSupertypeLink() { + verifyJavaHtmlNodes("JavaSupertype", defaultModelConfig) { model -> + model.members.single().members.single { it.name == "JavaSupertype" }.members.filter { it.name == "Bar" } + } + } + +}
\ No newline at end of file diff --git a/core/src/test/kotlin/format/JVMMarkdownFormatTest.kt b/core/src/test/kotlin/format/JVMMarkdownFormatTest.kt new file mode 100644 index 00000000..ee8169af --- /dev/null +++ b/core/src/test/kotlin/format/JVMMarkdownFormatTest.kt @@ -0,0 +1,117 @@ +package org.jetbrains.dokka.tests.format + +import org.jetbrains.dokka.Platform +import org.jetbrains.dokka.contentRootFromPath +import org.jetbrains.dokka.tests.BaseMarkdownFormatTest +import org.jetbrains.dokka.tests.ModelConfig +import org.jetbrains.dokka.tests.verifyOutput +import org.junit.Test + +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) + } +} diff --git a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt index b971b54d..224769e6 100644 --- a/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt +++ b/core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt @@ -1,7 +1,6 @@ package org.jetbrains.dokka.tests import org.jetbrains.dokka.* -import org.junit.Before import org.junit.Ignore import org.junit.Test @@ -39,7 +38,7 @@ class KotlinWebSiteFormatTest: FileGeneratorTestCase() { } private fun verifyKWSNodeByName(fileName: String, name: String) { - verifyOutput("testdata/format/website/$fileName.kt", ".md", format = "kotlin-website") { model, output -> + verifyOutput("testdata/format/website/$fileName.kt", ".md", ModelConfig(format = "kotlin-website")) { model, output -> buildPagesAndReadInto( model.members.single().members.filter { it.name == name }, output @@ -57,9 +56,27 @@ class KotlinWebSiteFormatTest: FileGeneratorTestCase() { 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) + appendDocumentation( + module, options, ModelConfig( + roots = arrayOf(contentRootFromPath("testdata/format/website/$path/jvm.kt")), + defaultPlatforms = listOf("JVM") + ) + + ) + + + appendDocumentation( + module, options, ModelConfig( + roots = arrayOf(contentRootFromPath("testdata/format/website/$path/jre7.kt")), + defaultPlatforms = listOf("JVM", "JRE7") + ) + ) + appendDocumentation( + module, options, ModelConfig( + roots = arrayOf(contentRootFromPath("testdata/format/website/$path/js.kt")), + defaultPlatforms = listOf("JS") + ) + ) return module } diff --git a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt index 49fa6d2f..c02d3ad4 100644 --- a/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt +++ b/core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt @@ -1,7 +1,6 @@ package org.jetbrains.dokka.tests import org.jetbrains.dokka.* -import org.junit.Before import org.junit.Test class KotlinWebSiteHtmlFormatTest: FileGeneratorTestCase() { @@ -53,7 +52,7 @@ class KotlinWebSiteHtmlFormatTest: FileGeneratorTestCase() { } private fun verifyKWSNodeByName(fileName: String, name: String) { - verifyOutput("testdata/format/website-html/$fileName.kt", ".html", format = "kotlin-website-html") { model, output -> + verifyOutput("testdata/format/website-html/$fileName.kt", ".html", ModelConfig(format = "kotlin-website-html")) { model, output -> buildPagesAndReadInto(model.members.single().members.filter { it.name == name }, output) } } @@ -68,9 +67,25 @@ class KotlinWebSiteHtmlFormatTest: FileGeneratorTestCase() { 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) + appendDocumentation( + module, options, ModelConfig( + roots = arrayOf(contentRootFromPath("testdata/format/website-html/$path/jvm.kt")), + defaultPlatforms = listOf("JVM") + ) + ) + appendDocumentation( + module, options, ModelConfig( + roots = arrayOf(contentRootFromPath("testdata/format/website-html/$path/jre7.kt")), + defaultPlatforms = listOf("JVM", "JRE7") + ) + ) + appendDocumentation( + module, options, ModelConfig( + roots = arrayOf(contentRootFromPath("testdata/format/website-html/$path/js.kt")), + defaultPlatforms = listOf("JS") + ) + ) + return module } |