From e6b76322ce8a5526194005a2b6756ed81d3fb550 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 27 Oct 2015 14:38:34 +0100 Subject: correctly render star projections --- src/Kotlin/DocumentationBuilder.kt | 10 ++++++++-- test/data/format/starProjection.kt | 3 +++ test/data/format/starProjection.md | 8 ++++++++ test/src/format/MarkdownFormatTest.kt | 6 ++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 test/data/format/starProjection.kt create mode 100644 test/data/format/starProjection.md diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index b1aef822..a9ac8551 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -296,7 +296,12 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, } fun DocumentationNode.appendProjection(projection: TypeProjection, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type) { - appendType(projection.type, kind, projection.projectionKind.label) + if (projection.isStarProjection) { + appendTextNode("*", Kind.Type) + } + else { + appendType(projection.type, kind, projection.projectionKind.label) + } } fun DocumentationNode.appendType(jetType: KtType?, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type, prefix: String = "") { @@ -329,8 +334,9 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, append(node, DocumentationReference.Kind.Detail) node.appendAnnotations(jetType) - for (typeArgument in jetType.arguments) + for (typeArgument in jetType.arguments) { node.appendProjection(typeArgument) + } } fun ClassifierDescriptor.isBoringBuiltinClass(): Boolean = diff --git a/test/data/format/starProjection.kt b/test/data/format/starProjection.kt new file mode 100644 index 00000000..1532c830 --- /dev/null +++ b/test/data/format/starProjection.kt @@ -0,0 +1,3 @@ +public inline fun Iterable<*>.containsFoo(element: Any?): Boolean { + return false +} diff --git a/test/data/format/starProjection.md b/test/data/format/starProjection.md new file mode 100644 index 00000000..10114081 --- /dev/null +++ b/test/data/format/starProjection.md @@ -0,0 +1,8 @@ +[test](test/index) / [Iterable](test/-iterable/index) + + +### Extensions for Iterable + + +| [containsFoo](test/-iterable/contains-foo) | `inline fun Iterable<*>.containsFoo(element: Any?): Boolean` | + diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index 32a641ff..76ead835 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -168,6 +168,12 @@ public class MarkdownFormatTest { } } + @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) -- cgit