diff options
Diffstat (limited to 'plugins/gfm/src/main/kotlin')
-rw-r--r-- | plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt | 36 | ||||
-rw-r--r-- | plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt | 16 | ||||
-rw-r--r-- | plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt (renamed from plugins/gfm/src/main/kotlin/GfmPlugin.kt) | 54 |
3 files changed, 55 insertions, 51 deletions
diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt new file mode 100644 index 00000000..3f2eae4d --- /dev/null +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt @@ -0,0 +1,36 @@ +package org.jetbrains.dokka.gfm + +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.shared.RecognizedLinkFormat +import org.jetbrains.dokka.gfm.location.MarkdownLocationProviderFactory +import org.jetbrains.dokka.gfm.renderer.CommonmarkRenderer +import org.jetbrains.dokka.plugability.DokkaPlugin +import org.jetbrains.dokka.transformers.pages.PageTransformer + +class GfmPlugin : DokkaPlugin() { + + val gfmPreprocessors by extensionPoint<PageTransformer>() + + private val dokkaBase by lazy { plugin<DokkaBase>() } + + val renderer by extending { + CoreExtensions.renderer providing ::CommonmarkRenderer override dokkaBase.htmlRenderer + } + + val locationProvider by extending { + dokkaBase.locationProviderFactory providing ::MarkdownLocationProviderFactory override dokkaBase.locationProvider + } + + val rootCreator by extending { + gfmPreprocessors with RootCreator + } + + val packageListCreator by extending { + (gfmPreprocessors + providing { PackageListCreator(it, RecognizedLinkFormat.DokkaGFM) } + order { after(rootCreator) }) + } +} diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt new file mode 100644 index 00000000..6f96dbd5 --- /dev/null +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt @@ -0,0 +1,16 @@ +package org.jetbrains.dokka.gfm.location + +import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider +import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory +import org.jetbrains.dokka.pages.RootPageNode +import org.jetbrains.dokka.plugability.DokkaContext + +class MarkdownLocationProviderFactory(val context: DokkaContext) : LocationProviderFactory { + override fun getLocationProvider(pageNode: RootPageNode) = MarkdownLocationProvider(pageNode, context) +} + +class MarkdownLocationProvider( + pageGraphRoot: RootPageNode, + dokkaContext: DokkaContext +) : DokkaLocationProvider(pageGraphRoot, dokkaContext, ".md") + diff --git a/plugins/gfm/src/main/kotlin/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt index 780e4cb2..0655ce20 100644 --- a/plugins/gfm/src/main/kotlin/GfmPlugin.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt @@ -1,52 +1,14 @@ -package org.jetbrains.dokka.gfm +package org.jetbrains.dokka.gfm.renderer -import org.jetbrains.dokka.CoreExtensions -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.DokkaException -import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.DefaultRenderer -import org.jetbrains.dokka.base.renderers.PackageListCreator -import org.jetbrains.dokka.base.renderers.RootCreator import org.jetbrains.dokka.base.renderers.isImage -import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider -import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory +import org.jetbrains.dokka.gfm.GfmPlugin import org.jetbrains.dokka.model.DisplaySourceSet -import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat 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 - -class GfmPlugin : DokkaPlugin() { - - val gfmPreprocessors by extensionPoint<PageTransformer>() - - private val dokkaBase by lazy { plugin<DokkaBase>() } - - val renderer by extending { - (CoreExtensions.renderer - providing { CommonmarkRenderer(it) } - override dokkaBase.htmlRenderer) - } - - val locationProvider by extending { - (dokkaBase.locationProviderFactory - providing { MarkdownLocationProviderFactory(it) } - override dokkaBase.locationProvider) - } - - val rootCreator by extending { - gfmPreprocessors with RootCreator - } - - val packageListCreator by extending { - (gfmPreprocessors - providing { PackageListCreator(it, RecognizedLinkFormat.DokkaGFM) } - order { after(rootCreator) }) - } -} open class CommonmarkRenderer( context: DokkaContext @@ -357,14 +319,4 @@ open class CommonmarkRenderer( private fun StringBuilder.buildSourceSetTags(sourceSets: Set<DisplaySourceSet>) = append(sourceSets.joinToString(prefix = "[", postfix = "]") { it.name }) -} - -class MarkdownLocationProviderFactory(val context: DokkaContext) : LocationProviderFactory { - - override fun getLocationProvider(pageNode: RootPageNode) = MarkdownLocationProvider(pageNode, context) -} - -class MarkdownLocationProvider( - pageGraphRoot: RootPageNode, - dokkaContext: DokkaContext -) : DokkaLocationProvider(pageGraphRoot, dokkaContext, ".md") +}
\ No newline at end of file |