diff options
Diffstat (limited to 'plugins/jekyll/src/main/kotlin/JekyllPlugin.kt')
-rw-r--r-- | plugins/jekyll/src/main/kotlin/JekyllPlugin.kt | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt b/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt new file mode 100644 index 00000000..45afb072 --- /dev/null +++ b/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt @@ -0,0 +1,57 @@ +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.gfm.CommonmarkRenderer +import org.jetbrains.dokka.gfm.GfmPlugin +import org.jetbrains.dokka.pages.* +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.DokkaPlugin +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.query +import org.jetbrains.dokka.transformers.pages.PageTransformer +import java.lang.StringBuilder + + +class JekyllPlugin : DokkaPlugin() { + + val jekyllPreprocessors by extensionPoint<PageTransformer>() + + val renderer by extending { + (CoreExtensions.renderer + providing { JekyllRenderer(it) } + override plugin<GfmPlugin>().renderer) + } + + val rootCreator by extending { + jekyllPreprocessors with RootCreator + } + + val packageListCreator by extending { + jekyllPreprocessors providing { + PackageListCreator( + it, + "jekyll", + "md" + ) + } order { after(rootCreator) } + } +} + +class JekyllRenderer( + context: DokkaContext +) : CommonmarkRenderer(context) { + + override val preprocessors = context.plugin<JekyllPlugin>().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() + } +} |