From ef51f7e2466e28db0943d528b6b489aefd098c0d Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 30 Dec 2014 16:34:08 +0100 Subject: annotations work in progress --- test/data/classes/annotatedClass.kt | 1 + test/data/format/annotations.kt | 4 +++ test/data/format/annotations.md | 0 test/data/functions/annotatedFunction.kt | 2 ++ test/data/functions/functionWithAnnotatedParam.kt | 2 ++ test/data/properties/annotatedProperty.kt | 1 + test/src/format/MarkdownFormatTest.kt | 6 +++++ test/src/model/ClassTest.kt | 14 +++++++++++ test/src/model/FunctionTest.kt | 30 ++++++++++++++++++++++- test/src/model/PropertyTest.kt | 13 ++++++++++ 10 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 test/data/classes/annotatedClass.kt create mode 100644 test/data/format/annotations.kt create mode 100644 test/data/format/annotations.md create mode 100644 test/data/functions/annotatedFunction.kt create mode 100644 test/data/functions/functionWithAnnotatedParam.kt create mode 100644 test/data/properties/annotatedProperty.kt (limited to 'test') diff --git a/test/data/classes/annotatedClass.kt b/test/data/classes/annotatedClass.kt new file mode 100644 index 00000000..62c6f0ec --- /dev/null +++ b/test/data/classes/annotatedClass.kt @@ -0,0 +1 @@ +data class Foo() {} diff --git a/test/data/format/annotations.kt b/test/data/format/annotations.kt new file mode 100644 index 00000000..445ec969 --- /dev/null +++ b/test/data/format/annotations.kt @@ -0,0 +1,4 @@ +data class Foo { + inline fun bar() { + } +} diff --git a/test/data/format/annotations.md b/test/data/format/annotations.md new file mode 100644 index 00000000..e69de29b diff --git a/test/data/functions/annotatedFunction.kt b/test/data/functions/annotatedFunction.kt new file mode 100644 index 00000000..11c19672 --- /dev/null +++ b/test/data/functions/annotatedFunction.kt @@ -0,0 +1,2 @@ +inline fun f() { +} diff --git a/test/data/functions/functionWithAnnotatedParam.kt b/test/data/functions/functionWithAnnotatedParam.kt new file mode 100644 index 00000000..8922f765 --- /dev/null +++ b/test/data/functions/functionWithAnnotatedParam.kt @@ -0,0 +1,2 @@ +fun function([noinline] notInlined: () -> Unit) { +} diff --git a/test/data/properties/annotatedProperty.kt b/test/data/properties/annotatedProperty.kt new file mode 100644 index 00000000..f70c28b4 --- /dev/null +++ b/test/data/properties/annotatedProperty.kt @@ -0,0 +1 @@ +inline val property = "test" \ No newline at end of file diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index 5cdfb8b5..e9852964 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -19,4 +19,10 @@ public class MarkdownFormatTest { markdownService.appendNodes(tempLocation, output, model.members.single().members) } } + + Test fun annotations() { + verifyOutput("test/data/format/annotations.kt") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members) + } + } } diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt index b95a31dc..b9be30bf 100644 --- a/test/src/model/ClassTest.kt +++ b/test/src/model/ClassTest.kt @@ -167,3 +167,17 @@ public class ClassTest { } } } + + Test fun annotatedClass() { + verifyModel("test/data/classes/annotatedClass.kt") { model -> + with(model.members.single().members.single()) { + assertEquals(1, annotations.count()) + with(annotations[0]) { + assertEquals("data", name) + assertEquals(Content.Empty, content) + assertEquals(DocumentationNode.Kind.Annotation, kind) + } + } + } + } +} diff --git a/test/src/model/FunctionTest.kt b/test/src/model/FunctionTest.kt index 2a4ad0a5..d3d7843a 100644 --- a/test/src/model/FunctionTest.kt +++ b/test/src/model/FunctionTest.kt @@ -135,4 +135,32 @@ Documentation""", content.description.toTestString()) } } } -} \ No newline at end of file + + Test fun annotatedFunction() { + verifyModel("test/data/functions/annotatedFunction.kt") { model -> + with(model.members.single().members.single()) { + assertEquals(1, annotations.count()) + with(annotations[0]) { + assertEquals("inline", name) + assertEquals(Content.Empty, content) + assertEquals(DocumentationNode.Kind.Annotation, kind) + } + } + } + } + + Test fun functionWithAnnotatedParam() { + verifyModel("test/data/functions/functionWithAnnotatedParam.kt") { model -> + with(model.members.single().members.single()) { + with(details.elementAt(2)) { + assertEquals(1, annotations.count()) + with(annotations[0]) { + assertEquals("noinline", name) + assertEquals(Content.Empty, content) + assertEquals(DocumentationNode.Kind.Annotation, kind) + } + } + } + } + } +} diff --git a/test/src/model/PropertyTest.kt b/test/src/model/PropertyTest.kt index 103da170..0bf9714d 100644 --- a/test/src/model/PropertyTest.kt +++ b/test/src/model/PropertyTest.kt @@ -99,4 +99,17 @@ public class PropertyTest { } } } + + Test fun annotatedProperty() { + verifyModel("test/data/properties/annotatedProperty.kt") { model -> + with(model.members.single().members.single()) { + assertEquals(1, annotations.count()) + with(annotations[0]) { + assertEquals("inline", name) + assertEquals(Content.Empty, content) + assertEquals(DocumentationNode.Kind.Annotation, kind) + } + } + } + } } -- cgit From 0e70fa4ca021bff09e7d9ce64269a4e698512af5 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 30 Dec 2014 16:59:34 +0100 Subject: render annotations --- test/data/format/annotations.kt | 4 +++- test/data/format/annotations.md | 30 ++++++++++++++++++++++++++++++ test/src/format/MarkdownFormatTest.kt | 2 +- test/src/model/ClassTest.kt | 1 - 4 files changed, 34 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/data/format/annotations.kt b/test/data/format/annotations.kt index 445ec969..9356d4ca 100644 --- a/test/data/format/annotations.kt +++ b/test/data/format/annotations.kt @@ -1,4 +1,6 @@ data class Foo { - inline fun bar() { + inline fun bar([noinline] notInlined: () -> Unit) { } + + inline val x: Int } diff --git a/test/data/format/annotations.md b/test/data/format/annotations.md index e69de29b..83f79397 100644 --- a/test/data/format/annotations.md +++ b/test/data/format/annotations.md @@ -0,0 +1,30 @@ +[test](out.md) / [](out.md) / [Foo](out.md) + + +# Foo + + +``` +data class Foo +``` + + + + +### Constructors + + +| [<init>](out.md) | `public Foo()` | + + +### Properties + + +| [x](out.md) | `inline val x: Int` | + + +### Functions + + +| [bar](out.md) | `inline fun bar(noinline notInlined: () -> Unit): Unit` | + diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index e9852964..531980de 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -21,7 +21,7 @@ public class MarkdownFormatTest { } Test fun annotations() { - verifyOutput("test/data/format/annotations.kt") { model, output -> + verifyOutput("test/data/format/annotations.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt index b9be30bf..257d73eb 100644 --- a/test/src/model/ClassTest.kt +++ b/test/src/model/ClassTest.kt @@ -166,7 +166,6 @@ public class ClassTest { } } } -} Test fun annotatedClass() { verifyModel("test/data/classes/annotatedClass.kt") { model -> -- cgit From 716483c2f20e4af1951342f2acc9a231fcbeab3b Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 30 Dec 2014 17:41:14 +0100 Subject: render annotation classes correctly --- test/data/format/annotationClass.kt | 1 + test/data/format/annotationClass.md | 18 ++++++++++++++++++ test/src/format/MarkdownFormatTest.kt | 6 ++++++ 3 files changed, 25 insertions(+) create mode 100644 test/data/format/annotationClass.kt create mode 100644 test/data/format/annotationClass.md (limited to 'test') diff --git a/test/data/format/annotationClass.kt b/test/data/format/annotationClass.kt new file mode 100644 index 00000000..89d494fb --- /dev/null +++ b/test/data/format/annotationClass.kt @@ -0,0 +1 @@ +annotation class fancy diff --git a/test/data/format/annotationClass.md b/test/data/format/annotationClass.md new file mode 100644 index 00000000..bfaa8581 --- /dev/null +++ b/test/data/format/annotationClass.md @@ -0,0 +1,18 @@ +[test](out.md) / [](out.md) / [fancy](out.md) + + +# fancy + + +``` +annotation class fancy +``` + + + + +### Constructors + + +| [<init>](out.md) | `public fancy()` | + diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index 531980de..a1fc7ac1 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -25,4 +25,10 @@ public class MarkdownFormatTest { markdownService.appendNodes(tempLocation, output, model.members.single().members) } } + + Test fun annotationClass() { + verifyOutput("test/data/format/annotationClass.kt", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members) + } + } } -- cgit From 69dd2988ec98a9fa027fcc805f28efbe8758d476 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 30 Dec 2014 18:47:03 +0100 Subject: support and render annotation parameters --- .../annotatedClassWithAnnotationParameters.kt | 1 + test/data/classes/javaAnnotationClass.kt | 5 +++ test/data/format/annotationParams.kt | 1 + test/data/format/annotationParams.md | 12 ++++++ .../annotatedFunctionWithAnnotationParameters.kt | 1 + test/src/TestAPI.kt | 3 ++ test/src/format/MarkdownFormatTest.kt | 6 +++ test/src/model/ClassTest.kt | 44 ++++++++++++++++++++++ test/src/model/FunctionTest.kt | 23 +++++++++++ 9 files changed, 96 insertions(+) create mode 100644 test/data/classes/annotatedClassWithAnnotationParameters.kt create mode 100644 test/data/classes/javaAnnotationClass.kt create mode 100644 test/data/format/annotationParams.kt create mode 100644 test/data/format/annotationParams.md create mode 100644 test/data/functions/annotatedFunctionWithAnnotationParameters.kt (limited to 'test') diff --git a/test/data/classes/annotatedClassWithAnnotationParameters.kt b/test/data/classes/annotatedClassWithAnnotationParameters.kt new file mode 100644 index 00000000..1af97e75 --- /dev/null +++ b/test/data/classes/annotatedClassWithAnnotationParameters.kt @@ -0,0 +1 @@ +deprecated("should no longer be used") class Foo() {} diff --git a/test/data/classes/javaAnnotationClass.kt b/test/data/classes/javaAnnotationClass.kt new file mode 100644 index 00000000..c5f5cac4 --- /dev/null +++ b/test/data/classes/javaAnnotationClass.kt @@ -0,0 +1,5 @@ +import java.lang.annotation.Retention +import java.lang.annotation.RetentionPolicy + +Retention(RetentionPolicy.SOURCE) +public annotation class throws() diff --git a/test/data/format/annotationParams.kt b/test/data/format/annotationParams.kt new file mode 100644 index 00000000..ee5b524a --- /dev/null +++ b/test/data/format/annotationParams.kt @@ -0,0 +1 @@ +inlineOptions(InlineOption.LOCAL_CONTINUE_AND_BREAK) fun f() {} diff --git a/test/data/format/annotationParams.md b/test/data/format/annotationParams.md new file mode 100644 index 00000000..6bbdc0e5 --- /dev/null +++ b/test/data/format/annotationParams.md @@ -0,0 +1,12 @@ +[test](out.md) / [](out.md) / [f](out.md) + + +# f + + +``` +inlineOptions([InlineOption.LOCAL_CONTINUE_AND_BREAK]) fun f(): Unit +``` + + + diff --git a/test/data/functions/annotatedFunctionWithAnnotationParameters.kt b/test/data/functions/annotatedFunctionWithAnnotationParameters.kt new file mode 100644 index 00000000..ee5b524a --- /dev/null +++ b/test/data/functions/annotatedFunctionWithAnnotationParameters.kt @@ -0,0 +1 @@ +inlineOptions(InlineOption.LOCAL_CONTINUE_AND_BREAK) fun f() {} diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt index cc09f001..af1b8e52 100644 --- a/test/src/TestAPI.kt +++ b/test/src/TestAPI.kt @@ -7,6 +7,7 @@ import org.jetbrains.dokka.* import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor import java.io.File import kotlin.test.assertEquals +import com.intellij.openapi.application.PathManager public fun verifyModel(vararg files: String, verifier: (DocumentationModule) -> Unit) { val messageCollector = object : MessageCollector { @@ -27,6 +28,8 @@ public fun verifyModel(vararg files: String, verifier: (DocumentationModule) -> } val environment = AnalysisEnvironment(messageCollector) { + val stringRoot = PathManager.getResourceRoot(javaClass(), "/java/lang/String.class") + addClasspath(File(stringRoot)) addSources(files.toList()) } diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index a1fc7ac1..08267d32 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -31,4 +31,10 @@ public class MarkdownFormatTest { markdownService.appendNodes(tempLocation, output, model.members.single().members) } } + + Test fun annotationParams() { + verifyOutput("test/data/format/annotationParams.kt", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members) + } + } } diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt index 257d73eb..ae82a4f1 100644 --- a/test/src/model/ClassTest.kt +++ b/test/src/model/ClassTest.kt @@ -179,4 +179,48 @@ public class ClassTest { } } } + + Test fun annotatedClassWithAnnotationParameters() { + verifyModel("test/data/classes/annotatedClassWithAnnotationParameters.kt") { model -> + with(model.members.single().members.single()) { + assertEquals(1, annotations.count()) + with(annotations[0]) { + assertEquals("deprecated", name) + assertEquals(Content.Empty, content) + assertEquals(DocumentationNode.Kind.Annotation, kind) + assertEquals(1, details.count()) + with(details[0]) { + assertEquals(DocumentationNode.Kind.Parameter, kind) + assertEquals(1, details.count()) + with(details[0]) { + assertEquals(DocumentationNode.Kind.Value, kind) + assertEquals("\"should no longer be used\"", name) + } + } + } + } + } + } + + Test fun javaAnnotationClass() { + verifyModel("test/data/classes/javaAnnotationClass.kt") { model -> + with(model.members.single().members.single()) { + assertEquals(1, annotations.count()) + with(annotations[0]) { + assertEquals("Retention", name) + assertEquals(Content.Empty, content) + assertEquals(DocumentationNode.Kind.Annotation, kind) + assertEquals(1, details.count()) + with(details[0]) { + assertEquals(DocumentationNode.Kind.Parameter, kind) + assertEquals(1, details.count()) + with(details[0]) { + assertEquals(DocumentationNode.Kind.Value, kind) + assertEquals("RetentionPolicy.SOURCE", name) + } + } + } + } + } + } } diff --git a/test/src/model/FunctionTest.kt b/test/src/model/FunctionTest.kt index d3d7843a..bf7471ea 100644 --- a/test/src/model/FunctionTest.kt +++ b/test/src/model/FunctionTest.kt @@ -163,4 +163,27 @@ Documentation""", content.description.toTestString()) } } } + + Test fun annotatedFunctionWithAnnotationParameters() { + verifyModel("test/data/functions/annotatedFunctionWithAnnotationParameters.kt") { model -> + with(model.members.single().members.single()) { + assertEquals(1, annotations.count()) + with(annotations[0]) { + assertEquals("inlineOptions", name) + assertEquals(Content.Empty, content) + assertEquals(DocumentationNode.Kind.Annotation, kind) + assertEquals(1, details.count()) + with(details[0]) { + assertEquals(DocumentationNode.Kind.Parameter, kind) + assertEquals(1, details.count()) + with(details[0]) { + assertEquals(DocumentationNode.Kind.Value, kind) + assertEquals("[InlineOption.LOCAL_CONTINUE_AND_BREAK]", name) + } + } + } + } + } + } } + -- cgit From a03a2cc3df9afe714e2a490d86a9110faaecfa24 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 9 Jan 2015 17:56:15 +0100 Subject: remove some redundant code --- test/src/TestAPI.kt | 4 ---- 1 file changed, 4 deletions(-) (limited to 'test') diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt index af1b8e52..a88835cd 100644 --- a/test/src/TestAPI.kt +++ b/test/src/TestAPI.kt @@ -37,10 +37,6 @@ public fun verifyModel(vararg files: String, verifier: (DocumentationModule) -> val documentation = environment.withContext { environment, session -> val fragments = environment.getSourceFiles().map { session.getPackageFragment(it.getPackageFqName()) }.filterNotNull().distinct() - val descriptors = hashMapOf>() - for ((name, parts) in fragments.groupBy { it.fqName }) { - descriptors.put(name.asString(), parts.flatMap { it.getMemberScope().getAllDescriptors() }) - } val documentationModule = DocumentationModule("test") val documentationBuilder = DocumentationBuilder(session, options) -- cgit From 7fbff24a81a7bcc453e1c4e30acdcf7b38c68265 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 9 Jan 2015 18:54:06 +0100 Subject: use JUnit for compares; avoid generating trailing whitespace in markdown --- test/data/format/annotationClass.md | 2 +- test/data/format/annotations.md | 6 +++--- test/data/format/classWithClassObject.md | 6 +++--- test/src/TestAPI.kt | 5 ++--- 4 files changed, 9 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/data/format/annotationClass.md b/test/data/format/annotationClass.md index bfaa8581..301eff08 100644 --- a/test/data/format/annotationClass.md +++ b/test/data/format/annotationClass.md @@ -14,5 +14,5 @@ annotation class fancy ### Constructors -| [<init>](out.md) | `public fancy()` | +| [<init>](out.md) | `public fancy()` | diff --git a/test/data/format/annotations.md b/test/data/format/annotations.md index 83f79397..e745213e 100644 --- a/test/data/format/annotations.md +++ b/test/data/format/annotations.md @@ -14,17 +14,17 @@ data class Foo ### Constructors -| [<init>](out.md) | `public Foo()` | +| [<init>](out.md) | `public Foo()` | ### Properties -| [x](out.md) | `inline val x: Int` | +| [x](out.md) | `inline val x: Int` | ### Functions -| [bar](out.md) | `inline fun bar(noinline notInlined: () -> Unit): Unit` | +| [bar](out.md) | `inline fun bar(noinline notInlined: () -> Unit): Unit` | diff --git a/test/data/format/classWithClassObject.md b/test/data/format/classWithClassObject.md index f694a76f..796ecce2 100644 --- a/test/data/format/classWithClassObject.md +++ b/test/data/format/classWithClassObject.md @@ -14,17 +14,17 @@ class Klass ### Constructors -| [<init>](out.md) | `public Klass()` | +| [<init>](out.md) | `public Klass()` | ### Class Object Properties -| [x](out.md) | `val x: Int` | +| [x](out.md) | `val x: Int` | ### Class Object Functions -| [foo](out.md) | `fun foo(): Unit` | +| [foo](out.md) | `fun foo(): Unit` | diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt index a88835cd..e559e337 100644 --- a/test/src/TestAPI.kt +++ b/test/src/TestAPI.kt @@ -4,10 +4,9 @@ import org.jetbrains.jet.cli.common.messages.* import com.intellij.openapi.util.* import kotlin.test.fail import org.jetbrains.dokka.* -import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor import java.io.File -import kotlin.test.assertEquals import com.intellij.openapi.application.PathManager +import org.junit.Assert public fun verifyModel(vararg files: String, verifier: (DocumentationModule) -> Unit) { val messageCollector = object : MessageCollector { @@ -55,7 +54,7 @@ public fun verifyOutput(path: String, outputExtension: String, outputGenerator: val output = StringBuilder() outputGenerator(it, output) val expectedOutput = File(path.replace(".kt", outputExtension)).readText() - assertEquals(expectedOutput, output.toString()) + Assert.assertEquals(expectedOutput, output.toString()) } } -- cgit From 4b0dcee83efbdb77ae5e389ee04c309c52446153 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 9 Jan 2015 19:48:44 +0100 Subject: generate ExternalClass nodes to hold extension functions and properties for classes from other packages --- test/data/format/extensions.class.md | 16 ++++++++++++ test/data/format/extensions.kt | 19 ++++++++++++++ test/data/format/extensions.package.md | 18 +++++++++++++ test/data/functions/functionWithReceiver.kt | 8 +++++- test/data/properties/propertyWithReceiver.kt | 2 ++ test/src/format/MarkdownFormatTest.kt | 9 +++++++ test/src/model/FunctionTest.kt | 38 +++++++++++++++++----------- test/src/model/PropertyTest.kt | 13 ++++++++++ 8 files changed, 107 insertions(+), 16 deletions(-) create mode 100644 test/data/format/extensions.class.md create mode 100644 test/data/format/extensions.kt create mode 100644 test/data/format/extensions.package.md create mode 100644 test/data/properties/propertyWithReceiver.kt (limited to 'test') diff --git a/test/data/format/extensions.class.md b/test/data/format/extensions.class.md new file mode 100644 index 00000000..a9747756 --- /dev/null +++ b/test/data/format/extensions.class.md @@ -0,0 +1,16 @@ +[test](out.md) / [foo](out.md) / [String](out.md) + + +### Extensions for String + + +| [fn](out.md) | `fun String.fn(): Unit` +`fun String.fn(x: Int): Unit` +Function with receiver + + | +| [foobar](out.md) | `val String.foobar: Int` +Property with receiver. + + | + diff --git a/test/data/format/extensions.kt b/test/data/format/extensions.kt new file mode 100644 index 00000000..6f2eff9d --- /dev/null +++ b/test/data/format/extensions.kt @@ -0,0 +1,19 @@ +package foo + +/** + * Function with receiver + */ +fun String.fn() { +} + +/** + * Function with receiver + */ +fun String.fn(x: Int) { +} + +/** + * Property with receiver. + */ +val String.foobar: Int + get() = size() * 2 diff --git a/test/data/format/extensions.package.md b/test/data/format/extensions.package.md new file mode 100644 index 00000000..13f40457 --- /dev/null +++ b/test/data/format/extensions.package.md @@ -0,0 +1,18 @@ +[test](out.md) / [foo](out.md) + + +# foo + + +``` +package foo +``` + + + + +### Extensions for External Classes + + +| [String](out.md) | `` | + diff --git a/test/data/functions/functionWithReceiver.kt b/test/data/functions/functionWithReceiver.kt index 663c3e56..c8473251 100644 --- a/test/data/functions/functionWithReceiver.kt +++ b/test/data/functions/functionWithReceiver.kt @@ -2,4 +2,10 @@ * Function with receiver */ fun String.fn() { -} \ No newline at end of file +} + +/** + * Function with receiver + */ +fun String.fn(x: Int) { +} diff --git a/test/data/properties/propertyWithReceiver.kt b/test/data/properties/propertyWithReceiver.kt new file mode 100644 index 00000000..e282f6bd --- /dev/null +++ b/test/data/properties/propertyWithReceiver.kt @@ -0,0 +1,2 @@ +val String.foobar: Int + get() = size() * 2 diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index 08267d32..3d32743f 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -37,4 +37,13 @@ public class MarkdownFormatTest { markdownService.appendNodes(tempLocation, output, model.members.single().members) } } + + Test fun extensions() { + verifyOutput("test/data/format/extensions.kt", ".package.md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members) + } + verifyOutput("test/data/format/extensions.kt", ".class.md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members) + } + } } diff --git a/test/src/model/FunctionTest.kt b/test/src/model/FunctionTest.kt index bf7471ea..299f33a8 100644 --- a/test/src/model/FunctionTest.kt +++ b/test/src/model/FunctionTest.kt @@ -21,23 +21,32 @@ public class FunctionTest { Test fun functionWithReceiver() { verifyModel("test/data/functions/functionWithReceiver.kt") { model -> with(model.members.single().members.single()) { - assertEquals("fn", name) - assertEquals(DocumentationNode.Kind.Function, kind) - assertEquals("Function with receiver", content.summary.toTestString()) - assertEquals(4, details.count()) - assertEquals("internal", details.elementAt(0).name) - assertEquals("final", details.elementAt(1).name) - with(details.elementAt(2)) { - assertEquals("", name) - assertEquals(DocumentationNode.Kind.Receiver, kind) - assertEquals(Content.Empty, content) - assertEquals("String", details.single().name) + assertEquals("String", name) + assertEquals(DocumentationNode.Kind.ExternalClass, kind) + assertEquals(2, members.count()) + with(members[0]) { + assertEquals("fn", name) + assertEquals(DocumentationNode.Kind.Function, kind) + assertEquals("Function with receiver", content.summary.toTestString()) + assertEquals(4, details.count()) + assertEquals("internal", details.elementAt(0).name) + assertEquals("final", details.elementAt(1).name) + with(details.elementAt(2)) { + assertEquals("", name) + assertEquals(DocumentationNode.Kind.Receiver, kind) + assertEquals(Content.Empty, content) + assertEquals("String", details.single().name) + assertTrue(members.none()) + assertTrue(links.none()) + } + assertEquals("Unit", details.elementAt(3).name) assertTrue(members.none()) assertTrue(links.none()) } - assertEquals("Unit", details.elementAt(3).name) - assertTrue(members.none()) - assertTrue(links.none()) + with(members[1]) { + assertEquals("fn", name) + assertEquals(DocumentationNode.Kind.Function, kind) + } } } } @@ -186,4 +195,3 @@ Documentation""", content.description.toTestString()) } } } - diff --git a/test/src/model/PropertyTest.kt b/test/src/model/PropertyTest.kt index 0bf9714d..14c43f78 100644 --- a/test/src/model/PropertyTest.kt +++ b/test/src/model/PropertyTest.kt @@ -112,4 +112,17 @@ public class PropertyTest { } } } + + Test fun propertyWithReceiver() { + verifyModel("test/data/properties/propertyWithReceiver.kt") { model -> + with(model.members.single().members.single()) { + assertEquals("String", name) + assertEquals(DocumentationNode.Kind.ExternalClass, kind) + with(members.single()) { + assertEquals("foobar", name) + assertEquals(DocumentationNode.Kind.Property, kind) + } + } + } + } } -- cgit From e17eaa5fbc296bab0f32e8169d50fea06a6de581 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 9 Jan 2015 20:59:58 +0100 Subject: nice rendering for deprecated members --- test/data/format/deprecated.class.html | 46 ++++++++++++++++++++++++++++++++ test/data/format/deprecated.kt | 5 ++++ test/data/format/deprecated.package.html | 44 ++++++++++++++++++++++++++++++ test/src/format/HtmlFormatTest.kt | 9 +++++++ test/src/model/ClassTest.kt | 3 +-- 5 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 test/data/format/deprecated.class.html create mode 100644 test/data/format/deprecated.kt create mode 100644 test/data/format/deprecated.package.html (limited to 'test') diff --git a/test/data/format/deprecated.class.html b/test/data/format/deprecated.class.html new file mode 100644 index 00000000..87599082 --- /dev/null +++ b/test/data/format/deprecated.class.html @@ -0,0 +1,46 @@ + + + + +test /  / C
+
+

C

+
class C
Deprecated: This class sucks
+
+
+test /  / f
+
+

f

+
fun f(): Unit
Deprecated: This function sucks
+
+
+test /  / p
+
+

p

+
val p: Int
Deprecated: This property sucks
+
+
+

Constructors

+ + + + + + + +
+<init> +public C()
+

Accessors

+ + + + + + + +
+get +
+ + diff --git a/test/data/format/deprecated.kt b/test/data/format/deprecated.kt new file mode 100644 index 00000000..9ee2c1d6 --- /dev/null +++ b/test/data/format/deprecated.kt @@ -0,0 +1,5 @@ +deprecated("This class sucks") class C() { } + +deprecated("This function sucks") fun f() { } + +deprecated("This property sucks") val p: Int get() = 0 diff --git a/test/data/format/deprecated.package.html b/test/data/format/deprecated.package.html new file mode 100644 index 00000000..cf563a8b --- /dev/null +++ b/test/data/format/deprecated.package.html @@ -0,0 +1,44 @@ + + + + +test / 
+
+

+
package 

+
+

Types

+ + + + + + + +
+C +class C
+

Properties

+ + + + + + + +
+p +val p: Int
+

Functions

+ + + + + + + +
+f +fun f(): Unit
+ + diff --git a/test/src/format/HtmlFormatTest.kt b/test/src/format/HtmlFormatTest.kt index 881a7828..47fe9c4e 100644 --- a/test/src/format/HtmlFormatTest.kt +++ b/test/src/format/HtmlFormatTest.kt @@ -24,4 +24,13 @@ public class HtmlFormatTest { htmlService.appendNodes(tempLocation, output, model.members) } } + + Test fun deprecated() { + verifyOutput("test/data/format/deprecated.kt", ".package.html") { model, output -> + htmlService.appendNodes(tempLocation, output, model.members) + } + verifyOutput("test/data/format/deprecated.kt", ".class.html") { model, output -> + htmlService.appendNodes(tempLocation, output, model.members.single().members) + } + } } diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt index ae82a4f1..f21c5c57 100644 --- a/test/src/model/ClassTest.kt +++ b/test/src/model/ClassTest.kt @@ -183,8 +183,7 @@ public class ClassTest { Test fun annotatedClassWithAnnotationParameters() { verifyModel("test/data/classes/annotatedClassWithAnnotationParameters.kt") { model -> with(model.members.single().members.single()) { - assertEquals(1, annotations.count()) - with(annotations[0]) { + with(deprecation!!) { assertEquals("deprecated", name) assertEquals(Content.Empty, content) assertEquals(DocumentationNode.Kind.Annotation, kind) -- cgit