diff options
author | Błażej Kardyś <bkardys@virtuslab.com> | 2020-08-21 15:26:17 +0200 |
---|---|---|
committer | Błażej Kardyś <bkardys@virtuslab.com> | 2020-08-21 15:48:01 +0200 |
commit | 39b64feead5718ae9d3e4293407cf0858057493a (patch) | |
tree | 0c33c8ee5d213004f3fce9846448bb56e9d026b1 /plugins | |
parent | faf621b643ad2b4b7103d921d4a2d9d4838a21d6 (diff) | |
download | dokka-39b64feead5718ae9d3e4293407cf0858057493a.tar.gz dokka-39b64feead5718ae9d3e4293407cf0858057493a.tar.bz2 dokka-39b64feead5718ae9d3e4293407cf0858057493a.zip |
Adding missing deprecated exception section to Deprecated page
Diffstat (limited to 'plugins')
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) = |