aboutsummaryrefslogtreecommitdiff
path: root/plugins/templating
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/templating')
-rw-r--r--plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt4
-rw-r--r--plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt12
-rw-r--r--plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt11
3 files changed, 16 insertions, 11 deletions
diff --git a/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt b/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt
index 9531c279..fa58ecba 100644
--- a/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt
+++ b/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt
@@ -31,7 +31,7 @@ class AddToNavigationCommandHandler(val context: DokkaContext) : CommandHandler
val node = Element(Tag.valueOf("div"), "", attributes)
navigationFragments.entries.sortedBy { it.key }.forEach { (moduleName, command) ->
command.select("a").forEach { a ->
- a.attr("href")?.also { a.attr("href", "${moduleName}/${it}") }
+ a.attr("href").also { a.attr("href", "${moduleName}/${it}") }
}
command.childNodes().toList().forEachIndexed { index, child ->
if (index == 0) {
@@ -43,7 +43,7 @@ class AddToNavigationCommandHandler(val context: DokkaContext) : CommandHandler
Files.write(output.resolve("navigation.html").toPath(), listOf(node.outerHtml()))
node.select("a").forEach { a ->
- a.attr("href")?.also { a.attr("href", "../${it}") }
+ a.attr("href").also { a.attr("href", "../${it}") }
}
navigationFragments.keys.forEach {
Files.write(
diff --git a/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt b/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt
index 7ef4cb10..07f80883 100644
--- a/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt
+++ b/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt
@@ -67,15 +67,17 @@ class DirectiveBasedHtmlTemplateProcessingStrategy(private val context: DokkaCon
var firstStartBorder: Comment? = null
for (index in startFrom until node.childNodeSize()) {
when (val currentChild = node.childNode(index)) {
- is Comment -> if (currentChild.data?.startsWith(TEMPLATE_COMMAND_BEGIN_BORDER) == true) {
+ is Comment -> if (currentChild.data.startsWith(TEMPLATE_COMMAND_BEGIN_BORDER)) {
lastStartBorder = currentChild
firstStartBorder = firstStartBorder ?: currentChild
nodes.clear()
- } else if (lastStartBorder != null && currentChild.data?.startsWith(TEMPLATE_COMMAND_END_BORDER) == true) {
+ } else if (lastStartBorder != null && currentChild.data.startsWith(TEMPLATE_COMMAND_END_BORDER)) {
lastStartBorder.remove()
- val cmd: Command? =
- lastStartBorder.data?.removePrefix("$TEMPLATE_COMMAND_BEGIN_BORDER$TEMPLATE_COMMAND_SEPARATOR")?.let { parseJson(it) }
- cmd?.let { handler(it, nodes) }
+ val cmd = lastStartBorder.data
+ .removePrefix("$TEMPLATE_COMMAND_BEGIN_BORDER$TEMPLATE_COMMAND_SEPARATOR")
+ .let { parseJson<Command>(it) }
+
+ handler(cmd, nodes)
currentChild.remove()
extractCommandsFromComments(node, firstStartBorder?.siblingIndex() ?: 0, handler)
return
diff --git a/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt b/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt
index 02570849..8173f839 100644
--- a/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt
+++ b/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt
@@ -13,10 +13,13 @@ class ReplaceVersionCommandHandler(private val context: DokkaContext) : CommandH
override fun canHandle(command: Command): Boolean = command is ReplaceVersionsCommand
override fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) {
- val position = body.elementSiblingIndex()
val parent = body.parent()
- body.remove()
- context.configuration.moduleVersion?.takeIf { it.isNotEmpty() }
- ?.let { parent.insertChildren(position, TextNode(it)) }
+ if (parent != null) {
+ val position = body.elementSiblingIndex()
+ body.remove()
+
+ context.configuration.moduleVersion?.takeIf { it.isNotEmpty() }
+ ?.let { parent.insertChildren(position, TextNode(it)) }
+ }
}
} \ No newline at end of file