From 8e5c63d035ef44a269b8c43430f43f5c8eebfb63 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Fri, 10 Nov 2023 11:46:54 +0100 Subject: Restructure the project to utilize included builds (#3174) * Refactor and simplify artifact publishing * Update Gradle to 8.4 * Refactor and simplify convention plugins and build scripts Fixes #3132 --------- Co-authored-by: Adam <897017+aSemy@users.noreply.github.com> Co-authored-by: Oleg Yukhnevich --- .../org/jetbrains/dokka/jekyll/JekyllPlugin.kt | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 dokka-subprojects/plugin-jekyll/src/main/kotlin/org/jetbrains/dokka/jekyll/JekyllPlugin.kt (limited to 'dokka-subprojects/plugin-jekyll/src/main/kotlin/org') diff --git a/dokka-subprojects/plugin-jekyll/src/main/kotlin/org/jetbrains/dokka/jekyll/JekyllPlugin.kt b/dokka-subprojects/plugin-jekyll/src/main/kotlin/org/jetbrains/dokka/jekyll/JekyllPlugin.kt new file mode 100644 index 00000000..733c81bb --- /dev/null +++ b/dokka-subprojects/plugin-jekyll/src/main/kotlin/org/jetbrains/dokka/jekyll/JekyllPlugin.kt @@ -0,0 +1,85 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package org.jetbrains.dokka.jekyll + +import org.jetbrains.dokka.CoreExtensions +import org.jetbrains.dokka.base.DokkaBase +import org.jetbrains.dokka.base.renderers.PackageListCreator +import org.jetbrains.dokka.base.renderers.RootCreator +import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProviderFactory +import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory +import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat +import org.jetbrains.dokka.gfm.GfmPlugin +import org.jetbrains.dokka.gfm.renderer.BriefCommentPreprocessor +import org.jetbrains.dokka.gfm.renderer.CommonmarkRenderer +import org.jetbrains.dokka.pages.ContentPage +import org.jetbrains.dokka.plugability.* +import org.jetbrains.dokka.renderers.PostAction +import org.jetbrains.dokka.renderers.Renderer +import org.jetbrains.dokka.transformers.pages.PageTransformer + +public class JekyllPlugin : DokkaPlugin() { + + public val jekyllPreprocessors: ExtensionPoint by extensionPoint() + + private val dokkaBase by lazy { plugin() } + + private val gfmPlugin by lazy { plugin() } + + public val renderer: Extension by extending { + (CoreExtensions.renderer + providing { JekyllRenderer(it) } + override plugin().renderer) + } + + public val rootCreator: Extension by extending { + jekyllPreprocessors with RootCreator + } + + public val briefCommentPreprocessor: Extension by extending { + jekyllPreprocessors with BriefCommentPreprocessor() + } + + public val packageListCreator: Extension by extending { + jekyllPreprocessors providing { + PackageListCreator(it, RecognizedLinkFormat.DokkaJekyll) + } order { after(rootCreator) } + } + + public val locationProvider: Extension by extending { + dokkaBase.locationProviderFactory providing ::DokkaLocationProviderFactory override listOf(gfmPlugin.locationProvider) + } + + internal val alphaVersionNotifier by extending { + CoreExtensions.postActions providing { ctx -> + PostAction { + ctx.logger.info( + "The Jekyll output format is still in Alpha so you may find bugs and experience migration " + + "issues when using it. You use it at your own risk." + ) + } + } + } + + @OptIn(DokkaPluginApiPreview::class) + override fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement = + PluginApiPreviewAcknowledgement +} + +public class JekyllRenderer( + context: DokkaContext +) : CommonmarkRenderer(context) { + + override val preprocessors: List = context.plugin().query { jekyllPreprocessors } + + override fun buildPage(page: ContentPage, content: (StringBuilder, ContentPage) -> Unit): String { + val builder = StringBuilder() + builder.append("---\n") + builder.append("title: ${page.name}\n") + builder.append("---\n") + content(builder, page) + return builder.toString() + } +} -- cgit