aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2016-11-02 19:50:04 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2016-11-02 19:50:04 +0300
commitb64579c6d444a39882ceeef08bdc3eedb584e827 (patch)
tree2cb0eacd445bffa64f38e3a744db4e2334aea1c6
parent8c7ba164d96b8b5018b2eb5ec0717de29c44b172 (diff)
downloaddokka-b64579c6d444a39882ceeef08bdc3eedb584e827.tar.gz
dokka-b64579c6d444a39882ceeef08bdc3eedb584e827.tar.bz2
dokka-b64579c6d444a39882ceeef08bdc3eedb584e827.zip
Added test and post-review fix
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt3
-rw-r--r--core/src/test/kotlin/model/LinkTest.kt19
-rw-r--r--core/testdata/links/linkToPackage.kt8
3 files changed, 27 insertions, 3 deletions
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index f09c1fc0..ecb6edf2 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -732,12 +732,11 @@ fun CallableMemberDescriptor.getExtensionClassDescriptor(): ClassifierDescriptor
}
fun DeclarationDescriptor.signature(): String = when(this) {
- is ClassDescriptor, is PackageFragmentDescriptor -> DescriptorUtils.getFqName(this).asString()
+ is ClassDescriptor, is PackageFragmentDescriptor, is PackageViewDescriptor -> DescriptorUtils.getFqName(this).asString()
is PropertyDescriptor -> containingDeclaration.signature() + "$" + name + receiverSignature()
is FunctionDescriptor -> containingDeclaration.signature() + "$" + name + parameterSignature()
is ValueParameterDescriptor -> containingDeclaration.signature() + "/" + name
is TypeParameterDescriptor -> containingDeclaration.signature() + "*" + name
- is PackageViewDescriptor -> fqName.toString()
else -> throw UnsupportedOperationException("Don't know how to calculate signature for $this")
}
diff --git a/core/src/test/kotlin/model/LinkTest.kt b/core/src/test/kotlin/model/LinkTest.kt
index 1c206467..6b72525f 100644
--- a/core/src/test/kotlin/model/LinkTest.kt
+++ b/core/src/test/kotlin/model/LinkTest.kt
@@ -1,8 +1,10 @@
package org.jetbrains.dokka.tests
+import org.jetbrains.dokka.ContentBlock
+import org.jetbrains.dokka.ContentNodeLazyLink
import org.jetbrains.dokka.NodeKind
-import org.junit.Test
import org.junit.Assert.assertEquals
+import org.junit.Test
class LinkTest {
@Test fun linkToSelf() {
@@ -55,4 +57,19 @@ class LinkTest {
}
}
+ @Test fun linkToPackage() {
+ verifyModel("testdata/links/linkToPackage.kt") { model ->
+ val packageNode = model.members.single()
+ with(packageNode) {
+ assertEquals(this.name, "test.magic")
+ }
+ with(packageNode.members.single()) {
+ assertEquals("Magic", name)
+ assertEquals(NodeKind.Class, kind)
+ assertEquals("Basic implementations of [Magic -> Class:Magic] are located in [test.magic -> Package:test.magic] package", content.summary.toTestString())
+ assertEquals(packageNode, ((this.content.summary as ContentBlock).children.filterIsInstance<ContentNodeLazyLink>().last()).lazyNode.invoke())
+ }
+ }
+ }
+
} \ No newline at end of file
diff --git a/core/testdata/links/linkToPackage.kt b/core/testdata/links/linkToPackage.kt
new file mode 100644
index 00000000..3dd86628
--- /dev/null
+++ b/core/testdata/links/linkToPackage.kt
@@ -0,0 +1,8 @@
+package test.magic
+
+/**
+ * Basic implementations of [Magic] are located in [test.magic] package
+ */
+abstract class Magic {
+
+}