Skip to content

Commit

Permalink
Change jekyll links to be .html
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinAman committed Jun 28, 2021
1 parent c2182b7 commit 16db741
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,7 @@ class DefaultExternalModuleLinkResolver(val context: DokkaContext) : ExternalMod
context.configuration.modules.firstOrNull { it.name == moduleName }
?.let { module ->
val packageList = loadPackageListForModule(module)
val extension = when (packageList?.linkFormat) {
RecognizedLinkFormat.KotlinWebsiteHtml,
RecognizedLinkFormat.DokkaOldHtml,
RecognizedLinkFormat.DokkaHtml -> ".html"
RecognizedLinkFormat.DokkaGFM,
RecognizedLinkFormat.DokkaJekyll -> ".md"
else -> ""
}
val extension = packageList?.linkFormat?.linkExtension?.let { ".$it" }.orEmpty()
"${module.relativePathToOutputDirectory}/index$extension"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ enum class RecognizedLinkFormat(override val formatName: String, override val li
DokkaHtml("html-v1", "html"),
DokkaJavadoc("javadoc-v1", "html"),
DokkaGFM("gfm-v1", "md"),
DokkaJekyll("jekyll-v1", "md"),
DokkaJekyll("jekyll-v1", "html"),
Javadoc1("javadoc1", "html"),
Javadoc8("javadoc8", "html"),
Javadoc10("javadoc10", "html"),
Expand Down
17 changes: 17 additions & 0 deletions plugins/jekyll/jekyll-template-processing/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import org.jetbrains.registerDokkaArtifactPublication

dependencies {
implementation(project(":plugins:base"))
implementation(project(":plugins:jekyll"))
implementation(project(":plugins:all-modules-page"))
implementation(project(":plugins:templating"))
implementation(project(":plugins:gfm"))
implementation(project(":plugins:gfm:gfm-template-processing"))

val coroutines_version: String by project
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
}

registerDokkaArtifactPublication("dokkaJekyllTemplateProcessing") {
artifactId = "jekyll-template-processing-plugin"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.jetbrains.dokka.gfm.templateProcessing

import org.jetbrains.dokka.allModulesPage.AllModulesPagePlugin
import org.jetbrains.dokka.allModulesPage.MultimoduleLocationProvider
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProviderFactory
import org.jetbrains.dokka.gfm.GfmPlugin
import org.jetbrains.dokka.jekyll.JekyllPlugin
import org.jetbrains.dokka.plugability.DokkaPlugin

class JekyllTemplateProcessingPlugin : DokkaPlugin() {

private val allModulesPagePlugin by lazy { plugin<AllModulesPagePlugin>() }

private val jekyllPlugin by lazy { plugin<JekyllPlugin>() }
private val gfmPlugin by lazy { plugin<GfmPlugin>() }
private val gfmTemplatingPlugin by lazy { plugin<GfmTemplateProcessingPlugin>() }

private val dokkaBase by lazy { plugin<DokkaBase>() }

val jekyllLocationProvider by extending {
dokkaBase.locationProviderFactory providing MultimoduleLocationProvider::Factory override listOf(
jekyllPlugin.locationProvider,
gfmPlugin.locationProvider,
gfmTemplatingPlugin.gfmLocationProvider,
allModulesPagePlugin.multimoduleLocationProvider
)
}

val jekyllPartialLocationProvider by extending {
allModulesPagePlugin.partialLocationProviderFactory providing ::DokkaLocationProviderFactory override listOf(
allModulesPagePlugin.baseLocationProviderFactory,
gfmTemplatingPlugin.gfmPartialLocationProvider
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.jetbrains.dokka.gfm.templateProcessing.JekyllTemplateProcessingPlugin
11 changes: 11 additions & 0 deletions plugins/jekyll/src/main/kotlin/JekyllPlugin.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
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.shared.RecognizedLinkFormat
import org.jetbrains.dokka.gfm.renderer.CommonmarkRenderer
import org.jetbrains.dokka.gfm.GfmPlugin
import org.jetbrains.dokka.gfm.location.MarkdownLocationProvider
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.DokkaPlugin
Expand All @@ -19,6 +22,10 @@ class JekyllPlugin : DokkaPlugin() {

val jekyllPreprocessors by extensionPoint<PageTransformer>()

private val dokkaBase by lazy { plugin<DokkaBase>() }

private val gfmPlugin by lazy { plugin<GfmPlugin>() }

val renderer by extending {
(CoreExtensions.renderer
providing { JekyllRenderer(it) }
Expand All @@ -34,6 +41,10 @@ class JekyllPlugin : DokkaPlugin() {
PackageListCreator(it, RecognizedLinkFormat.DokkaJekyll)
} order { after(rootCreator) }
}

val locationProvider by extending {
dokkaBase.locationProviderFactory providing { ctx -> DokkaLocationProviderFactory(ctx) } override listOf(gfmPlugin.locationProvider)
}
}

class JekyllRenderer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ internal class DokkaArtifacts(private val project: Project) {
val javadocPlugin get() = fromModuleName("javadoc-plugin")
val gfmPlugin get() = fromModuleName("gfm-plugin")
val gfmTemplateProcessing get() = fromModuleName("gfm-template-processing-plugin")
val jekyllTemplateProcessing get() = fromModuleName("jekyll-template-processing-plugin")
val jekyllPlugin get() = fromModuleName("jekyll-plugin")
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ open class DokkaPlugin : Plugin<Project> {
description = "Generates documentation in GitHub flavored markdown format"
}

project.setupDokkaTasks("dokkaJekyll", allModulesPageAndTemplateProcessing = project.dokkaArtifacts.gfmTemplateProcessing) {
project.setupDokkaTasks("dokkaJekyll", allModulesPageAndTemplateProcessing = project.dokkaArtifacts.jekyllTemplateProcessing) {
plugins.dependencies.add(project.dokkaArtifacts.jekyllPlugin)
description = "Generates documentation in Jekyll flavored markdown format"
}
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ include("plugins:mathjax")
include("plugins:gfm")
include("plugins:gfm:gfm-template-processing")
include("plugins:jekyll")
include("plugins:jekyll:jekyll-template-processing")
include("plugins:kotlin-as-java")
include("plugins:javadoc")

Expand Down

0 comments on commit 16db741

Please sign in to comment.