aboutsummaryrefslogtreecommitdiff
path: root/plugins/gfm/src/main
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-04-03 13:57:33 +0200
committerKamil Doległo <kamilok1965@users.noreply.github.com>2020-04-15 14:33:24 +0200
commitfee86d79a3aa7357c68c2f8f519d187f43447e8c (patch)
tree7ba7ef24bf7733e7778f0a5344756ed39c364a3a /plugins/gfm/src/main
parent64e600b126ae8edcfbb3c2716febb01d221520b5 (diff)
downloaddokka-fee86d79a3aa7357c68c2f8f519d187f43447e8c.tar.gz
dokka-fee86d79a3aa7357c68c2f8f519d187f43447e8c.tar.bz2
dokka-fee86d79a3aa7357c68c2f8f519d187f43447e8c.zip
Refactor package list to be a preprocessor
Diffstat (limited to 'plugins/gfm/src/main')
-rw-r--r--plugins/gfm/src/main/kotlin/GfmPlugin.kt25
1 files changed, 24 insertions, 1 deletions
diff --git a/plugins/gfm/src/main/kotlin/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/GfmPlugin.kt
index 7c0ce509..91b6f7b5 100644
--- a/plugins/gfm/src/main/kotlin/GfmPlugin.kt
+++ b/plugins/gfm/src/main/kotlin/GfmPlugin.kt
@@ -3,17 +3,23 @@ package org.jetbrains.dokka.gfm
import org.jetbrains.dokka.CoreExtensions
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.renderers.DefaultRenderer
-import org.jetbrains.dokka.base.renderers.OutputWriter
+import org.jetbrains.dokka.base.renderers.PackageListCreator
+import org.jetbrains.dokka.base.renderers.RootCreator
import org.jetbrains.dokka.base.resolvers.local.DefaultLocationProvider
import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory
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 GfmPlugin : DokkaPlugin() {
+ val gfmPreprocessors by extensionPoint<PageTransformer>()
+
val renderer by extending {
CoreExtensions.renderer providing { CommonmarkRenderer(it) } applyIf { format == "gfm" }
}
@@ -21,11 +27,28 @@ class GfmPlugin : DokkaPlugin() {
val locationProvider by extending {
plugin<DokkaBase>().locationProviderFactory providing { MarkdownLocationProviderFactory(it) } applyIf { format == "gfm" }
}
+
+ val rootCreator by extending {
+ gfmPreprocessors with RootCreator
+ }
+
+ val packageListCreator by extending {
+ gfmPreprocessors providing {
+ PackageListCreator(
+ it,
+ "gfm",
+ "md"
+ )
+ } order { after(rootCreator) }
+ }
}
open class CommonmarkRenderer(
context: DokkaContext
) : DefaultRenderer<StringBuilder>(context) {
+
+ override val preprocessors = context.plugin<GfmPlugin>().query { gfmPreprocessors }
+
override fun StringBuilder.buildHeader(level: Int, content: StringBuilder.() -> Unit) {
buildParagraph()
append("#".repeat(level) + " ")