diff --git a/plugins/all-modules-page/api/all-modules-page.api b/plugins/all-modules-page/api/all-modules-page.api index d9724a9a2d..0763d75a04 100644 --- a/plugins/all-modules-page/api/all-modules-page.api +++ b/plugins/all-modules-page/api/all-modules-page.api @@ -84,5 +84,6 @@ public final class org/jetbrains/dokka/allModulesPage/ResolveLinkCommandHandler public fun finish (Ljava/io/File;)V public fun handleCommand (Lorg/jsoup/nodes/Element;Lorg/jetbrains/dokka/base/templating/Command;Ljava/io/File;Ljava/io/File;)V public fun handleCommandAsComment (Lorg/jetbrains/dokka/base/templating/Command;Ljava/util/List;Ljava/io/File;Ljava/io/File;)V + public fun handleCommandAsTag (Lorg/jetbrains/dokka/base/templating/Command;Lorg/jsoup/nodes/Element;Ljava/io/File;Ljava/io/File;)V } diff --git a/plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt b/plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt index e881a5abec..7976ba5a0c 100644 --- a/plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt +++ b/plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt @@ -16,29 +16,29 @@ class ResolveLinkCommandHandler(context: DokkaContext) : CommandHandler { private val externalModuleLinkResolver = context.plugin().querySingle { externalModuleLinkResolver } - override fun handleCommand(element: Element, command: Command, input: File, output: File) { + override fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) { command as ResolveLinkCommand val link = externalModuleLinkResolver.resolve(command.dri, output) if (link == null) { - val children = element.childNodes().toList() + val children = body.childNodes().toList() val attributes = Attributes().apply { put("data-unresolved-link", command.dri.toString()) } val el = Element(Tag.valueOf("span"), "", attributes).apply { children.forEach { ch -> appendChild(ch) } } - element.replaceWith(el) + body.replaceWith(el) return } val attributes = Attributes().apply { put("href", link) } - val children = element.childNodes().toList() + val children = body.childNodes().toList() val el = Element(Tag.valueOf("a"), "", attributes).apply { children.forEach { ch -> appendChild(ch) } } - element.replaceWith(el) + body.replaceWith(el) } override fun canHandle(command: Command): Boolean = command is ResolveLinkCommand diff --git a/plugins/templating/api/templating.api b/plugins/templating/api/templating.api index 17c9751553..37255cd75e 100644 --- a/plugins/templating/api/templating.api +++ b/plugins/templating/api/templating.api @@ -29,6 +29,7 @@ public final class org/jetbrains/dokka/templates/AddToNavigationCommandHandler : public final fun getContext ()Lorg/jetbrains/dokka/plugability/DokkaContext; public fun handleCommand (Lorg/jsoup/nodes/Element;Lorg/jetbrains/dokka/base/templating/Command;Ljava/io/File;Ljava/io/File;)V public fun handleCommandAsComment (Lorg/jetbrains/dokka/base/templating/Command;Ljava/util/List;Ljava/io/File;Ljava/io/File;)V + public fun handleCommandAsTag (Lorg/jetbrains/dokka/base/templating/Command;Lorg/jsoup/nodes/Element;Ljava/io/File;Ljava/io/File;)V } public abstract interface class org/jetbrains/dokka/templates/CommandHandler { @@ -36,10 +37,12 @@ public abstract interface class org/jetbrains/dokka/templates/CommandHandler { public abstract fun finish (Ljava/io/File;)V public abstract fun handleCommand (Lorg/jsoup/nodes/Element;Lorg/jetbrains/dokka/base/templating/Command;Ljava/io/File;Ljava/io/File;)V public abstract fun handleCommandAsComment (Lorg/jetbrains/dokka/base/templating/Command;Ljava/util/List;Ljava/io/File;Ljava/io/File;)V + public abstract fun handleCommandAsTag (Lorg/jetbrains/dokka/base/templating/Command;Lorg/jsoup/nodes/Element;Ljava/io/File;Ljava/io/File;)V } public final class org/jetbrains/dokka/templates/CommandHandler$DefaultImpls { public static fun finish (Lorg/jetbrains/dokka/templates/CommandHandler;Ljava/io/File;)V + public static fun handleCommand (Lorg/jetbrains/dokka/templates/CommandHandler;Lorg/jsoup/nodes/Element;Lorg/jetbrains/dokka/base/templating/Command;Ljava/io/File;Ljava/io/File;)V public static fun handleCommandAsComment (Lorg/jetbrains/dokka/templates/CommandHandler;Lorg/jetbrains/dokka/base/templating/Command;Ljava/util/List;Ljava/io/File;Ljava/io/File;)V } @@ -87,6 +90,7 @@ public final class org/jetbrains/dokka/templates/SubstitutionCommandHandler : or public fun finish (Ljava/io/File;)V public fun handleCommand (Lorg/jsoup/nodes/Element;Lorg/jetbrains/dokka/base/templating/Command;Ljava/io/File;Ljava/io/File;)V public fun handleCommandAsComment (Lorg/jetbrains/dokka/base/templating/Command;Ljava/util/List;Ljava/io/File;Ljava/io/File;)V + public fun handleCommandAsTag (Lorg/jetbrains/dokka/base/templating/Command;Lorg/jsoup/nodes/Element;Ljava/io/File;Ljava/io/File;)V } public abstract interface class org/jetbrains/dokka/templates/Substitutor { @@ -168,6 +172,7 @@ public final class templates/ReplaceVersionCommandHandler : org/jetbrains/dokka/ public fun finish (Ljava/io/File;)V public fun handleCommand (Lorg/jsoup/nodes/Element;Lorg/jetbrains/dokka/base/templating/Command;Ljava/io/File;Ljava/io/File;)V public fun handleCommandAsComment (Lorg/jetbrains/dokka/base/templating/Command;Ljava/util/List;Ljava/io/File;Ljava/io/File;)V + public fun handleCommandAsTag (Lorg/jetbrains/dokka/base/templating/Command;Lorg/jsoup/nodes/Element;Ljava/io/File;Ljava/io/File;)V } public final class templates/SourcesetDependencyProcessingStrategy : org/jetbrains/dokka/templates/TemplateProcessingStrategy { diff --git a/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt b/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt index 3e7e1290c3..9531c27968 100644 --- a/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt +++ b/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt @@ -13,12 +13,12 @@ import java.util.concurrent.ConcurrentHashMap class AddToNavigationCommandHandler(val context: DokkaContext) : CommandHandler { private val navigationFragments = ConcurrentHashMap() - override fun handleCommand(element: Element, command: Command, input: File, output: File) { + override fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) { command as AddToNavigationCommand context.configuration.modules.find { it.name == command.moduleName } ?.relativePathToOutputDirectory ?.relativeToOrSelf(context.configuration.outputDir) - ?.let { key -> navigationFragments[key.toString()] = element } + ?.let { key -> navigationFragments[key.toString()] = body } } override fun canHandle(command: Command) = command is AddToNavigationCommand diff --git a/plugins/templating/src/main/kotlin/templates/CommandHandler.kt b/plugins/templating/src/main/kotlin/templates/CommandHandler.kt index 772754564c..e0a69cb8ab 100644 --- a/plugins/templating/src/main/kotlin/templates/CommandHandler.kt +++ b/plugins/templating/src/main/kotlin/templates/CommandHandler.kt @@ -7,7 +7,10 @@ import java.io.File interface CommandHandler { - fun handleCommand(element: Element, command: Command, input: File, output: File) + @Deprecated("This was renamed to handleCommandAsTag", ReplaceWith("handleCommandAsTag(command, element, input, output)")) + fun handleCommand(element: Element, command: Command, input: File, output: File) = + handleCommandAsTag(command, element, input, output) + fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) fun handleCommandAsComment(command: Command, body: List, input: File, output: File) { } fun canHandle(command: Command): Boolean fun finish(output: File) {} diff --git a/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt b/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt index d5579f8a16..7ef4cb10eb 100644 --- a/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt +++ b/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt @@ -42,7 +42,7 @@ class DirectiveBasedHtmlTemplateProcessingStrategy(private val context: DokkaCon } else false fun handleCommandAsTag(element: Element, command: Command, input: File, output: File) { - traverseHandlers(command) { handleCommand(element, command, input, output) } + traverseHandlers(command) { handleCommandAsTag(command, element, input, output) } } fun handleCommandAsComment(command: Command, body: List, input: File, output: File) { diff --git a/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt b/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt index 8035fc83be..0257084926 100644 --- a/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt +++ b/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt @@ -12,10 +12,10 @@ class ReplaceVersionCommandHandler(private val context: DokkaContext) : CommandH override fun canHandle(command: Command): Boolean = command is ReplaceVersionsCommand - override fun handleCommand(element: Element, command: Command, input: File, output: File) { - val position = element.elementSiblingIndex() - val parent = element.parent() - element.remove() + 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)) } } diff --git a/plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt b/plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt index 58cd76948f..178f52dcd2 100644 --- a/plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt +++ b/plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt @@ -13,14 +13,14 @@ import java.io.File class SubstitutionCommandHandler(context: DokkaContext) : CommandHandler { - override fun handleCommand(element: Element, command: Command, input: File, output: File) { + override fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) { command as SubstitutionCommand - val childrenCopy = element.children().toList() + val childrenCopy = body.children().toList() substitute(childrenCopy, TemplatingContext(input, output, childrenCopy, command)) - val position = element.elementSiblingIndex() - val parent = element.parent() - element.remove() + val position = body.elementSiblingIndex() + val parent = body.parent() + body.remove() parent?.insertChildren(position, childrenCopy) } diff --git a/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt b/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt index 7001b1ba59..aea019708b 100644 --- a/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt +++ b/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt @@ -7,6 +7,7 @@ import templates.ProjectNameSubstitutor import templates.ReplaceVersionCommandHandler import templates.SourcesetDependencyProcessingStrategy +@Suppress("unused") class TemplatingPlugin : DokkaPlugin() { val submoduleTemplateProcessor by extensionPoint() diff --git a/plugins/versioning/api/versioning.api b/plugins/versioning/api/versioning.api index f62670582b..b163fd4abe 100644 --- a/plugins/versioning/api/versioning.api +++ b/plugins/versioning/api/versioning.api @@ -60,6 +60,7 @@ public final class org/jetbrains/dokka/versioning/ReplaceVersionCommandHandler : public final fun getVersionsNavigationCreator ()Lorg/jetbrains/dokka/versioning/VersionsNavigationCreator; public fun handleCommand (Lorg/jsoup/nodes/Element;Lorg/jetbrains/dokka/base/templating/Command;Ljava/io/File;Ljava/io/File;)V public fun handleCommandAsComment (Lorg/jetbrains/dokka/base/templating/Command;Ljava/util/List;Ljava/io/File;Ljava/io/File;)V + public fun handleCommandAsTag (Lorg/jetbrains/dokka/base/templating/Command;Lorg/jsoup/nodes/Element;Ljava/io/File;Ljava/io/File;)V } public final class org/jetbrains/dokka/versioning/SemVerVersionOrdering : org/jetbrains/dokka/versioning/VersionsOrdering { diff --git a/plugins/versioning/src/main/kotlin/versioning/ReplaceVersionsCommand.kt b/plugins/versioning/src/main/kotlin/versioning/ReplaceVersionsCommand.kt index 728eac09d4..ad1edd2b95 100644 --- a/plugins/versioning/src/main/kotlin/versioning/ReplaceVersionsCommand.kt +++ b/plugins/versioning/src/main/kotlin/versioning/ReplaceVersionsCommand.kt @@ -18,7 +18,7 @@ class ReplaceVersionCommandHandler(context: DokkaContext) : CommandHandler { override fun canHandle(command: Command): Boolean = command is ReplaceVersionsCommand - override fun handleCommand(element: Element, command: Command, input: File, output: File) { + override fun handleCommandAsTag(command: Command, element: Element, input: File, output: File) { element.empty() element.append(versionsNavigationCreator(output)) }