diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2022-04-19 13:11:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-19 13:11:38 +0300 |
commit | 3d573827230e7a750c002cf416cf9231161dd9b3 (patch) | |
tree | 9da32e97873536db521974a004929cbb0c8a29df /plugins/templating/src | |
parent | 2a0ed52ff33c2ea38cf2bbd439a8b5af9f692d04 (diff) | |
download | dokka-3d573827230e7a750c002cf416cf9231161dd9b3.tar.gz dokka-3d573827230e7a750c002cf416cf9231161dd9b3.tar.bz2 dokka-3d573827230e7a750c002cf416cf9231161dd9b3.zip |
Update Jsoup to 1.14.3 (#2448)
* Update Jsoup to 1.14.3
* Fix Jsoup API breaking changes after the update
* Fix new Qodana inspections
* Replace IllegalStateException with more appropriate NoSuchElementException
Diffstat (limited to 'plugins/templating/src')
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 |