aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers')
-rw-r--r--plugins/base/src/main/kotlin/renderers/PackageListService.kt5
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt9
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt18
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt2
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt2
-rw-r--r--plugins/base/src/main/kotlin/renderers/preprocessors.kt7
6 files changed, 22 insertions, 21 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/PackageListService.kt b/plugins/base/src/main/kotlin/renderers/PackageListService.kt
index 2bf66ebf..79391a1c 100644
--- a/plugins/base/src/main/kotlin/renderers/PackageListService.kt
+++ b/plugins/base/src/main/kotlin/renderers/PackageListService.kt
@@ -3,14 +3,13 @@ package org.jetbrains.dokka.base.renderers
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.resolvers.shared.LinkFormat
import org.jetbrains.dokka.base.resolvers.shared.PackageList.Companion.DOKKA_PARAM_PREFIX
-import org.jetbrains.dokka.base.resolvers.shared.PackageList.Companion.SINGLE_MODULE_NAME
import org.jetbrains.dokka.base.resolvers.shared.PackageList.Companion.MODULE_DELIMITER
+import org.jetbrains.dokka.base.resolvers.shared.PackageList.Companion.SINGLE_MODULE_NAME
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.querySingle
-import org.jetbrains.kotlin.utils.addToStdlib.safeAs
class PackageListService(val context: DokkaContext, val rootPage: RootPageNode) {
@@ -29,7 +28,7 @@ class PackageListService(val context: DokkaContext, val rootPage: RootPageNode)
?.let { packages.add(it) }
}
- val contentPage = node.safeAs<ContentPage>()
+ val contentPage = node as? ContentPage
contentPage?.dri?.forEach { dri ->
val nodeLocation = locationProvider.resolve(node, context = module, skipExtension = true)
?: run { context.logger.error("Cannot resolve path for ${node.name}!"); null }
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 94bd0aeb..fa343eec 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -23,7 +23,6 @@ import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.pages.HtmlContent
import org.jetbrains.dokka.plugability.*
import org.jetbrains.dokka.utilities.htmlEscape
-import org.jetbrains.kotlin.utils.addIfNotNull
internal const val TEMPLATE_REPLACEMENT: String = "###"
internal const val TOGGLEABLE_CONTENT_TYPE_ATTR = "data-togglable"
@@ -355,12 +354,10 @@ open class HtmlRenderer(
val contentOfSourceSet = mutableListOf<ContentNode>()
distinct.onEachIndexed{ index, (_, distinctInstances) ->
- contentOfSourceSet.addIfNotNull(distinctInstances.firstOrNull()?.before)
+ distinctInstances.firstOrNull()?.before?.let { contentOfSourceSet.add(it) }
contentOfSourceSet.addAll(distinctInstances.map { it.divergent })
- contentOfSourceSet.addIfNotNull(
- distinctInstances.firstOrNull()?.after
- ?: if (index != distinct.size - 1) ContentBreakLine(it.key) else null
- )
+ (distinctInstances.firstOrNull()?.after ?: if (index != distinct.size - 1) ContentBreakLine(it.key) else null)
+ ?.let { contentOfSourceSet.add(it) }
// content kind main is important for declarations list to avoid double line breaks
if (node.dci.kind == ContentKind.Main && index != distinct.size - 1) {
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
index be1b0fcf..c864295c 100644
--- a/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
@@ -4,13 +4,20 @@ 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
import org.jetbrains.dokka.base.utils.canonicalAlphabeticalOrder
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.pages.*
+import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.plugability.plugin
+import org.jetbrains.dokka.plugability.querySingle
+import org.jetbrains.kotlin.analysis.kotlin.internal.DocumentableLanguage
+import org.jetbrains.kotlin.analysis.kotlin.internal.InternalKotlinAnalysisPlugin
+
+abstract class NavigationDataProvider(
+ dokkaContext: DokkaContext
+) {
+ private val documentableSourceLanguageParser = dokkaContext.plugin<InternalKotlinAnalysisPlugin>().querySingle { documentableSourceLanguageParser }
-abstract class NavigationDataProvider {
open fun navigableChildren(input: RootPageNode): NavigationNode = input.withDescendants()
.first { it is ModulePage || it is MultimoduleRootPage }.let { visit(it as ContentPage) }
@@ -68,8 +75,9 @@ abstract class NavigationDataProvider {
}
private fun Documentable.hasAnyJavaSources(): Boolean {
- val withSources = this as? WithSources ?: return false
- return this.sourceSets.any { withSources.documentableLanguage(it) == DocumentableLanguage.JAVA }
+ return this.sourceSets.any { sourceSet ->
+ documentableSourceLanguageParser.getLanguage(this, sourceSet) == DocumentableLanguage.JAVA
+ }
}
private fun DClass.isAbstract() =
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
index 9543c388..4def7088 100644
--- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
@@ -2,6 +2,8 @@ package org.jetbrains.dokka.base.renderers.html
import kotlinx.html.*
import kotlinx.html.stream.createHTML
+import org.jetbrains.dokka.base.renderers.html.NavigationNodeIcon.CLASS
+import org.jetbrains.dokka.base.renderers.html.NavigationNodeIcon.CLASS_KT
import org.jetbrains.dokka.base.renderers.pageId
import org.jetbrains.dokka.base.templating.AddToNavigationCommand
import org.jetbrains.dokka.links.DRI
diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
index a213bce9..557205d7 100644
--- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
@@ -11,7 +11,7 @@ import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.configuration
import org.jetbrains.dokka.transformers.pages.PageTransformer
-open class NavigationPageInstaller(val context: DokkaContext) : NavigationDataProvider(), PageTransformer {
+open class NavigationPageInstaller(val context: DokkaContext) : NavigationDataProvider(context), PageTransformer {
override fun invoke(input: RootPageNode): RootPageNode =
input.modified(
children = input.children + NavigationPage(
diff --git a/plugins/base/src/main/kotlin/renderers/preprocessors.kt b/plugins/base/src/main/kotlin/renderers/preprocessors.kt
index 8a30bed1..2cfa2dcf 100644
--- a/plugins/base/src/main/kotlin/renderers/preprocessors.kt
+++ b/plugins/base/src/main/kotlin/renderers/preprocessors.kt
@@ -1,12 +1,7 @@
package org.jetbrains.dokka.base.renderers
import org.jetbrains.dokka.base.resolvers.shared.LinkFormat
-import org.jetbrains.dokka.pages.ModulePage
-import org.jetbrains.dokka.pages.RendererSpecificPage
-import org.jetbrains.dokka.pages.RendererSpecificResourcePage
-import org.jetbrains.dokka.pages.RendererSpecificRootPage
-import org.jetbrains.dokka.pages.RenderingStrategy
-import org.jetbrains.dokka.pages.RootPageNode
+import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.transformers.pages.PageTransformer