aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2020-08-14 13:25:48 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-19 13:34:10 +0200
commitc3e979270956b8df9380cf9eea067048f325dbd3 (patch)
treec4ebc524e68aabdf1f8486f2785ee783c28c66af /plugins/base
parentcd52a20e56abcb15ebc11659bc79cac6a9b56a75 (diff)
downloaddokka-c3e979270956b8df9380cf9eea067048f325dbd3.tar.gz
dokka-c3e979270956b8df9380cf9eea067048f325dbd3.tar.bz2
dokka-c3e979270956b8df9380cf9eea067048f325dbd3.zip
Replace !! with some meaningful messages
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt7
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt14
2 files changed, 16 insertions, 5 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
index d9ff924b..41dffa07 100644
--- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -4,6 +4,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
+import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
+import org.jetbrains.dokka.DokkaException
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.resolvers.local.LocationProvider
import org.jetbrains.dokka.model.DisplaySourceSet
@@ -157,7 +159,10 @@ abstract class DefaultRenderer<T>(
}
open suspend fun renderPage(page: PageNode) {
- val path by lazy { locationProvider.resolve(page, skipExtension = true)!! }
+ val path by lazy {
+ locationProvider.resolve(page, skipExtension = true)
+ ?: throw DokkaException("Cannot resolve path for ${page.name}")
+ }
when (page) {
is ContentPage -> outputWriter.write(path, buildPage(page) { c, p -> buildPageContent(c, p) }, ".html")
is RendererSpecificPage -> when (val strategy = page.strategy) {
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index d9833e43..0d20e8ac 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -523,11 +523,16 @@ open class HtmlRenderer(
}
private fun FlowContent.buildLink(to: PageNode, from: PageNode) =
- buildLink(locationProvider.resolve(to, from)!!) {
+ locationProvider.resolve(to, from)?.let { path ->
+ buildLink(path) {
+ text(to.name)
+ }
+ } ?: span {
+ attributes["data-unresolved-link"] = to.name.htmlEscape()
text(to.name)
}
- private fun FlowContent.buildAnchor(pointingTo: String) {
+ fun FlowContent.buildAnchor(pointingTo: String) {
span(classes = "anchor-wrapper") {
span(classes = "anchor-icon") {
attributes["pointing-to"] = pointingTo
@@ -551,7 +556,8 @@ open class HtmlRenderer(
platforms: List<DisplaySourceSet>,
from: PageNode? = null,
block: FlowContent.() -> Unit
- ) = buildLink(locationProvider.resolve(to, platforms.toSet(), from)!!, block)
+ ) = locationProvider.resolve(to, platforms.toSet(), from)?.let { buildLink(it, block) }
+ ?: run { context.logger.error("Cannot resolve path for $to"); block() }
override fun buildError(node: ContentNode) {
context.logger.error("Unknown ContentNode type: $node")
@@ -603,7 +609,7 @@ open class HtmlRenderer(
override suspend fun renderPage(page: PageNode) {
super.renderPage(page)
if (page is ContentPage && page !is ModulePageNode && page !is PackagePageNode)
- searchbarDataInstaller.processPage(page, locationProvider.resolve(page))
+ searchbarDataInstaller.processPage(page, locationProvider.resolve(page) ?: context.logger.error("Cannot resolve path for ${page.dri}"))
}
override fun FlowContent.buildText(textNode: ContentText) =