From 0298076ba9cf22b70b6c85846ad555e201ee95ee Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 20 Nov 2017 22:38:11 +0300 Subject: Support receiver reference --- core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 2 ++ core/src/test/kotlin/format/MarkdownFormatTest.kt | 4 ++++ core/testdata/format/receiverReference.kt | 6 ++++++ core/testdata/format/receiverReference.md | 6 ++++++ 4 files changed, 18 insertions(+) create mode 100644 core/testdata/format/receiverReference.kt create mode 100644 core/testdata/format/receiverReference.md diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index fddf0814..04993ad4 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -746,6 +746,7 @@ class DocumentationBuilder val node = DocumentationNode(name.asString(), Content.Empty, NodeKind.Receiver) node.appendType(type) + register(this, node) return node } @@ -915,6 +916,7 @@ fun DeclarationDescriptor.signature(): String = when (this) { is FunctionDescriptor -> containingDeclaration.signature() + "$" + name + parameterSignature() is ValueParameterDescriptor -> containingDeclaration.signature() + "/" + name is TypeParameterDescriptor -> containingDeclaration.signature() + "*" + name + is ReceiverParameterDescriptor -> containingDeclaration.signature() + "*" + name else -> throw UnsupportedOperationException("Don't know how to calculate signature for $this") } diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index fbebfbfd..97a8ad4b 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -380,6 +380,10 @@ class MarkdownFormatTest { verifyMarkdownNode("indentedCodeBlock") } + @Test fun receiverReference() { + verifyMarkdownNode("receiverReference") + } + private fun buildMultiplePlatforms(path: String): DocumentationModule { val module = DocumentationModule("test") val options = DocumentationOptions("", "html", generateIndexPages = false, noStdlibLink = true) diff --git a/core/testdata/format/receiverReference.kt b/core/testdata/format/receiverReference.kt new file mode 100644 index 00000000..3e6e2056 --- /dev/null +++ b/core/testdata/format/receiverReference.kt @@ -0,0 +1,6 @@ +/** + * Prints [this] + */ +fun String.some() { + println(this) +} \ No newline at end of file diff --git a/core/testdata/format/receiverReference.md b/core/testdata/format/receiverReference.md new file mode 100644 index 00000000..1584b2b1 --- /dev/null +++ b/core/testdata/format/receiverReference.md @@ -0,0 +1,6 @@ +[test](test/index) / [kotlin.String](test/kotlin.-string/index) + +### Extensions for kotlin.String + +| [some](test/kotlin.-string/some) | `fun String.some(): Unit`
Prints [this](test/kotlin.-string/some/-this-) | + -- cgit