aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2020-11-13 22:05:15 +0100
committerBłażej Kardyś <bkardys@virtuslab.com>2020-11-27 03:15:02 +0100
commitc203be9fb65ee221875b4e1c865bcd289a85e69c (patch)
tree40384c13d98f722dbb7c819f8ebadb6caac01651 /plugins
parent4639cbda50359c8dcbaa61f0a960c002c060d3b9 (diff)
downloaddokka-c203be9fb65ee221875b4e1c865bcd289a85e69c.tar.gz
dokka-c203be9fb65ee221875b4e1c865bcd289a85e69c.tar.bz2
dokka-c203be9fb65ee221875b4e1c865bcd289a85e69c.zip
Adding multimodule all modules page creation for gfm
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt4
-rw-r--r--plugins/base/src/test/kotlin/translators/JavadocInheritDocsTest.kt4
-rw-r--r--plugins/base/src/test/kotlin/translators/JavadocInheritedDocTagsTest.kt4
-rw-r--r--plugins/gfm/gfm-all-module-page/build.gradle.kts11
-rw-r--r--plugins/gfm/gfm-all-module-page/src/main/kotlin/org/jetbrains/dokka/gfm/allModulesPage/GfmAllModulesPagaPlugin.kt20
-rw-r--r--plugins/gfm/gfm-all-module-page/src/main/kotlin/org/jetbrains/dokka/gfm/allModulesPage/GfmMultimoduleLocationProvider.kt41
-rw-r--r--plugins/gfm/gfm-all-module-page/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin1
-rw-r--r--plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt36
-rw-r--r--plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt16
-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
-rw-r--r--plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt2
-rw-r--r--plugins/gfm/src/test/kotlin/renderers/gfm/GfmRenderingOnlyTestBase.kt2
-rw-r--r--plugins/gfm/src/test/kotlin/renderers/gfm/GroupWrappingTest.kt2
-rw-r--r--plugins/gfm/src/test/kotlin/renderers/gfm/SimpleElementsTest.kt2
-rw-r--r--plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt2
-rw-r--r--plugins/jekyll/src/main/kotlin/JekyllPlugin.kt3
16 files changed, 140 insertions, 64 deletions
diff --git a/plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt b/plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt
index 58413074..1a2e9fa3 100644
--- a/plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt
+++ b/plugins/base/src/test/kotlin/transformers/DivisionSwitchTest.kt
@@ -8,13 +8,13 @@ import org.jetbrains.dokka.pages.ClasslikePageNode
import org.jetbrains.dokka.pages.ContentHeader
import org.jetbrains.dokka.pages.ContentNode
import org.jetbrains.dokka.pages.ContentText
-import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
+import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.kotlin.utils.addIfNotNull
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
-class DivisionSwitchTest : AbstractCoreTest() {
+class DivisionSwitchTest : BaseAbstractTest() {
private val query = """
|/src/source0.kt
diff --git a/plugins/base/src/test/kotlin/translators/JavadocInheritDocsTest.kt b/plugins/base/src/test/kotlin/translators/JavadocInheritDocsTest.kt
index 8fac13c9..4e2cf70f 100644
--- a/plugins/base/src/test/kotlin/translators/JavadocInheritDocsTest.kt
+++ b/plugins/base/src/test/kotlin/translators/JavadocInheritDocsTest.kt
@@ -4,13 +4,13 @@ import org.jetbrains.dokka.model.doc.CustomDocTag
import org.jetbrains.dokka.model.doc.Description
import org.jetbrains.dokka.model.doc.P
import org.jetbrains.dokka.model.doc.Text
-import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
+import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.junit.Ignore
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
-class JavadocInheritDocsTest : AbstractCoreTest() {
+class JavadocInheritDocsTest : BaseAbstractTest() {
val configuration = dokkaConfiguration {
sourceSets {
sourceSet {
diff --git a/plugins/base/src/test/kotlin/translators/JavadocInheritedDocTagsTest.kt b/plugins/base/src/test/kotlin/translators/JavadocInheritedDocTagsTest.kt
index a7d4f057..c29c4e96 100644
--- a/plugins/base/src/test/kotlin/translators/JavadocInheritedDocTagsTest.kt
+++ b/plugins/base/src/test/kotlin/translators/JavadocInheritedDocTagsTest.kt
@@ -4,14 +4,14 @@ import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.links.PointingToDeclaration
import org.jetbrains.dokka.model.DModule
import org.jetbrains.dokka.model.doc.*
-import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
+import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.jetbrains.dokka.model.doc.Deprecated as DokkaDeprecatedTag
import org.jetbrains.dokka.model.doc.Throws as DokkaThrowsTag
-class JavadocInheritedDocTagsTest : AbstractCoreTest() {
+class JavadocInheritedDocTagsTest : BaseAbstractTest() {
private val configuration = dokkaConfiguration {
sourceSets {
sourceSet {
diff --git a/plugins/gfm/gfm-all-module-page/build.gradle.kts b/plugins/gfm/gfm-all-module-page/build.gradle.kts
new file mode 100644
index 00000000..66deb291
--- /dev/null
+++ b/plugins/gfm/gfm-all-module-page/build.gradle.kts
@@ -0,0 +1,11 @@
+import org.jetbrains.registerDokkaArtifactPublication
+
+dependencies {
+ implementation(project(":plugins:base"))
+ implementation(project(":plugins:gfm"))
+ implementation(project(":plugins:all-module-page"))
+}
+
+registerDokkaArtifactPublication("dokkaGfmAllModulePage") {
+ artifactId = "gfm-all-module-page-plugin"
+} \ No newline at end of file
diff --git a/plugins/gfm/gfm-all-module-page/src/main/kotlin/org/jetbrains/dokka/gfm/allModulesPage/GfmAllModulesPagaPlugin.kt b/plugins/gfm/gfm-all-module-page/src/main/kotlin/org/jetbrains/dokka/gfm/allModulesPage/GfmAllModulesPagaPlugin.kt
new file mode 100644
index 00000000..8052a762
--- /dev/null
+++ b/plugins/gfm/gfm-all-module-page/src/main/kotlin/org/jetbrains/dokka/gfm/allModulesPage/GfmAllModulesPagaPlugin.kt
@@ -0,0 +1,20 @@
+package org.jetbrains.dokka.gfm.allModulesPage
+
+import org.jetbrains.dokka.allModulesPage.AllModulesPagePlugin
+import org.jetbrains.dokka.base.DokkaBase
+import org.jetbrains.dokka.gfm.GfmPlugin
+import org.jetbrains.dokka.plugability.DokkaPlugin
+
+class GfmAllModulesPagePlugin : DokkaPlugin() {
+
+ private val gfmPlugin by lazy { plugin<GfmPlugin>() }
+
+ private val dokkaBase by lazy { plugin<DokkaBase>() }
+
+ private val allModulesPagePlugin by lazy { plugin<AllModulesPagePlugin>() }
+
+ val locationProvider by extending {
+ (dokkaBase.locationProviderFactory providing GfmMultimoduleLocationProvider::Factory
+ override listOf(allModulesPagePlugin.multimoduleLocationProvider, gfmPlugin.locationProvider))
+ }
+} \ No newline at end of file
diff --git a/plugins/gfm/gfm-all-module-page/src/main/kotlin/org/jetbrains/dokka/gfm/allModulesPage/GfmMultimoduleLocationProvider.kt b/plugins/gfm/gfm-all-module-page/src/main/kotlin/org/jetbrains/dokka/gfm/allModulesPage/GfmMultimoduleLocationProvider.kt
new file mode 100644
index 00000000..d49be426
--- /dev/null
+++ b/plugins/gfm/gfm-all-module-page/src/main/kotlin/org/jetbrains/dokka/gfm/allModulesPage/GfmMultimoduleLocationProvider.kt
@@ -0,0 +1,41 @@
+package org.jetbrains.dokka.gfm.allModulesPage
+
+import org.jetbrains.dokka.base.resolvers.local.DokkaBaseLocationProvider
+import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider
+import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory
+import org.jetbrains.dokka.gfm.location.MarkdownLocationProvider
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.model.DisplaySourceSet
+import org.jetbrains.dokka.pages.PageNode
+import org.jetbrains.dokka.pages.RootPageNode
+import org.jetbrains.dokka.plugability.DokkaContext
+
+class GfmMultimoduleLocationProvider(private val root: RootPageNode, context: DokkaContext) : DokkaBaseLocationProvider(root, context, ".md") {
+
+ private val defaultLocationProvider = MarkdownLocationProvider(root, context)
+
+ val paths = context.configuration.modules.map {
+ it.name to it.relativePathToOutputDirectory
+ }.toMap()
+
+ override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?) =
+ dri.takeIf { it.packageName == MULTIMODULE_PACKAGE_PLACEHOLDER }?.classNames?.let { paths[it] }?.let {
+ "$it/${DokkaLocationProvider.identifierToFilename(dri.classNames.orEmpty())}/index.md"
+ } ?: defaultLocationProvider.resolve(dri, sourceSets, context)
+
+ override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean) =
+ defaultLocationProvider.resolve(node, context, skipExtension)
+
+ override fun pathToRoot(from: PageNode): String = defaultLocationProvider.pathToRoot(from)
+
+ override fun ancestors(node: PageNode): List<PageNode> = listOf(root)
+
+ companion object {
+ const val MULTIMODULE_PACKAGE_PLACEHOLDER = ".ext"
+ }
+
+ class Factory(private val context: DokkaContext): LocationProviderFactory {
+ override fun getLocationProvider(pageNode: RootPageNode) =
+ GfmMultimoduleLocationProvider(pageNode, context)
+ }
+} \ No newline at end of file
diff --git a/plugins/gfm/gfm-all-module-page/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin b/plugins/gfm/gfm-all-module-page/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin
new file mode 100644
index 00000000..1a8acd51
--- /dev/null
+++ b/plugins/gfm/gfm-all-module-page/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin
@@ -0,0 +1 @@
+org.jetbrains.dokka.gfm.allModulesPage.GfmAllModulesPagePlugin \ No newline at end of file
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
diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt
index a205aa2f..b0eead1b 100644
--- a/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt
+++ b/plugins/gfm/src/test/kotlin/renderers/gfm/DivergentTest.kt
@@ -2,7 +2,7 @@ package renderers.gfm
import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.gfm.CommonmarkRenderer
+import org.jetbrains.dokka.gfm.renderer.CommonmarkRenderer
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.pages.ContentDivergentGroup
import org.junit.jupiter.api.Test
diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/GfmRenderingOnlyTestBase.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/GfmRenderingOnlyTestBase.kt
index a118a20e..165aef98 100644
--- a/plugins/gfm/src/test/kotlin/renderers/gfm/GfmRenderingOnlyTestBase.kt
+++ b/plugins/gfm/src/test/kotlin/renderers/gfm/GfmRenderingOnlyTestBase.kt
@@ -2,7 +2,7 @@ package renderers.gfm
import org.jetbrains.dokka.DokkaConfigurationImpl
import org.jetbrains.dokka.gfm.GfmPlugin
-import org.jetbrains.dokka.gfm.MarkdownLocationProviderFactory
+import org.jetbrains.dokka.gfm.location.MarkdownLocationProviderFactory
import org.jetbrains.dokka.testApi.context.MockContext
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.renderers.RootCreator
diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/GroupWrappingTest.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/GroupWrappingTest.kt
index 53bee558..93aee5e1 100644
--- a/plugins/gfm/src/test/kotlin/renderers/gfm/GroupWrappingTest.kt
+++ b/plugins/gfm/src/test/kotlin/renderers/gfm/GroupWrappingTest.kt
@@ -1,6 +1,6 @@
package renderers.gfm
-import org.jetbrains.dokka.gfm.CommonmarkRenderer
+import org.jetbrains.dokka.gfm.renderer.CommonmarkRenderer
import org.jetbrains.dokka.pages.TextStyle
import org.junit.jupiter.api.Test
import renderers.*
diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/SimpleElementsTest.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/SimpleElementsTest.kt
index 9055fbc3..7b887071 100644
--- a/plugins/gfm/src/test/kotlin/renderers/gfm/SimpleElementsTest.kt
+++ b/plugins/gfm/src/test/kotlin/renderers/gfm/SimpleElementsTest.kt
@@ -1,6 +1,6 @@
package renderers.gfm
-import org.jetbrains.dokka.gfm.CommonmarkRenderer
+import org.jetbrains.dokka.gfm.renderer.CommonmarkRenderer
import org.junit.jupiter.api.Test
import renderers.testPage
import org.jetbrains.dokka.links.DRI
diff --git a/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt b/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt
index 0d845a98..4d05c602 100644
--- a/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt
+++ b/plugins/gfm/src/test/kotlin/renderers/gfm/SourceSetDependentHintTest.kt
@@ -2,7 +2,7 @@ package renderers.gfm
import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.gfm.CommonmarkRenderer
+import org.jetbrains.dokka.gfm.renderer.CommonmarkRenderer
import org.jetbrains.dokka.pages.TextStyle
import org.junit.jupiter.api.Test
import renderers.testPage
diff --git a/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt b/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt
index 81a49812..dfe3226a 100644
--- a/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt
+++ b/plugins/jekyll/src/main/kotlin/JekyllPlugin.kt
@@ -1,11 +1,10 @@
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.shared.RecognizedLinkFormat
-import org.jetbrains.dokka.gfm.CommonmarkRenderer
+import org.jetbrains.dokka.gfm.renderer.CommonmarkRenderer
import org.jetbrains.dokka.gfm.GfmPlugin
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext