diff options
-rw-r--r-- | core/src/main/kotlin/javadoc/docbase.kt | 12 | ||||
-rw-r--r-- | core/src/main/resources/format/javadoc.properties | 1 | ||||
-rw-r--r-- | core/src/test/kotlin/javadoc/JavadocTest.kt | 14 | ||||
-rw-r--r-- | core/testdata/javadoc/exception.kt | 5 |
4 files changed, 22 insertions, 10 deletions
diff --git a/core/src/main/kotlin/javadoc/docbase.kt b/core/src/main/kotlin/javadoc/docbase.kt index db5f201e..4298316f 100644 --- a/core/src/main/kotlin/javadoc/docbase.kt +++ b/core/src/main/kotlin/javadoc/docbase.kt @@ -156,12 +156,10 @@ class ProgramElementAdapter(module: ModuleNodeAdapter, node: DocumentationNode) var owner = node.owner while (owner != null) { - when (owner.kind) { - NodeKind.Class, - NodeKind.Interface, - NodeKind.Enum -> return ClassDocumentationNodeAdapter(module, owner) - else -> owner = owner.owner + if (owner.kind in NodeKind.classLike) { + return ClassDocumentationNodeAdapter(module, owner) } + owner = owner.owner } return null @@ -346,6 +344,10 @@ open class ExecutableMemberAdapter(module: ModuleNodeAdapter, node: Documentatio class ConstructorAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : ExecutableMemberAdapter(module, node), ConstructorDoc { override fun name(): String = node.owner?.name ?: throw IllegalStateException("No owner for $node") + + override fun containingClass(): ClassDoc? { + return super.containingClass() + } } class MethodAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeAdapter(module, node), ExecutableMemberDoc by ExecutableMemberAdapter(module, node), MethodDoc { diff --git a/core/src/main/resources/format/javadoc.properties b/core/src/main/resources/format/javadoc.properties deleted file mode 100644 index a58317fc..00000000 --- a/core/src/main/resources/format/javadoc.properties +++ /dev/null @@ -1 +0,0 @@ -class=org.jetbrains.dokka.javadoc.JavadocFormatDescriptor
\ No newline at end of file diff --git a/core/src/test/kotlin/javadoc/JavadocTest.kt b/core/src/test/kotlin/javadoc/JavadocTest.kt index 0fc4233a..b848aaa1 100644 --- a/core/src/test/kotlin/javadoc/JavadocTest.kt +++ b/core/src/test/kotlin/javadoc/JavadocTest.kt @@ -2,11 +2,8 @@ package org.jetbrains.dokka.javadoc import org.jetbrains.dokka.DokkaConsoleLogger import org.jetbrains.dokka.tests.verifyModel +import org.junit.Assert.* import org.junit.Test -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNotNull -import org.junit.Assert.assertTrue class JavadocTest { @Test fun testTypes() { @@ -41,4 +38,13 @@ class JavadocTest { } } + @Test fun testException() { + verifyModel("testdata/javadoc/exception.kt", format = "javadoc", withKotlinRuntime = true) { model -> + val doc = ModuleNodeAdapter(model, StandardReporter(DokkaConsoleLogger), "") + + val classDoc = doc.classNamed("foo.MyException")!! + val member = classDoc.methods().find { it.name() == "foo" } + assertEquals(classDoc, member!!.containingClass()) + } + } } diff --git a/core/testdata/javadoc/exception.kt b/core/testdata/javadoc/exception.kt new file mode 100644 index 00000000..ec0a5bbb --- /dev/null +++ b/core/testdata/javadoc/exception.kt @@ -0,0 +1,5 @@ +package foo + +class MyException : Exception { + fun foo() = "" +} |