aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt35
1 files changed, 26 insertions, 9 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
index 958488ef..ecce70e8 100644
--- a/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
@@ -1,6 +1,8 @@
package org.jetbrains.dokka.base.renderers.html
import org.jetbrains.dokka.base.renderers.sourceSets
+import org.jetbrains.dokka.base.signatures.KotlinSignatureUtils.annotations
+import org.jetbrains.dokka.base.transformers.documentables.isDeprecated
import org.jetbrains.dokka.base.transformers.documentables.isException
import org.jetbrains.dokka.base.translators.documentables.DocumentableLanguage
import org.jetbrains.dokka.base.translators.documentables.documentableLanguage
@@ -17,6 +19,7 @@ abstract class NavigationDataProvider {
dri = page.dri.first(),
sourceSets = page.sourceSets(),
icon = chooseNavigationIcon(page),
+ styles = chooseStyles(page),
children = page.navigableChildren()
)
@@ -31,8 +34,8 @@ abstract class NavigationDataProvider {
name
}
- private fun chooseNavigationIcon(contentPage: ContentPage): NavigationNodeIcon? {
- return if (contentPage is WithDocumentables) {
+ private fun chooseNavigationIcon(contentPage: ContentPage): NavigationNodeIcon? =
+ if (contentPage is WithDocumentables) {
val documentable = contentPage.documentables.firstOrNull()
val isJava = documentable?.hasAnyJavaSources() ?: false
@@ -61,27 +64,41 @@ abstract class NavigationDataProvider {
} else {
null
}
- }
private fun Documentable.hasAnyJavaSources(): Boolean {
val withSources = this as? WithSources ?: return false
return this.sourceSets.any { withSources.documentableLanguage(it) == DocumentableLanguage.JAVA }
}
- private fun DClass.isAbstract(): Boolean {
- return modifier.values.all { it is KotlinModifier.Abstract || it is JavaModifier.Abstract }
+ private fun DClass.isAbstract() =
+ modifier.values.all { it is KotlinModifier.Abstract || it is JavaModifier.Abstract }
+
+ private fun chooseStyles(page: ContentPage): Set<Style> =
+ if (page.containsOnlyDeprecatedDocumentables()) setOf(TextStyle.Strikethrough) else emptySet()
+
+ private fun ContentPage.containsOnlyDeprecatedDocumentables(): Boolean {
+ if (this !is WithDocumentables) {
+ return false
+ }
+ return this.documentables.isNotEmpty() && this.documentables.all { it.isDeprecatedForAllSourceSets() }
+ }
+
+ private fun Documentable.isDeprecatedForAllSourceSets(): Boolean {
+ val sourceSetAnnotations = this.annotations()
+ return sourceSetAnnotations.isNotEmpty() && sourceSetAnnotations.all { (_, annotations) ->
+ annotations.any { it.isDeprecated() }
+ }
}
- private fun ContentPage.navigableChildren(): List<NavigationNode> {
- return if (this is ClasslikePage) {
- return this.navigableChildren()
+ private fun ContentPage.navigableChildren() =
+ if (this is ClasslikePage) {
+ this.navigableChildren()
} else {
children
.filterIsInstance<ContentPage>()
.map { visit(it) }
.sortedBy { it.name.toLowerCase() }
}
- }
private fun ClasslikePage.navigableChildren(): List<NavigationNode> {
// Classlikes should only have other classlikes as navigable children