aboutsummaryrefslogtreecommitdiff
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
parentcd52a20e56abcb15ebc11659bc79cac6a9b56a75 (diff)
downloaddokka-c3e979270956b8df9380cf9eea067048f325dbd3.tar.gz
dokka-c3e979270956b8df9380cf9eea067048f325dbd3.tar.bz2
dokka-c3e979270956b8df9380cf9eea067048f325dbd3.zip
Replace !! with some meaningful messages
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt7
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt14
-rw-r--r--plugins/gfm/src/main/kotlin/GfmPlugin.kt10
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt14
4 files changed, 32 insertions, 13 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) =
diff --git a/plugins/gfm/src/main/kotlin/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/GfmPlugin.kt
index c758467a..c8f78c26 100644
--- a/plugins/gfm/src/main/kotlin/GfmPlugin.kt
+++ b/plugins/gfm/src/main/kotlin/GfmPlugin.kt
@@ -1,6 +1,8 @@
package org.jetbrains.dokka.gfm
import org.jetbrains.dokka.CoreExtensions
+import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
+import org.jetbrains.dokka.DokkaException
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.renderers.DefaultRenderer
import org.jetbrains.dokka.base.renderers.PackageListCreator
@@ -324,7 +326,11 @@ open class CommonmarkRenderer(
}
override 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) }, ".md")
is RendererSpecificPage -> when (val strategy = page.strategy) {
@@ -359,5 +365,5 @@ class MarkdownLocationProvider(
) : DokkaLocationProvider(
pageGraphRoot,
dokkaContext,
-".md"
+ ".md"
) \ No newline at end of file
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt
index e25a29fd..c811ace3 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt
@@ -3,6 +3,8 @@ package org.jetbrains.dokka.javadoc.renderer
import org.jetbrains.dokka.javadoc.location.JavadocLocationProvider
import org.jetbrains.dokka.javadoc.pages.*
import org.jetbrains.dokka.javadoc.renderer.SearchRecord.Companion.allTypes
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.DokkaException
import org.jetbrains.dokka.base.renderers.sourceSets
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.DisplaySourceSet
@@ -57,7 +59,7 @@ class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider
val modules = SearchData(moduleRecords = input.map {
SearchRecord(
l = it.name,
- url = locationProvider.resolve(it)?.formatToEndWithHtml()
+ url = locationProvider.resolve(it).formatToEndWithHtml()
)
})
val processablePackages = input.flatMap { it.children.filterIsInstance<JavadocPackagePageNode>() }
@@ -68,7 +70,7 @@ class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider
val packages = input.map {
SearchRecord(
l = it.name,
- url = locationProvider.resolve(it)?.formatToEndWithHtml()
+ url = locationProvider.resolve(it).formatToEndWithHtml()
)
} + SearchRecord.allPackages
val types = input.flatMap {
@@ -86,7 +88,7 @@ class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider
SearchRecord(
p = it.first.name,
l = it.second.name,
- url = locationProvider.resolve(it.second)?.formatToEndWithHtml()
+ url = locationProvider.resolve(it.second).formatToEndWithHtml()
)
} + allTypes
val updated = accumulator.copy(typeRecords = types)
@@ -103,7 +105,7 @@ class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider
packageName = it.first.name,
classlikeName = it.second.name,
input = function,
- url = locationProvider.resolve(function.dri, it.first.sourceSets())!!
+ url = locationProvider.resolve(function.dri, it.first.sourceSets()) ?: throw DokkaException("Cannot resolve path for ${function.dri}")
)
}
}
@@ -114,7 +116,7 @@ class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider
packageName = it.first.name,
classlikeName = it.second.name,
property,
- locationProvider.resolve(property.dri, it.first.sourceSets())!!
+ locationProvider.resolve(property.dri, it.first.sourceSets())?: throw DokkaException("Cannot resolve path for ${property.dri}")
)
}
}
@@ -125,7 +127,7 @@ class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider
packageName = it.first.name,
classlikeName = it.second.name,
entry,
- locationProvider.resolve(entry.dri, it.first.sourceSets())!!
+ locationProvider.resolve(entry.dri, it.first.sourceSets()) ?: throw DokkaException("Cannot resolve path for ${entry.dri}")
)
}
}