aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Kotlin/DocumentationBuilder.kt4
-rw-r--r--src/Kotlin/KotlinLanguageService.kt7
-rw-r--r--test/data/format/propertyVar.kt1
-rw-r--r--test/data/format/propertyVar.md12
-rw-r--r--test/src/format/MarkdownFormatTest.kt6
-rw-r--r--test/src/model/PropertyTest.kt3
6 files changed, 30 insertions, 3 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index 892a462e..c7ce0ef6 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -285,6 +285,10 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
getExtensionReceiverParameter()?.let { node.appendChild(it, DocumentationReference.Kind.Detail) }
node.appendType(getReturnType())
node.appendAnnotations(this)
+ if (isVar()) {
+ node.append(DocumentationNode("var", Content.Empty, DocumentationNode.Kind.Modifier),
+ DocumentationReference.Kind.Detail)
+ }
getGetter()?.let {
if (!it.isDefault())
node.appendChild(it, DocumentationReference.Kind.Member)
diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt
index 8795aba6..c273ff3d 100644
--- a/src/Kotlin/KotlinLanguageService.kt
+++ b/src/Kotlin/KotlinLanguageService.kt
@@ -108,7 +108,7 @@ class KotlinLanguageService : LanguageService {
private fun ContentNode.renderModifier(node: DocumentationNode) {
when (node.name) {
- "final", "internal" -> {}
+ "final", "internal", "var" -> {}
else -> {
keyword(node.name)
text(" ")
@@ -237,7 +237,7 @@ class KotlinLanguageService : LanguageService {
renderAnnotationsForNode(node)
when (node.kind) {
DocumentationNode.Kind.Property,
- DocumentationNode.Kind.ClassObjectProperty -> keyword("val ")
+ DocumentationNode.Kind.ClassObjectProperty -> keyword("${node.getPropertyKeyword()} ")
else -> throw IllegalArgumentException("Node $node is not a property")
}
renderTypeParametersForNode(node)
@@ -252,6 +252,9 @@ class KotlinLanguageService : LanguageService {
renderType(node.detail(DocumentationNode.Kind.Type))
}
+ fun DocumentationNode.getPropertyKeyword() =
+ if (details(DocumentationNode.Kind.Modifier).any { it.name == "var" }) "var" else "val"
+
fun ContentNode.identifierOrDeprecated(node: DocumentationNode) {
if (node.deprecation != null) {
val strike = ContentStrikethrough()
diff --git a/test/data/format/propertyVar.kt b/test/data/format/propertyVar.kt
new file mode 100644
index 00000000..88be1a7a
--- /dev/null
+++ b/test/data/format/propertyVar.kt
@@ -0,0 +1 @@
+var x = 1 \ No newline at end of file
diff --git a/test/data/format/propertyVar.md b/test/data/format/propertyVar.md
new file mode 100644
index 00000000..6b14fca3
--- /dev/null
+++ b/test/data/format/propertyVar.md
@@ -0,0 +1,12 @@
+[test](out.md) / [](out.md) / [x](out.md)
+
+
+# x
+
+
+```
+var x: Int
+```
+
+
+
diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt
index f7fc6da0..71ad1773 100644
--- a/test/src/format/MarkdownFormatTest.kt
+++ b/test/src/format/MarkdownFormatTest.kt
@@ -61,4 +61,10 @@ public class MarkdownFormatTest {
markdownService.appendNodes(tempLocation, output, model.members.single().members)
}
}
+
+ Test fun propertyVar() {
+ verifyOutput("test/data/format/propertyVar.kt", ".md") { model, output ->
+ markdownService.appendNodes(tempLocation, output, model.members.single().members)
+ }
+ }
}
diff --git a/test/src/model/PropertyTest.kt b/test/src/model/PropertyTest.kt
index 14c43f78..d6de84bb 100644
--- a/test/src/model/PropertyTest.kt
+++ b/test/src/model/PropertyTest.kt
@@ -57,11 +57,12 @@ public class PropertyTest {
assertEquals("property", name)
assertEquals(DocumentationNode.Kind.Property, kind)
assertEquals(Content.Empty, content)
- assertEquals(3, details.count())
+ assertEquals(4, details.count())
assertEquals("String", detail(DocumentationNode.Kind.Type).name)
val modifiers = details(DocumentationNode.Kind.Modifier).map { it.name }
assertTrue("final" in modifiers)
assertTrue("internal" in modifiers)
+ assertTrue("var" in modifiers)
assertTrue(links.none())
assertEquals(2, members.count())