aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/utils.kt8
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt1
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt5
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocDeprecatedTest.kt26
4 files changed, 38 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/utils.kt b/plugins/base/src/main/kotlin/transformers/documentables/utils.kt
index a8f13ad8..6b87fe39 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/utils.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/utils.kt
@@ -2,6 +2,7 @@ package org.jetbrains.dokka.base.transformers.documentables
import org.jetbrains.dokka.model.Annotations
import org.jetbrains.dokka.model.Documentable
+import org.jetbrains.dokka.model.WithSupertypes
import org.jetbrains.dokka.model.properties.WithExtraProperties
fun <T> T.isDeprecated() where T : WithExtraProperties<out Documentable> =
@@ -13,4 +14,11 @@ val <T> T.deprecatedAnnotation where T : WithExtraProperties<out Documentable>
it.dri.toString() == "kotlin/Deprecated///PointingToDeclaration/" ||
it.dri.toString() == "java.lang/Deprecated///PointingToDeclaration/"
}
+ }
+
+val WithSupertypes.isException: Boolean
+ get() = supertypes.values.flatten().any {
+ val dri = it.typeConstructor.dri.toString()
+ dri == "kotlin/Exception///PointingToDeclaration/" ||
+ dri == "java.lang/Exception///PointingToDeclaration/"
} \ No newline at end of file
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
index de07b730..feedc493 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
@@ -319,6 +319,7 @@ enum class DeprecatedPageSection(val id: String, val caption: String, val header
DeprecatedInterfaces("interface", "Interfaces", "Interface"),
DeprecatedClasses("class", "Classes", "Class"),
DeprecatedEnums("enum", "Enums", "Enum"),
+ DeprecatedExceptions("exception", "Exceptions", "Exceptions"),
DeprecatedFields("field", "Fields", "Field"),
DeprecatedMethods("method", "Methods", "Method"),
DeprecatedConstructors("constructor", "Constructors", "Constructor"),
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt
index 418327e6..5d51bc24 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt
@@ -3,8 +3,10 @@ package org.jetbrains.dokka.javadoc.pages
import org.jetbrains.dokka.base.renderers.sourceSets
import org.jetbrains.dokka.base.transformers.documentables.deprecatedAnnotation
import org.jetbrains.dokka.base.transformers.documentables.isDeprecated
+import org.jetbrains.dokka.base.transformers.documentables.isException
import org.jetbrains.dokka.model.Documentable
import org.jetbrains.dokka.model.StringValue
+import org.jetbrains.dokka.model.WithSupertypes
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.transformers.pages.PageTransformer
import kotlin.collections.HashMap
@@ -130,7 +132,8 @@ object DeprecatedPageCreator : PageTransformer {
node.properties.forEach { it.takeIf { it.isDeprecated() }?.putAs(DeprecatedPageSection.DeprecatedFields) }
node.entries.forEach { it.takeIf { it.isDeprecated() }?.putAs(DeprecatedPageSection.DeprecatedEnumConstants) }
node.takeIf { it.isDeprecated() }?.putAs(
- when (node.kind) {
+ if ((node.documentable as? WithSupertypes)?.isException == true) DeprecatedPageSection.DeprecatedExceptions
+ else when (node.kind) {
"enum" -> DeprecatedPageSection.DeprecatedEnums
"interface" -> DeprecatedPageSection.DeprecatedInterfaces
else -> DeprecatedPageSection.DeprecatedClasses
diff --git a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocDeprecatedTest.kt b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocDeprecatedTest.kt
index 97865c0f..982d356a 100644
--- a/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocDeprecatedTest.kt
+++ b/plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/JavadocDeprecatedTest.kt
@@ -10,7 +10,7 @@ internal class JavadocDeprecatedTest : AbstractJavadocTemplateMapTest() {
@Test
fun `generates correct number of sections`() {
testDeprecatedPageTemplateMaps { templateMap ->
- Assertions.assertEquals(5, (templateMap["sections"] as List<TemplateMap>).size)
+ Assertions.assertEquals(6, (templateMap["sections"] as List<TemplateMap>).size)
}
}
@@ -47,6 +47,14 @@ internal class JavadocDeprecatedTest : AbstractJavadocTemplateMapTest() {
}
@Test
+ fun `finds correct number of deprecated exceptions`() {
+ testDeprecatedPageTemplateMaps { templateMap ->
+ val map = templateMap.section("Exceptions")
+ Assertions.assertEquals(2, map.elements().size)
+ }
+ }
+
+ @Test
fun `finds correct number of deprecated methods`() {
testDeprecatedPageTemplateMaps { templateMap ->
//We are checking whether we will have an additional function for enum classes
@@ -133,6 +141,22 @@ internal class JavadocDeprecatedTest : AbstractJavadocTemplateMapTest() {
@Deprecated(forRemoval = true)
public void deprecatedMethod() {}
}
+
+ /src/source5.java
+ package package1;
+ /**
+ * Documentation for ClassJavaException
+ */
+ @Deprecated
+ public class ClassJavaException extends Exception { }
+
+ /src/source6.kt
+ package package1
+ /**
+ * Documentation for ClassKotlinException
+ */
+ @Deprecated
+ class ClassKotlinException: Exception() {}
""".trimIndent()
private fun testDeprecatedPageTemplateMaps(operation: (TemplateMap) -> Unit) =