diff options
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 9 | ||||
-rw-r--r-- | src/Kotlin/KotlinLanguageService.kt | 9 | ||||
-rw-r--r-- | test/data/format/typeParameterVariance.kt | 2 | ||||
-rw-r--r-- | test/data/format/typeParameterVariance.md | 14 | ||||
-rw-r--r-- | test/src/format/MarkdownFormatTest.kt | 6 |
5 files changed, 36 insertions, 4 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 6ce7727c..7804fd72 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -474,12 +474,15 @@ class DocumentationBuilder(val session: ResolveSession, val doc = parseDocumentation(this) val name = getName().asString() val prefix = when (getVariance()) { - Variance.IN_VARIANCE -> "in " - Variance.OUT_VARIANCE -> "out " + Variance.IN_VARIANCE -> "in" + Variance.OUT_VARIANCE -> "out" else -> "" } - val node = DocumentationNode(prefix + name, doc, DocumentationNode.Kind.TypeParameter) + val node = DocumentationNode(name, doc, DocumentationNode.Kind.TypeParameter) + if (prefix != "") { + node.appendTextNode(prefix, Kind.Modifier) + } val builtIns = KotlinBuiltIns.getInstance() for (constraint in getUpperBounds()) { diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt index 435fbc64..a4f62c3f 100644 --- a/src/Kotlin/KotlinLanguageService.kt +++ b/src/Kotlin/KotlinLanguageService.kt @@ -125,8 +125,15 @@ class KotlinLanguageService : LanguageService { } private fun ContentBlock.renderTypeParameter(node: DocumentationNode) { - val constraints = node.details(DocumentationNode.Kind.UpperBound) + val modifier = node.details(DocumentationNode.Kind.Modifier).singleOrNull() + if (modifier != null) { + keyword(modifier.name) + nbsp() + } + identifier(node.name) + + val constraints = node.details(DocumentationNode.Kind.UpperBound) if (constraints.any()) { nbsp() symbol(":") diff --git a/test/data/format/typeParameterVariance.kt b/test/data/format/typeParameterVariance.kt new file mode 100644 index 00000000..28b29f4b --- /dev/null +++ b/test/data/format/typeParameterVariance.kt @@ -0,0 +1,2 @@ +class Foo<out T> { +} diff --git a/test/data/format/typeParameterVariance.md b/test/data/format/typeParameterVariance.md new file mode 100644 index 00000000..a46929ce --- /dev/null +++ b/test/data/format/typeParameterVariance.md @@ -0,0 +1,14 @@ +[test](test/index) / [Foo](test/-foo/index) + + +# Foo + +`class Foo<out T> ` + + + +### Constructors + + +| [<init>](test/-foo/-init-) | `public Foo()` | + diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index cf894898..b0c254ba 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -110,4 +110,10 @@ public class MarkdownFormatTest { markdownService.appendNodes(tempLocation, output, model.members.single().members) } } + + Test fun typeParameterVariance() { + verifyOutput("test/data/format/typeParameterVariance.kt", ".md") { model, output -> + markdownService.appendNodes(tempLocation, output, model.members.single().members) + } + } } |