aboutsummaryrefslogtreecommitdiff
path: root/plugins/javadoc/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/javadoc/src/main')
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt41
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt33
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt2
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToHtmlTranslator.kt4
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt2
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt24
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt8
7 files changed, 71 insertions, 43 deletions
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt
index 0c322a82..cf45ef75 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt
@@ -1,21 +1,27 @@
package org.jetbrains.dokka.javadoc
-import org.jetbrains.dokka.javadoc.JavadocDocumentableToPageTranslator
import org.jetbrains.dokka.javadoc.location.JavadocLocationProviderFactory
import org.jetbrains.dokka.javadoc.renderer.KorteJavadocRenderer
import org.jetbrains.dokka.javadoc.signatures.JavadocSignatureProvider
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.javadoc.pages.AllClassesPageInstaller
+import org.jetbrains.dokka.javadoc.pages.ResourcesInstaller
+import org.jetbrains.dokka.javadoc.pages.TreeViewInstaller
import org.jetbrains.dokka.kotlinAsJava.KotlinAsJavaPlugin
import org.jetbrains.dokka.plugability.DokkaPlugin
import org.jetbrains.dokka.plugability.querySingle
+import org.jetbrains.dokka.transformers.pages.PageTransformer
class JavadocPlugin : DokkaPlugin() {
val dokkaBasePlugin by lazy { plugin<DokkaBase>() }
val kotinAsJavaPlugin by lazy { plugin<KotlinAsJavaPlugin>() }
-
- val locationProviderFactory by extensionPoint<JavadocLocationProviderFactory>()
+ val locationProviderFactory by lazy { dokkaBasePlugin.locationProviderFactory }
+ val javadocPreprocessors by extensionPoint<PageTransformer>()
val dokkaJavadocPlugin by extending {
(CoreExtensions.renderer
@@ -34,9 +40,9 @@ class JavadocPlugin : DokkaPlugin() {
}
val javadocLocationProviderFactory by extending {
- locationProviderFactory providing { context ->
+ dokkaBasePlugin.locationProviderFactory providing { context ->
JavadocLocationProviderFactory(context)
- }
+ } override dokkaBasePlugin.locationProvider
}
val javadocSignatureProvider by extending {
@@ -49,5 +55,30 @@ class JavadocPlugin : DokkaPlugin() {
)
} override kotinAsJavaPlugin.javaSignatureProvider
}
+
+ val rootCreator by extending {
+ javadocPreprocessors with RootCreator
+ }
+
+ val packageListCreator by extending {
+ javadocPreprocessors providing {
+ PackageListCreator(
+ it,
+ RecognizedLinkFormat.DokkaJavadoc
+ )
+ } order { after(rootCreator) }
+ }
+
+ val resourcesInstaller by extending {
+ javadocPreprocessors with ResourcesInstaller order { after(rootCreator) }
+ }
+
+ val treeViewInstaller by extending {
+ javadocPreprocessors with TreeViewInstaller order { after(rootCreator) }
+ }
+
+ val allClassessPageInstaller by extending {
+ javadocPreprocessors with AllClassesPageInstaller order { before(rootCreator) }
+ }
}
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
index 7bc6d6d8..24719ebf 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
@@ -32,37 +32,32 @@ interface WithBrief {
}
class JavadocModulePageNode(
- override val name: String,
- override val content: JavadocContentNode,
- override val children: List<PageNode>,
+ name: String,
+ content: JavadocContentNode,
+ children: List<PageNode>,
override val dri: Set<DRI>
) :
- RootPageNode(),
+ ModulePageNode(name, content, null, children, emptyList()),
JavadocPageNode {
- override val documentable: Documentable? = null
- override val embeddedResources: List<String> = emptyList()
- override fun modified(name: String, children: List<PageNode>): RootPageNode =
- JavadocModulePageNode(name, content, children, dri)
-
override fun modified(
name: String,
content: ContentNode,
dri: Set<DRI>,
embeddedResources: List<String>,
children: List<PageNode>
- ): ContentPage = JavadocModulePageNode(name, content as JavadocContentNode, children, dri)
+ ): ModulePageNode = JavadocModulePageNode(name, content as JavadocContentNode, children, dri)
}
class JavadocPackagePageNode(
- override val name: String,
- override val content: JavadocContentNode,
- override val dri: Set<DRI>,
+ name: String,
+ content: JavadocContentNode,
+ dri: Set<DRI>,
- override val documentable: Documentable? = null,
- override val children: List<PageNode> = emptyList(),
- override val embeddedResources: List<String> = listOf()
-) : JavadocPageNode, WithIndexables, IndexableJavadocNode {
+ documentable: Documentable? = null,
+ children: List<PageNode> = emptyList(),
+ embeddedResources: List<String> = listOf()
+) : JavadocPageNode, WithIndexables, IndexableJavadocNode, PackagePageNode(name, content, dri, documentable, children, embeddedResources) {
override fun getAllIndexables(): List<IndexableJavadocNode> =
children.filterIsInstance<IndexableJavadocNode>().flatMap {
@@ -73,7 +68,7 @@ class JavadocPackagePageNode(
override fun modified(
name: String,
children: List<PageNode>
- ): PageNode = JavadocPackagePageNode(
+ ): PackagePageNode = JavadocPackagePageNode(
name,
content,
dri,
@@ -88,7 +83,7 @@ class JavadocPackagePageNode(
dri: Set<DRI>,
embeddedResources: List<String>,
children: List<PageNode>
- ): ContentPage =
+ ): PackagePageNode =
JavadocPackagePageNode(
name,
content as JavadocContentNode,
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt
index a2c3cf22..c54d484a 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt
@@ -5,8 +5,6 @@ import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.transformers.pages.PageTransformer
import kotlin.collections.HashMap
-val preprocessors = listOf(ResourcesInstaller, TreeViewInstaller, AllClassesPageInstaller, IndexGenerator)
-
object ResourcesInstaller : PageTransformer {
override fun invoke(input: RootPageNode): RootPageNode = input.modified(
children = input.children +
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToHtmlTranslator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToHtmlTranslator.kt
index b5fdde33..413b6387 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToHtmlTranslator.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToHtmlTranslator.kt
@@ -1,6 +1,6 @@
package org.jetbrains.dokka.javadoc.renderer
-import org.jetbrains.dokka.javadoc.location.JavadocLocationProvider
+import org.jetbrains.dokka.base.resolvers.local.LocationProvider
import org.jetbrains.dokka.javadoc.pages.JavadocSignatureContentNode
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
@@ -8,7 +8,7 @@ import org.jetbrains.dokka.utilities.formatToEndWithHtml
import org.jetbrains.dokka.utilities.htmlEscape
internal class JavadocContentToHtmlTranslator(
- private val locationProvider: JavadocLocationProvider,
+ private val locationProvider: LocationProvider,
private val context: DokkaContext
) {
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt
index ab12f50c..554bdb8a 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/JavadocContentToTemplateMapTranslator.kt
@@ -167,6 +167,8 @@ internal class JavadocContentToTemplateMapTranslator(
else -> emptyMap()
}
+ fun templateMapForJavadocContentNode(node: ContentNode): TemplateMap = (node as? JavadocContentNode)?.let { templateMapForJavadocContentNode(it) } ?: emptyMap()
+
private fun templateMapForParameterNode(node: JavadocParameterNode): TemplateMap =
mapOf(
"description" to htmlForContentNodes(node.description, contextNode),
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt
index 20115ac8..cdd045a4 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt
@@ -10,11 +10,13 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.jetbrains.dokka.base.renderers.OutputWriter
+import org.jetbrains.dokka.base.resolvers.local.LocationProvider
import org.jetbrains.dokka.javadoc.JavadocPlugin
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
+import org.jetbrains.dokka.plugability.query
import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.renderers.Renderer
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -25,6 +27,7 @@ typealias TemplateMap = Map<String, Any?>
class KorteJavadocRenderer(private val outputWriter: OutputWriter, val context: DokkaContext, resourceDir: String) :
Renderer {
private lateinit var locationProvider: JavadocLocationProvider
+ private val registeredPreprocessors = context.plugin<JavadocPlugin>().query { javadocPreprocessors }
private val contentToHtmlTranslator by lazy {
JavadocContentToHtmlTranslator(locationProvider, context)
@@ -34,10 +37,10 @@ class KorteJavadocRenderer(private val outputWriter: OutputWriter, val context:
JavadocContentToTemplateMapTranslator(locationProvider, context)
}
- override fun render(root: RootPageNode) = root.let { preprocessors.fold(root) { r, t -> t.invoke(r) } }.let { newRoot ->
- locationProvider = context.plugin<JavadocPlugin>().querySingle { locationProviderFactory }.getLocationProvider(newRoot)
+ override fun render(root: RootPageNode) = root.let { registeredPreprocessors.fold(root) { r, t -> t.invoke(r) } }.let { newRoot ->
+ locationProvider = context.plugin<JavadocPlugin>().querySingle { locationProviderFactory }.getLocationProvider(newRoot) as JavadocLocationProvider
runBlocking(Dispatchers.IO) {
- renderModulePageNode(newRoot as JavadocModulePageNode)
+ renderPage(newRoot)
SearchScriptsCreator(locationProvider).invoke(newRoot).forEach { renderSpecificPage(it, "") }
}
}
@@ -52,11 +55,11 @@ class KorteJavadocRenderer(private val outputWriter: OutputWriter, val context:
else -> ""
}
- private fun CoroutineScope.renderNode(node: PageNode, path: String = "") {
- if (node is JavadocPageNode) {
- renderJavadocPageNode(node)
- } else if (node is RendererSpecificPage) {
- renderSpecificPage(node, path)
+ private fun CoroutineScope.renderPage(node: PageNode, path: String = "") {
+ when(node){
+ is JavadocModulePageNode -> renderModulePageNode(node)
+ is JavadocPageNode -> renderJavadocPageNode(node)
+ is RendererSpecificPage -> renderSpecificPage(node, path)
}
}
@@ -67,14 +70,14 @@ class KorteJavadocRenderer(private val outputWriter: OutputWriter, val context:
val contentMap = contentToTemplateMapTranslator.templateMapForPageNode(node)
writeFromTemplate(outputWriter, "$link/$name".toNormalized(), "tabPage.korte", contentMap.toList())
- node.children.forEach { renderNode(it, link) }
+ node.children.forEach { renderPage(it, link) }
}
private fun CoroutineScope.renderJavadocPageNode(node: JavadocPageNode) {
val link = locationProvider.resolve(node, skipExtension = true)
val contentMap = contentToTemplateMapTranslator.templateMapForPageNode(node)
writeFromTemplate(outputWriter, link, templateForNode(node), contentMap.toList())
- node.children.forEach { renderNode(it, link.toNormalized()) }
+ node.children.forEach { renderPage(it, link.toNormalized()) }
}
private fun CoroutineScope.renderSpecificPage(node: RendererSpecificPage, path: String) = launch {
@@ -87,6 +90,7 @@ class KorteJavadocRenderer(private val outputWriter: OutputWriter, val context:
)
RenderingStrategy.DoNothing -> Unit
}
+ node.children.forEach { renderPage(it, locationProvider.resolve(node, skipExtension = true).toNormalized()) }
}
private fun Pair<String, String>.pairToTag() =
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt
index 589aeb51..0c2d8e07 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt
@@ -1,12 +1,10 @@
package org.jetbrains.dokka.javadoc.renderer
-import org.jetbrains.dokka.javadoc.location.JavadocLocationProvider
import org.jetbrains.dokka.javadoc.pages.*
import org.jetbrains.dokka.javadoc.renderer.SearchRecord.Companion.allTypes
-import org.jetbrains.dokka.DokkaConfiguration
-import org.jetbrains.dokka.DokkaException
import org.jetbrains.dokka.base.renderers.sourceSets
import org.jetbrains.dokka.base.resolvers.local.resolveOrThrow
+import org.jetbrains.dokka.base.resolvers.local.LocationProvider
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.DisplaySourceSet
import org.jetbrains.dokka.model.Documentable
@@ -14,12 +12,12 @@ import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.utilities.formatToEndWithHtml
import java.lang.StringBuilder
-class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider) {
+class SearchScriptsCreator(private val locationProvider: LocationProvider) {
fun invoke(input: RootPageNode): List<RendererSpecificPage> {
val data = when (input) {
is JavadocModulePageNode -> processModules(listOf(input))
- else -> SearchData()
+ else -> processModules(input.children.filterIsInstance<JavadocModulePageNode>())
}
val serializer = SearchRecordJsonSerializer()