aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt2
-rw-r--r--plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt10
-rw-r--r--plugins/all-modules-page/src/test/kotlin/templates/MultiModuleDocumentationTest.kt2
-rw-r--r--plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkCommandResolutionTest.kt8
-rw-r--r--plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt8
-rw-r--r--plugins/all-modules-page/src/test/kotlin/templates/mockedPackageListFactory.kt8
-rw-r--r--plugins/base/api/base.api23
-rw-r--r--plugins/base/src/main/kotlin/DokkaBase.kt2
-rw-r--r--plugins/base/src/main/kotlin/renderers/PackageListService.kt29
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt10
-rw-r--r--plugins/base/src/main/kotlin/renderers/preprocessors.kt18
-rw-r--r--plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt14
-rw-r--r--plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt27
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt28
-rw-r--r--plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt43
-rw-r--r--plugins/base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt4
-rw-r--r--plugins/base/src/test/kotlin/locationProvider/DokkaLocationProviderTest.kt0
-rw-r--r--plugins/base/src/test/kotlin/locationProvider/MultiModuleLinkingTest.kt71
-rw-r--r--plugins/base/src/test/kotlin/packageList/PackageListTest.kt65
-rw-r--r--plugins/base/src/test/resources/locationProvider/multi-module-package-list8
-rw-r--r--plugins/gfm/gfm-template-processing/api/gfm-template-processing.api2
-rw-r--r--plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingStrategy.kt5
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPlugin.kt3
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt4
-rw-r--r--plugins/javadoc/src/test/kotlin/org/jetbrains/dokka/javadoc/packagelist/JavadocPackageListTest.kt10
-rw-r--r--plugins/templating/api/templating.api21
-rw-r--r--plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt3
-rw-r--r--plugins/templating/src/main/kotlin/templates/FallbackTemplateProcessingStrategy.kt10
-rw-r--r--plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt9
-rw-r--r--plugins/templating/src/main/kotlin/templates/PackageListProcessingStrategy.kt51
-rw-r--r--plugins/templating/src/main/kotlin/templates/SourcesetDependencyProcessingStrategy.kt5
-rw-r--r--plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt31
-rw-r--r--plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt11
-rw-r--r--plugins/templating/src/test/kotlin/templates/AddToNavigationCommandResolutionTest.kt2
-rw-r--r--plugins/templating/src/test/kotlin/templates/AddToSearchCommandResolutionTest.kt2
-rw-r--r--plugins/templating/src/test/kotlin/templates/SubstitutionCommandResolutionTest.kt2
-rw-r--r--plugins/versioning/src/main/kotlin/versioning/VersioningHandler.kt4
37 files changed, 413 insertions, 142 deletions
diff --git a/plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt b/plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt
index e6556b07..da44c840 100644
--- a/plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt
+++ b/plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt
@@ -45,4 +45,4 @@ class AllModulesPagePlugin : DokkaPlugin() {
val multiModuleLinkResolver by extending {
externalModuleLinkResolver providing ::DefaultExternalModuleLinkResolver
}
-} \ No newline at end of file
+}
diff --git a/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt b/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt
index 0fde629c..e7925ead 100644
--- a/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt
+++ b/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt
@@ -1,10 +1,10 @@
package org.jetbrains.dokka.allModulesPage
-import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.DokkaConfiguration.DokkaModuleDescription
import org.jetbrains.dokka.base.DokkaBase
-import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider.Companion.identifierToFilename
import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation
import org.jetbrains.dokka.base.resolvers.shared.PackageList
+import org.jetbrains.dokka.base.resolvers.shared.PackageList.Companion.PACKAGE_LIST_NAME
import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.plugability.DokkaContext
@@ -42,10 +42,10 @@ class DefaultExternalModuleLinkResolver(val context: DokkaContext) : ExternalMod
this
}
- private fun loadPackageListForModule(module: DokkaConfiguration.DokkaModuleDescription) =
- module.sourceOutputDirectory.resolve(File(identifierToFilename(module.name))).let {
+ private fun loadPackageListForModule(module: DokkaModuleDescription) =
+ module.sourceOutputDirectory.walkTopDown().maxDepth(3).firstOrNull { it.name == PACKAGE_LIST_NAME }?.let {
PackageList.load(
- URL("file:" + it.resolve("package-list").path),
+ URL("file:" + it.path),
8,
true
)
diff --git a/plugins/all-modules-page/src/test/kotlin/templates/MultiModuleDocumentationTest.kt b/plugins/all-modules-page/src/test/kotlin/templates/MultiModuleDocumentationTest.kt
index 11a03bc4..57f7027f 100644
--- a/plugins/all-modules-page/src/test/kotlin/templates/MultiModuleDocumentationTest.kt
+++ b/plugins/all-modules-page/src/test/kotlin/templates/MultiModuleDocumentationTest.kt
@@ -62,4 +62,4 @@ class MultiModuleDocumentationTest : MultiModuleAbstractTest() {
}
}
}
-} \ No newline at end of file
+}
diff --git a/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkCommandResolutionTest.kt b/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkCommandResolutionTest.kt
index 2637714f..b7487c16 100644
--- a/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkCommandResolutionTest.kt
+++ b/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkCommandResolutionTest.kt
@@ -50,7 +50,7 @@ class ResolveLinkCommandResolutionTest : MultiModuleAbstractTest() {
}
val expected = createHTML().a {
- href = "../../module2/package2/-sample/index.html"
+ href = "../module2/package2/-sample/index.html"
span {
+"Sample"
}
@@ -97,12 +97,12 @@ class ResolveLinkCommandResolutionTest : MultiModuleAbstractTest() {
fun setup(content: String): File {
folder.create()
- val innerModule1 = folder.newFolder("module1", "module1")
- val innerModule2 = folder.newFolder("module2", "module2")
+ val innerModule1 = folder.newFolder("module1")
+ val innerModule2 = folder.newFolder("module2")
val packageList = innerModule2.resolve("package-list")
packageList.writeText(mockedPackageListForPackages(RecognizedLinkFormat.DokkaHtml, "package2"))
val contentFile = innerModule1.resolve("index.html")
contentFile.writeText(content)
return contentFile
}
-} \ No newline at end of file
+}
diff --git a/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt b/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt
index 185a179d..975d3183 100644
--- a/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt
+++ b/plugins/all-modules-page/src/test/kotlin/templates/ResolveLinkGfmCommandResolutionTest.kt
@@ -33,7 +33,7 @@ class ResolveLinkGfmCommandResolutionTest : MultiModuleAbstractTest() {
sourceOutputDirectory = folder.root.resolve("module2"),
)
)
- this.outputDir = folder.root
+ outputDir = folder.root
}
@Test
@@ -49,7 +49,7 @@ class ResolveLinkGfmCommandResolutionTest : MultiModuleAbstractTest() {
}
}.toString()
- val expected = "[Sample text inside](../../module2/package2/-sample/index.md)"
+ val expected = "[Sample text inside](../module2/package2/-sample/index.md)"
val content = setup(link)
val configuration = configuration()
@@ -63,8 +63,8 @@ class ResolveLinkGfmCommandResolutionTest : MultiModuleAbstractTest() {
private fun setup(content: String): File {
folder.create()
- val innerModule1 = folder.newFolder("module1", "module1")
- val innerModule2 = folder.newFolder("module2", "module2")
+ val innerModule1 = folder.newFolder( "module1")
+ val innerModule2 = folder.newFolder( "module2")
val packageList = innerModule2.resolve("package-list")
packageList.writeText(mockedPackageListForPackages(RecognizedLinkFormat.DokkaGFM, "package2"))
val contentFile = innerModule1.resolve("index.md")
diff --git a/plugins/all-modules-page/src/test/kotlin/templates/mockedPackageListFactory.kt b/plugins/all-modules-page/src/test/kotlin/templates/mockedPackageListFactory.kt
index 7a10041b..3386ae2c 100644
--- a/plugins/all-modules-page/src/test/kotlin/templates/mockedPackageListFactory.kt
+++ b/plugins/all-modules-page/src/test/kotlin/templates/mockedPackageListFactory.kt
@@ -1,12 +1,12 @@
package org.jetbrains.dokka.allModulesPage.templates
-import org.jetbrains.dokka.base.renderers.PackageListService
+import org.jetbrains.dokka.base.resolvers.shared.PackageList
import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat
internal fun mockedPackageListForPackages(format: RecognizedLinkFormat, vararg packages: String): String =
"""
- ${PackageListService.DOKKA_PARAM_PREFIX}.format:${format.formatName}
- ${PackageListService.DOKKA_PARAM_PREFIX}.linkExtension:${format.linkExtension}
+ ${PackageList.DOKKA_PARAM_PREFIX}.format:${format.formatName}
+ ${PackageList.DOKKA_PARAM_PREFIX}.linkExtension:${format.linkExtension}
${packages.sorted().joinToString(separator = "\n", postfix = "\n") { it }}
- """.trimIndent() \ No newline at end of file
+ """.trimIndent()
diff --git a/plugins/base/api/base.api b/plugins/base/api/base.api
index bfb83e6e..6bf4de15 100644
--- a/plugins/base/api/base.api
+++ b/plugins/base/api/base.api
@@ -277,25 +277,24 @@ public abstract interface class org/jetbrains/dokka/base/renderers/OutputWriter
}
public final class org/jetbrains/dokka/base/renderers/PackageListCreator : org/jetbrains/dokka/transformers/pages/PageTransformer {
- public fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;Lorg/jetbrains/dokka/base/resolvers/shared/LinkFormat;Ljava/util/List;Z)V
- public synthetic fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;Lorg/jetbrains/dokka/base/resolvers/shared/LinkFormat;Ljava/util/List;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;Lorg/jetbrains/dokka/base/resolvers/shared/LinkFormat;Ljava/util/List;)V
+ public synthetic fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;Lorg/jetbrains/dokka/base/resolvers/shared/LinkFormat;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getContext ()Lorg/jetbrains/dokka/plugability/DokkaContext;
public final fun getFormat ()Lorg/jetbrains/dokka/base/resolvers/shared/LinkFormat;
public final fun getOutputFilesNames ()Ljava/util/List;
- public final fun getRemoveModulePrefix ()Z
public fun invoke (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/pages/RootPageNode;
}
public final class org/jetbrains/dokka/base/renderers/PackageListService {
public static final field Companion Lorg/jetbrains/dokka/base/renderers/PackageListService$Companion;
- public static final field DOKKA_PARAM_PREFIX Ljava/lang/String;
public fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;Lorg/jetbrains/dokka/pages/RootPageNode;)V
- public final fun createPackageList (Lorg/jetbrains/dokka/pages/ModulePage;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
+ public final fun createPackageList (Lorg/jetbrains/dokka/pages/ModulePage;Lorg/jetbrains/dokka/base/resolvers/shared/LinkFormat;)Ljava/lang/String;
public final fun getContext ()Lorg/jetbrains/dokka/plugability/DokkaContext;
public final fun getRootPage ()Lorg/jetbrains/dokka/pages/RootPageNode;
}
public final class org/jetbrains/dokka/base/renderers/PackageListService$Companion {
+ public final fun renderPackageList (Ljava/util/Map;Ljava/util/Map;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
}
public final class org/jetbrains/dokka/base/renderers/RootCreator : org/jetbrains/dokka/transformers/pages/PageTransformer {
@@ -734,19 +733,25 @@ public abstract interface class org/jetbrains/dokka/base/resolvers/shared/LinkFo
public final class org/jetbrains/dokka/base/resolvers/shared/PackageList {
public static final field Companion Lorg/jetbrains/dokka/base/resolvers/shared/PackageList$Companion;
- public fun <init> (Lorg/jetbrains/dokka/base/resolvers/shared/RecognizedLinkFormat;Ljava/util/Set;Ljava/util/Map;Ljava/net/URL;)V
+ public static final field DOKKA_PARAM_PREFIX Ljava/lang/String;
+ public static final field MODULE_DELIMITER Ljava/lang/String;
+ public static final field PACKAGE_LIST_NAME Ljava/lang/String;
+ public static final field SINGLE_MODULE_NAME Ljava/lang/String;
+ public fun <init> (Lorg/jetbrains/dokka/base/resolvers/shared/RecognizedLinkFormat;Ljava/util/Map;Ljava/util/Map;Ljava/net/URL;)V
public final fun component1 ()Lorg/jetbrains/dokka/base/resolvers/shared/RecognizedLinkFormat;
- public final fun component2 ()Ljava/util/Set;
+ public final fun component2 ()Ljava/util/Map;
public final fun component3 ()Ljava/util/Map;
public final fun component4 ()Ljava/net/URL;
- public final fun copy (Lorg/jetbrains/dokka/base/resolvers/shared/RecognizedLinkFormat;Ljava/util/Set;Ljava/util/Map;Ljava/net/URL;)Lorg/jetbrains/dokka/base/resolvers/shared/PackageList;
- public static synthetic fun copy$default (Lorg/jetbrains/dokka/base/resolvers/shared/PackageList;Lorg/jetbrains/dokka/base/resolvers/shared/RecognizedLinkFormat;Ljava/util/Set;Ljava/util/Map;Ljava/net/URL;ILjava/lang/Object;)Lorg/jetbrains/dokka/base/resolvers/shared/PackageList;
+ public final fun copy (Lorg/jetbrains/dokka/base/resolvers/shared/RecognizedLinkFormat;Ljava/util/Map;Ljava/util/Map;Ljava/net/URL;)Lorg/jetbrains/dokka/base/resolvers/shared/PackageList;
+ public static synthetic fun copy$default (Lorg/jetbrains/dokka/base/resolvers/shared/PackageList;Lorg/jetbrains/dokka/base/resolvers/shared/RecognizedLinkFormat;Ljava/util/Map;Ljava/util/Map;Ljava/net/URL;ILjava/lang/Object;)Lorg/jetbrains/dokka/base/resolvers/shared/PackageList;
public fun equals (Ljava/lang/Object;)Z
public final fun getLinkFormat ()Lorg/jetbrains/dokka/base/resolvers/shared/RecognizedLinkFormat;
public final fun getLocations ()Ljava/util/Map;
+ public final fun getModules ()Ljava/util/Map;
public final fun getPackages ()Ljava/util/Set;
public final fun getUrl ()Ljava/net/URL;
public fun hashCode ()I
+ public final fun moduleFor (Ljava/lang/String;)Ljava/lang/String;
public fun toString ()Ljava/lang/String;
}
diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt
index 0a18c3b1..c0e512c5 100644
--- a/plugins/base/src/main/kotlin/DokkaBase.kt
+++ b/plugins/base/src/main/kotlin/DokkaBase.kt
@@ -188,7 +188,7 @@ class DokkaBase : DokkaPlugin() {
}
val rootCreator by extending {
- htmlPreprocessors with RootCreator
+ htmlPreprocessors with RootCreator applyIf { !delayTemplateSubstitution }
}
val defaultSamplesTransformer by extending {
diff --git a/plugins/base/src/main/kotlin/renderers/PackageListService.kt b/plugins/base/src/main/kotlin/renderers/PackageListService.kt
index 9b753cb1..2bf66ebf 100644
--- a/plugins/base/src/main/kotlin/renderers/PackageListService.kt
+++ b/plugins/base/src/main/kotlin/renderers/PackageListService.kt
@@ -1,6 +1,10 @@
package org.jetbrains.dokka.base.renderers
import org.jetbrains.dokka.base.DokkaBase
+import org.jetbrains.dokka.base.resolvers.shared.LinkFormat
+import org.jetbrains.dokka.base.resolvers.shared.PackageList.Companion.DOKKA_PARAM_PREFIX
+import org.jetbrains.dokka.base.resolvers.shared.PackageList.Companion.SINGLE_MODULE_NAME
+import org.jetbrains.dokka.base.resolvers.shared.PackageList.Companion.MODULE_DELIMITER
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
@@ -10,7 +14,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
class PackageListService(val context: DokkaContext, val rootPage: RootPageNode) {
- fun createPackageList(module: ModulePage, format: String, linkExtension: String): String {
+ fun createPackageList(module: ModulePage, format: LinkFormat): String {
val packages = mutableSetOf<String>()
val nonStandardLocations = mutableMapOf<String, String>()
@@ -31,7 +35,7 @@ class PackageListService(val context: DokkaContext, val rootPage: RootPageNode)
?: run { context.logger.error("Cannot resolve path for ${node.name}!"); null }
if (dri != DRI.topLevel && locationProvider.expectedLocationForDri(dri) != nodeLocation) {
- nonStandardLocations[dri.toString()] = "$nodeLocation.$linkExtension"
+ nonStandardLocations[dri.toString()] = "$nodeLocation.${format.linkExtension}"
}
}
@@ -39,19 +43,22 @@ class PackageListService(val context: DokkaContext, val rootPage: RootPageNode)
}
visit(module)
+ return renderPackageList(nonStandardLocations, mapOf(SINGLE_MODULE_NAME to packages), format.formatName, format.linkExtension)
+ }
- return buildString {
+ companion object {
+ fun renderPackageList(nonStandardLocations: Map<String, String>, modules: Map<String, Set<String>>, format: String, linkExtension: String): String = buildString {
appendLine("$DOKKA_PARAM_PREFIX.format:${format}")
appendLine("$DOKKA_PARAM_PREFIX.linkExtension:${linkExtension}")
- nonStandardLocations.map { (signature, location) -> "$DOKKA_PARAM_PREFIX.location:$signature\u001f$location" }
- .sorted().joinTo(this, separator = "\n", postfix = "\n")
+ nonStandardLocations.map { (signature, location) ->
+ "$DOKKA_PARAM_PREFIX.location:$signature\u001f$location"
+ }.sorted().joinTo(this, separator = "\n", postfix = "\n")
- packages.sorted().joinTo(this, separator = "\n", postfix = "\n")
+ modules.mapNotNull { (module, packages) ->
+ ("$MODULE_DELIMITER$module\n".takeIf { module != SINGLE_MODULE_NAME }.orEmpty() +
+ packages.filter(String::isNotBlank).sorted().joinToString(separator = "\n"))
+ .takeIf { packages.isNotEmpty() }
+ }.joinTo(this, separator = "\n", postfix = "\n")
}
-
- }
-
- companion object {
- const val DOKKA_PARAM_PREFIX = "\$dokka"
}
}
diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
index 92f7324c..ff724f02 100644
--- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
@@ -15,8 +15,8 @@ import org.jetbrains.dokka.plugability.configuration
import org.jetbrains.dokka.transformers.pages.PageTransformer
abstract class NavigationDataProvider {
- open fun navigableChildren(input: RootPageNode): NavigationNode =
- input.children.filterIsInstance<ContentPage>().single().let { visit(it) }
+ open fun navigableChildren(input: RootPageNode): NavigationNode = input.withDescendants()
+ .first { it is ModulePage || it is MultimoduleRootPage }.let { visit(it as ContentPage) }
open fun visit(page: ContentPage): NavigationNode =
NavigationNode(
@@ -167,9 +167,9 @@ private fun List<String>.toRenderSpecificResourcePage(): List<RendererSpecificRe
class SourcesetDependencyAppender(val context: DokkaContext) : PageTransformer {
private val name = "scripts/sourceset_dependencies.js"
override fun invoke(input: RootPageNode): RootPageNode {
- val dependenciesMap = context.configuration.sourceSets.map {
+ val dependenciesMap = context.configuration.sourceSets.associate {
it.sourceSetID to it.dependentSourceSets
- }.toMap()
+ }
fun createDependenciesJson(): String =
dependenciesMap.map { (key, values) -> key.toString() to values.map { it.toString() } }.toMap()
@@ -191,4 +191,4 @@ class SourcesetDependencyAppender(val context: DokkaContext) : PageTransformer {
children = input.children + deps
).transformContentPagesTree { it.modified(embeddedResources = it.embeddedResources + name) }
}
-} \ No newline at end of file
+}
diff --git a/plugins/base/src/main/kotlin/renderers/preprocessors.kt b/plugins/base/src/main/kotlin/renderers/preprocessors.kt
index b64d2e1f..1a41162d 100644
--- a/plugins/base/src/main/kotlin/renderers/preprocessors.kt
+++ b/plugins/base/src/main/kotlin/renderers/preprocessors.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka.base.renderers
import org.jetbrains.dokka.base.resolvers.shared.LinkFormat
+import org.jetbrains.dokka.model.withDescendants
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.transformers.pages.PageTransformer
@@ -13,25 +14,20 @@ object RootCreator : PageTransformer {
class PackageListCreator(
val context: DokkaContext,
val format: LinkFormat,
- val outputFilesNames: List<String> = listOf("package-list"),
- val removeModulePrefix: Boolean = true
+ val outputFilesNames: List<String> = listOf("package-list")
) : PageTransformer {
- override fun invoke(input: RootPageNode) =
- input.modified(children = input.children.map {
- it.takeUnless { it is ModulePage }
- ?: it.modified(children = it.children + packageList(input, it as ModulePage))
- })
-
+ override fun invoke(input: RootPageNode) = input.transformPageNodeTree { pageNode ->
+ pageNode.takeIf { it is ModulePage }?.let { it.modified(children = it.children + packageList(input, it as ModulePage)) } ?: pageNode
+ }
private fun packageList(rootPageNode: RootPageNode, module: ModulePage): List<RendererSpecificPage> {
val content = PackageListService(context, rootPageNode).createPackageList(
module,
- format.formatName,
- format.linkExtension
+ format
)
return outputFilesNames.map { fileName ->
RendererSpecificResourcePage(
- "${rootPageNode.name}/${fileName}",
+ fileName,
emptyList(),
RenderingStrategy.Write(content)
)
diff --git a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt
index 09eb7cc4..fc7f57f4 100644
--- a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt
@@ -22,11 +22,21 @@ open class DefaultExternalLocationProvider(
}
protected open fun DRI.constructPath(): String {
- val classNamesChecked = classNames ?: return "$docURL${packageName ?: ""}/index$extension"
+ val modulePart = packageName?.let { packageName ->
+ externalDocumentation.packageList.moduleFor(packageName)?.let {
+ if (it.isNotBlank())
+ "$it/"
+ else
+ ""
+ }
+ }.orEmpty()
+
+ val docWithModule = docURL + modulePart
+ val classNamesChecked = classNames ?: return "$docWithModule${packageName ?: ""}/index$extension"
val classLink = (listOfNotNull(packageName) + classNamesChecked.split('.'))
.joinToString("/", transform = ::identifierToFilename)
val fileName = callable?.let { identifierToFilename(it.name) } ?: "index"
- return "$docURL$classLink/$fileName$extension"
+ return "$docWithModule$classLink/$fileName$extension"
}
}
diff --git a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt
index b0398cd7..f1a32cb4 100644
--- a/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/external/javadoc/JavadocExternalLocationProvider.kt
@@ -8,22 +8,33 @@ import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.utilities.htmlEscape
open class JavadocExternalLocationProvider(
- externalDocumentation: ExternalDocumentation,
- val brackets: String,
- val separator: String,
- dokkaContext: DokkaContext
+ externalDocumentation: ExternalDocumentation,
+ val brackets: String,
+ val separator: String,
+ dokkaContext: DokkaContext
) : DefaultExternalLocationProvider(externalDocumentation, ".html", dokkaContext) {
override fun DRI.constructPath(): String {
val packageLink = packageName?.replace(".", "/")
+ val modulePart = packageName?.let { packageName ->
+ externalDocumentation.packageList.moduleFor(packageName)?.let {
+ if (it.isNotBlank())
+ "$it/"
+ else
+ ""
+ }
+ }.orEmpty()
+
+ val docWithModule = docURL + modulePart
+
if (classNames == null) {
- return "$docURL$packageLink/package-summary$extension".htmlEscape()
+ return "$docWithModule$packageLink/package-summary$extension".htmlEscape()
}
val classLink =
- if (packageLink == null) "${classNames}$extension" else "$packageLink/${classNames}$extension"
- val callableChecked = callable ?: return "$docURL$classLink".htmlEscape()
+ if (packageLink == null) "${classNames}$extension" else "$packageLink/${classNames}$extension"
+ val callableChecked = callable ?: return "$docWithModule$classLink".htmlEscape()
- return ("$docURL$classLink#" + anchorPart(callableChecked)).htmlEscape()
+ return ("$docWithModule$classLink#" + anchorPart(callableChecked)).htmlEscape()
}
protected open fun anchorPart(callable: Callable) = callable.name +
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt
index 87683414..3647bfa7 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt
@@ -23,22 +23,20 @@ abstract class DefaultLocationProvider(
dokkaContext.plugin<DokkaBase>().query { externalLocationProviderFactory }
protected val externalLocationProviders: Map<ExternalDocumentation, ExternalLocationProvider?> = dokkaContext
- .configuration
- .sourceSets
- .flatMap { sourceSet ->
- sourceSet.externalDocumentationLinks.map {
- PackageList.load(it.packageListUrl, sourceSet.jdkVersion, dokkaContext.configuration.offlineMode)
- ?.let { packageList -> ExternalDocumentation(it.url, packageList) }
+ .configuration
+ .sourceSets
+ .flatMap { sourceSet ->
+ sourceSet.externalDocumentationLinks.map {
+ PackageList.load(it.packageListUrl, sourceSet.jdkVersion, dokkaContext.configuration.offlineMode)
+ ?.let { packageList -> ExternalDocumentation(it.url, packageList) }
+ }
+ }
+ .filterNotNull().associateWith { extDocInfo ->
+ externalLocationProviderFactories
+ .mapNotNull { it.getExternalLocationProvider(extDocInfo) }
+ .firstOrNull()
+ ?: run { dokkaContext.logger.error("No ExternalLocationProvider for '${extDocInfo.packageList.url}' found"); null }
}
- }
- .filterNotNull()
- .map { extDocInfo ->
- val externalLocationProvider = (externalLocationProviderFactories.asSequence()
- .mapNotNull { it.getExternalLocationProvider(extDocInfo) }.firstOrNull()
- ?: run { dokkaContext.logger.error("No ExternalLocationProvider for '${extDocInfo.packageList.url}' found"); null })
- extDocInfo to externalLocationProvider
- }
- .toMap()
protected val packagesIndex: Map<String, ExternalLocationProvider?> =
externalLocationProviders
diff --git a/plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt b/plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt
index a06365eb..469904bd 100644
--- a/plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt
+++ b/plugins/base/src/main/kotlin/resolvers/shared/PackageList.kt
@@ -1,20 +1,33 @@
package org.jetbrains.dokka.base.resolvers.shared
-import org.jetbrains.dokka.base.renderers.PackageListService
import java.net.URL
+typealias Module = String
+
data class PackageList(
val linkFormat: RecognizedLinkFormat,
- val packages: Set<String>,
+ val modules: Map<Module, Set<String>>,
val locations: Map<String, String>,
val url: URL
) {
+ val packages: Set<String>
+ get() = modules.values.flatten().toSet()
+
+ fun moduleFor(packageName: String) = modules.asSequence()
+ .filter { it.value.contains(packageName) }
+ .firstOrNull()?.ke