diff options
Diffstat (limited to 'test/src/format')
-rw-r--r-- | test/src/format/HtmlFormatTest.kt | 52 | ||||
-rw-r--r-- | test/src/format/MarkdownFormatTest.kt | 113 | ||||
-rw-r--r-- | test/src/format/PackageDocsTest.kt | 18 |
3 files changed, 125 insertions, 58 deletions
diff --git a/test/src/format/HtmlFormatTest.kt b/test/src/format/HtmlFormatTest.kt index b7fef79f..66fd0fee 100644 --- a/test/src/format/HtmlFormatTest.kt +++ b/test/src/format/HtmlFormatTest.kt @@ -11,37 +11,37 @@ import java.io.File public class HtmlFormatTest { private val htmlService = HtmlFormatService(InMemoryLocationService, KotlinLanguageService(), HtmlTemplateService.default()) - Test fun classWithCompanionObject() { + @Test fun classWithCompanionObject() { verifyOutput("test/data/format/classWithCompanionObject.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun htmlEscaping() { + @Test fun htmlEscaping() { verifyOutput("test/data/format/htmlEscaping.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun overloads() { + @Test fun overloads() { verifyOutput("test/data/format/overloads.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members) } } - Test fun overloadsWithDescription() { + @Test fun overloadsWithDescription() { verifyOutput("test/data/format/overloadsWithDescription.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun overloadsWithDifferentDescriptions() { + @Test fun overloadsWithDifferentDescriptions() { verifyOutput("test/data/format/overloadsWithDifferentDescriptions.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun deprecated() { + @Test fun deprecated() { verifyOutput("test/data/format/deprecated.kt", ".package.html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members) } @@ -50,85 +50,85 @@ public class HtmlFormatTest { } } - Test fun brokenLink() { + @Test fun brokenLink() { verifyOutput("test/data/format/brokenLink.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun codeSpan() { + @Test fun codeSpan() { verifyOutput("test/data/format/codeSpan.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun parenthesis() { + @Test fun parenthesis() { verifyOutput("test/data/format/parenthesis.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun bracket() { + @Test fun bracket() { verifyOutput("test/data/format/bracket.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun see() { + @Test fun see() { verifyOutput("test/data/format/see.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun tripleBackticks() { + @Test fun tripleBackticks() { verifyOutput("test/data/format/tripleBackticks.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun typeLink() { + @Test fun typeLink() { verifyOutput("test/data/format/typeLink.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar"} ) } } - Test fun parameterAnchor() { + @Test fun parameterAnchor() { verifyOutput("test/data/format/parameterAnchor.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaSupertypeLink() { + @Test fun javaSupertypeLink() { verifyOutput("test/data/format/javaSupertype.java", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members.single { it.name == "C"}.members.filter { it.name == "Bar"} ) } } - Test fun javaLinkTag() { - verifyOutput("test/data/format/javaLinkTag.java", ".html") { model, output -> + @Test fun javaLinkTag() { + verifyOutput("test/data/format/javaLinkTag.java", ".html", withJdk = true) { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaLinkTagWithLabel() { - verifyOutput("test/data/format/javaLinkTagWithLabel.java", ".html") { model, output -> + @Test fun javaLinkTagWithLabel() { + verifyOutput("test/data/format/javaLinkTagWithLabel.java", ".html", withJdk = true) { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaSeeTag() { - verifyOutput("test/data/format/javaSeeTag.java", ".html") { model, output -> + @Test fun javaSeeTag() { + verifyOutput("test/data/format/javaSeeTag.java", ".html", withJdk = true) { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaDeprecated() { + @Test fun javaDeprecated() { verifyOutput("test/data/format/javaDeprecated.java", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members.single { it.name == "Foo" }.members.filter { it.name == "foo" }) } } - Test fun crossLanguageKotlinExtendsJava() { + @Test fun crossLanguageKotlinExtendsJava() { verifyOutput(arrayOf(KotlinSourceRoot("test/data/format/crossLanguage/kotlinExtendsJava/Bar.kt"), JavaSourceRoot(File("test/data/format/crossLanguage/kotlinExtendsJava"))), ".html") { model, output -> @@ -136,19 +136,19 @@ public class HtmlFormatTest { } } - Test fun orderedList() { + @Test fun orderedList() { verifyOutput("test/data/format/orderedList.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) } } - Test fun linkWithLabel() { + @Test fun linkWithLabel() { verifyOutput("test/data/format/linkWithLabel.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) } } - Test fun entity() { + @Test fun entity() { verifyOutput("test/data/format/entity.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) } diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index 059b491b..bb61fa1c 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -1,42 +1,43 @@ package org.jetbrains.dokka.tests +import org.jetbrains.dokka.KotlinLanguageService +import org.jetbrains.dokka.MarkdownFormatService import org.junit.Test -import org.jetbrains.dokka.* public class MarkdownFormatTest { private val markdownService = MarkdownFormatService(InMemoryLocationService, KotlinLanguageService()) - Test fun emptyDescription() { + @Test fun emptyDescription() { verifyOutput("test/data/format/emptyDescription.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun classWithCompanionObject() { + @Test fun classWithCompanionObject() { verifyOutput("test/data/format/classWithCompanionObject.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun annotations() { + @Test fun annotations() { verifyOutput("test/data/format/annotations.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun annotationClass() { + @Test fun annotationClass() { verifyOutput("test/data/format/annotationClass.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun annotationParams() { - verifyOutput("test/data/format/annotationParams.kt", ".md") { model, output -> + @Test fun annotationParams() { + verifyOutput("test/data/format/annotationParams.kt", ".md", withKotlinRuntime = true) { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun extensions() { + @Test fun extensions() { verifyOutput("test/data/format/extensions.kt", ".package.md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members) } @@ -45,7 +46,7 @@ public class MarkdownFormatTest { } } - Test fun enumClass() { + @Test fun enumClass() { verifyOutput("test/data/format/enumClass.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } @@ -56,13 +57,13 @@ public class MarkdownFormatTest { } } - Test fun varargsFunction() { + @Test fun varargsFunction() { verifyOutput("test/data/format/varargsFunction.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun overridingFunction() { + @Test fun overridingFunction() { verifyOutput("test/data/format/overridingFunction.kt", ".md") { model, output -> val classMembers = model.members.single().members.first { it.name == "D" }.members markdownService.appendNodes(tempLocation, output, classMembers.filter { it.name == "f" }) @@ -70,100 +71,148 @@ public class MarkdownFormatTest { } - Test fun propertyVar() { + @Test fun propertyVar() { verifyOutput("test/data/format/propertyVar.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun functionWithDefaultParameter() { + @Test fun functionWithDefaultParameter() { verifyOutput("test/data/format/functionWithDefaultParameter.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun accessor() { + @Test fun accessor() { verifyOutput("test/data/format/accessor.kt", ".md") { model, output -> val propertyNode = model.members.single().members.first { it.name == "C" }.members.filter { it.name == "x" } markdownService.appendNodes(tempLocation, output, propertyNode) } } - Test fun paramTag() { + @Test fun paramTag() { verifyOutput("test/data/format/paramTag.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun throwsTag() { + @Test fun throwsTag() { verifyOutput("test/data/format/throwsTag.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun typeParameterBounds() { + @Test fun typeParameterBounds() { verifyOutput("test/data/format/typeParameterBounds.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun typeParameterVariance() { + @Test fun typeParameterVariance() { verifyOutput("test/data/format/typeParameterVariance.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun typeProjectionVariance() { + @Test fun typeProjectionVariance() { verifyOutput("test/data/format/typeProjectionVariance.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javadocHtml() { - verifyOutput("test/data/format/javadocHtml.java", ".md") { model, output -> + @Test fun javadocHtml() { + verifyOutput("test/data/format/javadocHtml.java", ".md", withJdk = true) { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaCodeLiteralTags() { - verifyOutput("test/data/format/javaCodeLiteralTags.java", ".md") { model, output -> + @Test fun javaCodeLiteralTags() { + verifyOutput("test/data/format/javaCodeLiteralTags.java", ".md", withJdk = true) { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaCodeInParam() { - verifyOutput("test/data/format/javaCodeInParam.java", ".md") { model, output -> + @Test fun javaCodeInParam() { + verifyOutput("test/data/format/javaCodeInParam.java", ".md", withJdk = true) { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaSpaceInAuthor() { - verifyOutput("test/data/format/javaSpaceInAuthor.java", ".md") { model, output -> + @Test fun javaSpaceInAuthor() { + verifyOutput("test/data/format/javaSpaceInAuthor.java", ".md", withJdk = true) { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun nullability() { + @Test fun nullability() { verifyOutput("test/data/format/nullability.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun operatorOverloading() { + @Test fun operatorOverloading() { verifyOutput("test/data/format/operatorOverloading.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members.single { it.name == "C" }.members.filter { it.name == "plus" }) } } - Test fun javadocOrderedList() { - verifyOutput("test/data/format/javadocOrderedList.java", ".md") { model, output -> + @Test fun javadocOrderedList() { + verifyOutput("test/data/format/javadocOrderedList.java", ".md", withJdk = true) { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) } } - Test fun companionObjectExtension() { + @Test fun companionObjectExtension() { verifyOutput("test/data/format/companionObjectExtension.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Foo" }) } } + + @Test fun starProjection() { + verifyOutput("test/data/format/starProjection.kt", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members) + } + } + + @Test fun extensionFunctionParameter() { + verifyOutput("test/data/format/extensionFunctionParameter.kt", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members) + } + } + + @Test fun summarizeSignatures() { + verifyOutput("test/data/format/summarizeSignatures.kt", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members) + } + } + + @Test fun summarizeSignaturesProperty() { + verifyOutput("test/data/format/summarizeSignaturesProperty.kt", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members) + } + } + + @Test fun reifiedTypeParameter() { + verifyOutput("test/data/format/reifiedTypeParameter.kt", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members) + } + } + + @Test fun annotatedTypeParameter() { + verifyOutput("test/data/format/annotatedTypeParameter.kt", ".md", withKotlinRuntime = true) { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members) + } + } + + @Test fun inheritedMembers() { + verifyOutput("test/data/format/inheritedMembers.kt", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) + } + } + + @Test fun inheritedExtensions() { + verifyOutput("test/data/format/inheritedExtensions.kt", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) + } + } } diff --git a/test/src/format/PackageDocsTest.kt b/test/src/format/PackageDocsTest.kt new file mode 100644 index 00000000..6815de6f --- /dev/null +++ b/test/src/format/PackageDocsTest.kt @@ -0,0 +1,18 @@ +package org.jetbrains.dokka.tests.format + +import org.jetbrains.dokka.ContentBlock +import org.jetbrains.dokka.ContentText +import org.jetbrains.dokka.DokkaConsoleLogger +import org.jetbrains.dokka.PackageDocs +import org.junit.Test +import kotlin.test.assertEquals + +public class PackageDocsTest { + @Test fun verifyParse() { + val docs = PackageDocs(null, null, DokkaConsoleLogger) + docs.parse("test/data/packagedocs/stdlib.md") + val packageContent = docs.packageContent["kotlin"]!! + val block = (packageContent.children.single() as ContentBlock).children.first() as ContentText + assertEquals("Core functions and types", block.text) + } +} |