aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/CoreExtensions.kt5
-rw-r--r--core/src/main/kotlin/plugability/DefaultExtensions.kt7
-rw-r--r--core/src/main/kotlin/resolvers/LocationProviderFactory.kt14
-rw-r--r--plugins/base/src/main/kotlin/DokkaBase.kt16
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt11
-rw-r--r--plugins/base/src/main/kotlin/renderers/FileWriter.kt (renamed from core/src/main/kotlin/renderers/FileWriter.kt)3
-rw-r--r--plugins/base/src/main/kotlin/renderers/OutputWriter.kt (renamed from core/src/main/kotlin/renderers/OutputWriter.kt)2
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt3
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt2
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt2
-rw-r--r--plugins/base/src/main/kotlin/resolvers/DefaultLocationProvider.kt (renamed from core/src/main/kotlin/resolvers/DefaultLocationProvider.kt)27
-rw-r--r--plugins/base/src/main/kotlin/resolvers/DefaultLocationProviderFactory.kt9
-rw-r--r--plugins/base/src/main/kotlin/resolvers/ExternalLocationProvider.kt (renamed from core/src/main/kotlin/resolvers/ExternalLocationProvider.kt)2
-rw-r--r--plugins/base/src/main/kotlin/resolvers/LocationProvider.kt (renamed from core/src/main/kotlin/resolvers/LocationProvider.kt)8
14 files changed, 55 insertions, 56 deletions
diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt
index 859e850e..c8314f4d 100644
--- a/core/src/main/kotlin/CoreExtensions.kt
+++ b/core/src/main/kotlin/CoreExtensions.kt
@@ -2,8 +2,6 @@ package org.jetbrains.dokka
import org.jetbrains.dokka.plugability.ExtensionPoint
import org.jetbrains.dokka.renderers.Renderer
-import org.jetbrains.dokka.renderers.OutputWriter
-import org.jetbrains.dokka.resolvers.LocationProviderFactory
import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentationTranslator
import org.jetbrains.dokka.transformers.documentation.DocumentableMerger
import org.jetbrains.dokka.transformers.documentation.DocumentationNodeTransformer
@@ -26,9 +24,6 @@ object CoreExtensions {
val pageTransformer by coreExtension<PageNodeTransformer>()
val renderer by coreExtension<Renderer>()
- val locationProviderFactory by coreExtension<LocationProviderFactory>()
- val outputWriter by coreExtension<OutputWriter>()
-
private fun <T: Any> coreExtension() = object {
operator fun provideDelegate(thisRef: CoreExtensions, property: KProperty<*>): Lazy<ExtensionPoint<T>> =
lazy { ExtensionPoint<T>(thisRef::class.qualifiedName!!, property.name) }
diff --git a/core/src/main/kotlin/plugability/DefaultExtensions.kt b/core/src/main/kotlin/plugability/DefaultExtensions.kt
index 242eb6b8..798e0f1a 100644
--- a/core/src/main/kotlin/plugability/DefaultExtensions.kt
+++ b/core/src/main/kotlin/plugability/DefaultExtensions.kt
@@ -1,20 +1,13 @@
package org.jetbrains.dokka.plugability
import org.jetbrains.dokka.CoreExtensions
-import org.jetbrains.dokka.renderers.FileWriter
-import org.jetbrains.dokka.renderers.OutputWriter
-import org.jetbrains.dokka.resolvers.DefaultLocationProviderFactory
internal object DefaultExtensions {
- private val providerFactory: LazyEvaluated<DefaultLocationProviderFactory> = LazyEvaluated.fromRecipe { DefaultLocationProviderFactory(it) }
- private val outputWriter: LazyEvaluated<OutputWriter> = LazyEvaluated.fromRecipe { FileWriter(it) }
@Suppress("IMPLICIT_CAST_TO_ANY", "UNCHECKED_CAST")
internal fun <T : Any, E : ExtensionPoint<T>> get(point: E, fullContext: DokkaContext): List<T> =
when (point) {
- CoreExtensions.locationProviderFactory -> providerFactory.get(fullContext)
- CoreExtensions.outputWriter -> outputWriter.get(fullContext)
else -> null
}.let { listOfNotNull( it ) as List<T> }
} \ No newline at end of file
diff --git a/core/src/main/kotlin/resolvers/LocationProviderFactory.kt b/core/src/main/kotlin/resolvers/LocationProviderFactory.kt
deleted file mode 100644
index 782795de..00000000
--- a/core/src/main/kotlin/resolvers/LocationProviderFactory.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.jetbrains.dokka.resolvers
-
-import org.jetbrains.dokka.pages.ModulePageNode
-import org.jetbrains.dokka.pages.RootPageNode
-import org.jetbrains.dokka.plugability.DokkaContext
-
-interface LocationProviderFactory {
- fun getLocationProvider(pageNode: RootPageNode): LocationProvider
-}
-
-class DefaultLocationProviderFactory(val context: DokkaContext) : LocationProviderFactory {
-
- override fun getLocationProvider(pageNode: RootPageNode) = DefaultLocationProvider(pageNode, context)
-} \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt
index 9b6e9b1a..fd842dc0 100644
--- a/plugins/base/src/main/kotlin/DokkaBase.kt
+++ b/plugins/base/src/main/kotlin/DokkaBase.kt
@@ -1,6 +1,11 @@
package org.jetbrains.dokka.base
import org.jetbrains.dokka.CoreExtensions
+import org.jetbrains.dokka.base.renderers.FileWriter
+import org.jetbrains.dokka.base.renderers.OutputWriter
+import org.jetbrains.dokka.base.renderers.html.HtmlRenderer
+import org.jetbrains.dokka.base.resolvers.DefaultLocationProviderFactory
+import org.jetbrains.dokka.base.resolvers.LocationProviderFactory
import org.jetbrains.dokka.base.transformers.descriptors.DefaultDescriptorToDocumentationTranslator
import org.jetbrains.dokka.base.transformers.documentables.DefaultDocumentableMerger
import org.jetbrains.dokka.base.transformers.documentables.DefaultDocumentablesToPageTranslator
@@ -12,11 +17,12 @@ import org.jetbrains.dokka.base.transformers.pages.merger.PageNodeMerger
import org.jetbrains.dokka.base.transformers.pages.merger.SameMethodNamePageMergerStrategy
import org.jetbrains.dokka.base.transformers.psi.DefaultPsiToDocumentationTranslator
import org.jetbrains.dokka.plugability.DokkaPlugin
-import org.jetbrains.dokka.renderers.html.HtmlRenderer
class DokkaBase : DokkaPlugin() {
val pageMergerStrategy by extensionPoint<PageMergerStrategy>()
val commentsToContentConverter by extensionPoint<CommentsToContentConverter>()
+ val locationproviderFactory by extensionPoint<LocationProviderFactory>()
+ val outputWriter by extensionPoint<OutputWriter>()
val descriptorToDocumentationTranslator by extending(isFallback = true) {
CoreExtensions.descriptorToDocumentationTranslator providing ::DefaultDescriptorToDocumentationTranslator
@@ -57,4 +63,12 @@ class DokkaBase : DokkaPlugin() {
val htmlRenderer by extending {
CoreExtensions.renderer providing ::HtmlRenderer applyIf { format == "html" }
}
+
+ val locationProvider by extending(isFallback = true) {
+ locationproviderFactory providing ::DefaultLocationProviderFactory
+ }
+
+ val fileWriter by extending(isFallback = true) {
+ outputWriter providing ::FileWriter
+ }
} \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
index c6183cf3..951545d2 100644
--- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -1,18 +1,19 @@
package org.jetbrains.dokka.base.renderers
-import org.jetbrains.dokka.CoreExtensions
+import org.jetbrains.dokka.base.DokkaBase
+import org.jetbrains.dokka.base.resolvers.LocationProvider
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
-import org.jetbrains.dokka.renderers.OutputWriter
+import org.jetbrains.dokka.plugability.plugin
+import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.renderers.Renderer
-import org.jetbrains.dokka.resolvers.LocationProvider
import org.jetbrains.dokka.transformers.pages.PageNodeTransformer
abstract class DefaultRenderer<T>(
protected val context: DokkaContext
) : Renderer {
- protected val outputWriter = context.single(CoreExtensions.outputWriter)
+ protected val outputWriter = context.plugin<DokkaBase>().querySingle { outputWriter }
protected lateinit var locationProvider: LocationProvider
private set
@@ -116,7 +117,7 @@ abstract class DefaultRenderer<T>(
val newRoot = preprocessors.fold(root) { acc, t -> t(acc) }
locationProvider =
- context.single(CoreExtensions.locationProviderFactory).getLocationProvider(newRoot)
+ context.plugin<DokkaBase>().querySingle { locationproviderFactory }.getLocationProvider(newRoot)
root.children<ModulePageNode>().forEach { renderPackageList(it) }
diff --git a/core/src/main/kotlin/renderers/FileWriter.kt b/plugins/base/src/main/kotlin/renderers/FileWriter.kt
index 727a8d21..5d3067fc 100644
--- a/core/src/main/kotlin/renderers/FileWriter.kt
+++ b/plugins/base/src/main/kotlin/renderers/FileWriter.kt
@@ -1,6 +1,7 @@
-package org.jetbrains.dokka.renderers
+package org.jetbrains.dokka.base.renderers
import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.renderers.OutputWriter
import java.io.File
import java.io.IOException
import java.net.URI
diff --git a/core/src/main/kotlin/renderers/OutputWriter.kt b/plugins/base/src/main/kotlin/renderers/OutputWriter.kt
index e317f8ef..a6fda51a 100644
--- a/core/src/main/kotlin/renderers/OutputWriter.kt
+++ b/plugins/base/src/main/kotlin/renderers/OutputWriter.kt
@@ -1,4 +1,4 @@
-package org.jetbrains.dokka.renderers
+package org.jetbrains.dokka.base.renderers
interface OutputWriter {
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index c9270681..8bf00043 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -1,4 +1,4 @@
-package org.jetbrains.dokka.renderers.html
+package org.jetbrains.dokka.base.renderers.html
import kotlinx.html.*
import kotlinx.html.stream.createHTML
@@ -7,7 +7,6 @@ import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.Function
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
-import org.jetbrains.dokka.renderers.OutputWriter
import java.io.File
open class HtmlRenderer(
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
index 4a2fb40d..ad574769 100644
--- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
@@ -1,4 +1,4 @@
-package org.jetbrains.dokka.renderers.html
+package org.jetbrains.dokka.base.renderers.html
import kotlinx.html.*
import kotlinx.html.stream.createHTML
diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
index 09164d97..ecd2e89a 100644
--- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
@@ -1,4 +1,4 @@
-package org.jetbrains.dokka.renderers.html
+package org.jetbrains.dokka.base.renderers.html
import kotlinx.html.h1
import kotlinx.html.id
diff --git a/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/DefaultLocationProvider.kt
index 65d2f794..2238b0c3 100644
--- a/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/DefaultLocationProvider.kt
@@ -1,4 +1,4 @@
-package org.jetbrains.dokka.resolvers
+package org.jetbrains.dokka.base.resolvers
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.pages.*
@@ -78,34 +78,29 @@ fun DRI.toJavadocLocation(jdkVersion: Int): String { // TODO: classes without pa
return "$packageLink/package-summary.html".htmlEscape()
}
val classLink = if (packageLink == null) "$classNames.html" else "$packageLink/$classNames.html"
- if (callable == null) {
- return classLink.htmlEscape()
- }
+ val callableChecked = callable ?: return classLink.htmlEscape()
- val callableLink = "$classLink#${callable.name}" + when {
- jdkVersion < 8 -> "(${callable.params.joinToString(", ")})"
- jdkVersion < 10 -> "-${callable.params.joinToString("-")}-"
- else -> "(${callable.params.joinToString(",")})"
+ val callableLink = "$classLink#${callableChecked.name}" + when {
+ jdkVersion < 8 -> "(${callableChecked.params.joinToString(", ")})"
+ jdkVersion < 10 -> "-${callableChecked.params.joinToString("-")}-"
+ else -> "(${callableChecked.params.joinToString(",")})"
}
return callableLink.htmlEscape()
}
fun DRI.toDokkaLocation(extension: String): String { // TODO: classes without packages?
- if (classNames == null) {
- return "$packageName/index$extension"
- }
+ val classNamesChecked = classNames ?: return "$packageName/index$extension"
+
val classLink = if (packageName == null) {
""
} else {
"$packageName/"
- } + classNames.split('.').joinToString("/", transform = ::identifierToFilename)
+ } + classNamesChecked.split('.').joinToString("/", transform = ::identifierToFilename)
- if (callable == null) {
- return "$classLink/index$extension"
- }
+ val callableChecked = callable ?: return "$classLink/index$extension"
- return "$classLink/${identifierToFilename(callable.name)}$extension"
+ return "$classLink/${identifierToFilename(callableChecked.name)}$extension"
}
private val reservedFilenames = setOf("index", "con", "aux", "lst", "prn", "nul", "eof", "inp", "out")
diff --git a/plugins/base/src/main/kotlin/resolvers/DefaultLocationProviderFactory.kt b/plugins/base/src/main/kotlin/resolvers/DefaultLocationProviderFactory.kt
new file mode 100644
index 00000000..c649e22b
--- /dev/null
+++ b/plugins/base/src/main/kotlin/resolvers/DefaultLocationProviderFactory.kt
@@ -0,0 +1,9 @@
+package org.jetbrains.dokka.base.resolvers
+
+import org.jetbrains.dokka.pages.RootPageNode
+import org.jetbrains.dokka.plugability.DokkaContext
+
+class DefaultLocationProviderFactory(private val context: DokkaContext) : LocationProviderFactory {
+
+ override fun getLocationProvider(pageNode: RootPageNode) = DefaultLocationProvider(pageNode, context)
+} \ No newline at end of file
diff --git a/core/src/main/kotlin/resolvers/ExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/ExternalLocationProvider.kt
index d3d8fa0d..7c0e9952 100644
--- a/core/src/main/kotlin/resolvers/ExternalLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/ExternalLocationProvider.kt
@@ -1,4 +1,4 @@
-package org.jetbrains.dokka.resolvers
+package org.jetbrains.dokka.base.resolvers
import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink
import org.jetbrains.dokka.links.DRI
diff --git a/core/src/main/kotlin/resolvers/LocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/LocationProvider.kt
index 3bc9ab72..13f4563c 100644
--- a/core/src/main/kotlin/resolvers/LocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/LocationProvider.kt
@@ -1,9 +1,10 @@
-package org.jetbrains.dokka.resolvers
+package org.jetbrains.dokka.base.resolvers
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.pages.ContentPage
import org.jetbrains.dokka.pages.PageNode
import org.jetbrains.dokka.pages.PlatformData
+import org.jetbrains.dokka.pages.RootPageNode
interface LocationProvider {
fun resolve(dri: DRI, platforms: List<PlatformData>, context: PageNode? = null): String
@@ -11,3 +12,8 @@ interface LocationProvider {
fun resolveRoot(node: PageNode): String
fun ancestors(node: PageNode): List<PageNode>
}
+
+interface LocationProviderFactory {
+ fun getLocationProvider(pageNode: RootPageNode): LocationProvider
+}
+