diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-05-20 12:05:26 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-06-15 13:15:30 +0200 |
commit | f3baf10b4c882230d382bfcdd94163d070bd0e25 (patch) | |
tree | 128b63b10f05242cfce88da6714d9e04987b5651 /plugins | |
parent | 645e02fb42bbf1cd3ee2773a014ea1e553e09229 (diff) | |
download | dokka-f3baf10b4c882230d382bfcdd94163d070bd0e25.tar.gz dokka-f3baf10b4c882230d382bfcdd94163d070bd0e25.tar.bz2 dokka-f3baf10b4c882230d382bfcdd94163d070bd0e25.zip |
Rework dokka configuration and Gradle plugin
Diffstat (limited to 'plugins')
18 files changed, 39 insertions, 59 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 42273d20..528b7d16 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -22,7 +22,7 @@ open class HtmlRenderer( private val sourceSetDependencyMap = with(context.sourceSetCache) { allSourceSets.map { sourceSet -> - sourceSet to allSourceSets.filter { sourceSet.dependentSourceSets.contains(it.sourceSetName) } + sourceSet to allSourceSets.filter { sourceSet.dependentSourceSets.contains(it.sourceSetID ) } }.toMap() } @@ -93,14 +93,14 @@ open class HtmlRenderer( group.sourceSets.forEach { button(classes = "platform-tag platform-selector") { attributes["data-active"] = "" - attributes["data-filter"] = it.sourceSetName - when (it.platform.key) { + attributes["data-filter"] = it.sourceSetID + when(it.platform.key) { "common" -> classes = classes + "common-like" "native" -> classes = classes + "native-like" "jvm" -> classes = classes + "jvm-like" "js" -> classes = classes + "js-like" } - text(it.sourceSetName) + text(it.displayName) } } } @@ -161,10 +161,10 @@ open class HtmlRenderer( attributes["data-toggle-list"] = "data-toggle-list" contents.forEachIndexed { index, pair -> button(classes = "platform-bookmark") { - attributes["data-filterable-current"] = pair.first.sourceSetName - attributes["data-filterable-set"] = pair.first.sourceSetName + attributes["data-filterable-current"] = pair.first.sourceSetID + attributes["data-filterable-set"] = pair.first.sourceSetID if (index == 0) attributes["data-active"] = "" - attributes["data-toggle"] = pair.first.sourceSetName + attributes["data-toggle"] = pair.first.sourceSetID when ( pair.first.platform.key ) { @@ -173,8 +173,8 @@ open class HtmlRenderer( "jvm" -> classes = classes + "jvm-like" "js" -> classes = classes + "js-like" } - attributes["data-toggle"] = pair.first.sourceSetName - text(pair.first.sourceSetName) + attributes["data-toggle"] = pair.first.sourceSetID + text(pair.first.displayName) } } } @@ -242,10 +242,10 @@ open class HtmlRenderer( consumer.onTagContentUnsafe { +createHTML().div("divergent-group") { attributes["data-filterable-current"] = groupedDivergent.keys.joinToString(" ") { - it.sourceSetName + it.sourceSetID } attributes["data-filterable-set"] = groupedDivergent.keys.joinToString(" ") { - it.sourceSetName + it.sourceSetID } val divergentForPlatformDependent = groupedDivergent.map { (sourceSet, elements) -> @@ -346,12 +346,13 @@ open class HtmlRenderer( div(classes = "table-row") { if (!style.contains(MultimoduleTable)) { attributes["data-filterable-current"] = node.sourceSets.joinToString(" ") { - it.sourceSetName + it.sourceSetID } attributes["data-filterable-set"] = node.sourceSets.joinToString(" ") { - it.sourceSetName + it.sourceSetID } } + it.filterIsInstance<ContentLink>().takeIf { it.isNotEmpty() }?.let { div("main-subrow " + node.style.joinToString(" ")) { it.filter { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } } @@ -396,7 +397,7 @@ open class HtmlRenderer( "jvm" -> classes = classes + "jvm-like" "js" -> classes = classes + "js-like" } - text(it.sourceSetName) + text(it.displayName) } } } diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index f10c85d5..cdb30555 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -87,7 +87,7 @@ object StyleAndScriptsAppender : PageTransformer { class SourcesetDependencyAppender(val context: DokkaContext) : PageTransformer{ override fun invoke(input: RootPageNode): RootPageNode { val dependenciesMap = context.configuration.passesConfigurations.map { - it.sourceSetName to it.dependentSourceSets + it.sourceSetID to it.dependentSourceSets }.toMap() fun createDependenciesJson() : String = "sourceset_dependencies = '{${ dependenciesMap.entries.joinToString(", ") { diff --git a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt index 322f4927..a9e58f17 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt @@ -98,26 +98,19 @@ open class DefaultLocationProvider( if (info == null) { toResolve.getOrPut(jdk) { mutableListOf() }.add(link) } else if (info.packages.contains(dri.packageName)) { - return link.url.toExternalForm() + getLink( - dri, - info - ) + return link.url.toExternalForm() + getLink(dri, info) } } } // Not in cache, resolve packageLists for ((jdk, links) in toResolve) { for (link in links) { + if(dokkaContext.configuration.offlineMode && link.packageListUrl.protocol.toLowerCase() != "file") + continue val locationInfo = - loadPackageList( - jdk, - link.packageListUrl - ) + loadPackageList(jdk, link.packageListUrl) if (locationInfo.packages.contains(dri.packageName)) { - return link.url.toExternalForm() + getLink( - dri, - locationInfo - ) + return link.url.toExternalForm() + getLink(dri, locationInfo) } } toResolve.remove(jdk) diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt index 04b2636c..2aab6018 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt @@ -53,7 +53,7 @@ internal class ModuleAndPackageDocumentationTransformer(val context: DokkaContex module.sourceSets.mapNotNull { pd -> val doc = modulesAndPackagesDocumentation[Pair(module.name, pd)] val facade = context.platforms[pd]?.facade - ?: return@mapNotNull null.also { context.logger.warn("Could not find platform data for ${pd.moduleName}/${pd.sourceSetName}") } + ?: return@mapNotNull null.also { context.logger.warn("Could not find platform data for ${pd.moduleName}/${pd.sourceSetID}") } try { doc?.get("Module")?.get(module.name)?.run { pd to MarkdownParser( @@ -72,7 +72,7 @@ internal class ModuleAndPackageDocumentationTransformer(val context: DokkaContex it.name to it.sourceSets.mapNotNull { pd -> val doc = modulesAndPackagesDocumentation[Pair(module.name, pd)] val facade = context.platforms[pd]?.facade - ?: return@mapNotNull null.also { context.logger.warn("Could not find platform data for ${pd.moduleName}/${pd.sourceSetName}") } + ?: return@mapNotNull null.also { context.logger.warn("Could not find platform data for ${pd.moduleName}/${pd.sourceSetID}") } val descriptor = facade.moduleDescriptor.getPackage(FqName(it.name.let { if(it == "[JS root]") "" else it })) doc?.get("Package")?.get(it.name)?.run { pd to MarkdownParser( diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index bf92c849..33cad4f5 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -739,7 +739,7 @@ private class DokkaDescriptorVisitor( private fun ConstantsEnumValue.fullEnumEntryName() = "${this.enumClassId.relativeClassName.asString()}.${this.enumEntryName.identifier}" - private fun fallbackPackageName(): String = "[${sourceSet.sourceSetName} root]"// TODO: error-prone, find a better way to do it + private fun fallbackPackageName(): String = "[${sourceSet.displayName} root]"// TODO: error-prone, find a better way to do it } private fun DRI.withPackageFallbackTo(fallbackPackage: String): DRI { diff --git a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt index d10bd151..f91b82d5 100644 --- a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt +++ b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt @@ -19,7 +19,6 @@ class ContentForAnnotationsTest : AbstractCoreTest() { pass { sourceRoots = listOf("src/") analysisPlatform = "jvm" - targets = listOf("jvm") } } } diff --git a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt index e25567e0..335d834e 100644 --- a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt +++ b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt @@ -12,7 +12,6 @@ class ContentForParamsTest : AbstractCoreTest() { pass { sourceRoots = listOf("src/") analysisPlatform = "jvm" - targets = listOf("jvm") } } } diff --git a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt index c9adc0bf..696c3032 100644 --- a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt +++ b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt @@ -4,9 +4,9 @@ import matchers.content.* import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import org.junit.jupiter.api.Test +import utils.ParamAttributes import utils.bareSignature import utils.pWrapped -import utils.ParamAttributes import utils.unnamedTag class ContentForSeeAlsoTest : AbstractCoreTest() { @@ -15,7 +15,6 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { pass { sourceRoots = listOf("src/") analysisPlatform = "jvm" - targets = listOf("jvm") } } } diff --git a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt index bdefe45a..dc0488c8 100644 --- a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt +++ b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt @@ -16,7 +16,6 @@ class ContentForSignaturesTest : AbstractCoreTest() { pass { sourceRoots = listOf("src/") analysisPlatform = "jvm" - targets = listOf("jvm") } } } diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt index 7cdb0de3..d49ec8a5 100644 --- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt +++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt @@ -27,7 +27,6 @@ class LinkableContentTest : AbstractCoreTest() { pass { moduleName = "example" analysisPlatform = "js" - targets = listOf("js") sourceRoots = listOf("jsMain", "commonMain", "jvmAndJsSecondCommonMain").map { Paths.get("$testDataDir/$it/kotlin").toString() } @@ -37,7 +36,6 @@ class LinkableContentTest : AbstractCoreTest() { pass { moduleName = "example" analysisPlatform = "jvm" - targets = listOf("jvm") sourceRoots = listOf("jvmMain", "commonMain", "jvmAndJsSecondCommonMain").map { Paths.get("$testDataDir/$it/kotlin").toString() } @@ -68,7 +66,6 @@ class LinkableContentTest : AbstractCoreTest() { pass { moduleName = "example" analysisPlatform = "js" - targets = listOf("js") sourceRoots = listOf("$testDataDir/jsMain/kotlin") sourceLinks = listOf( SourceLinkDefinitionImpl( @@ -82,7 +79,6 @@ class LinkableContentTest : AbstractCoreTest() { pass { moduleName = "example" analysisPlatform = "jvm" - targets = listOf("jvm") sourceRoots = listOf("$testDataDir/jvmMain/kotlin") sourceLinks = listOf( SourceLinkDefinitionImpl( @@ -133,7 +129,6 @@ class LinkableContentTest : AbstractCoreTest() { pass { moduleName = "example" analysisPlatform = "js" - targets = listOf("js") sourceRoots = listOf("$testDataDir/jsMain/kotlin") sourceSetName = "js" samples = listOf("$testDataDir/jsMain/resources/Samples.kt") @@ -141,7 +136,6 @@ class LinkableContentTest : AbstractCoreTest() { pass { moduleName = "example" analysisPlatform = "jvm" - targets = listOf("jvm") sourceRoots = listOf("$testDataDir/jvmMain/kotlin") sourceSetName = "jvm" samples = listOf("$testDataDir/jvmMain/resources/Samples.kt") @@ -199,7 +193,7 @@ class LinkableContentTest : AbstractCoreTest() { pass { sourceRoots = listOf("src/") analysisPlatform = "jvm" - targets = listOf("jvm") + sourceSetName = "js" } } } diff --git a/plugins/base/src/test/kotlin/markdown/LinkTest.kt b/plugins/base/src/test/kotlin/markdown/LinkTest.kt index 20bd24ee..ddcef5db 100644 --- a/plugins/base/src/test/kotlin/markdown/LinkTest.kt +++ b/plugins/base/src/test/kotlin/markdown/LinkTest.kt @@ -70,7 +70,7 @@ class LinkTest : AbstractCoreTest() { val innerClass = root.children.first { it is ClasslikePageNode } val foo = innerClass.children.first { it.name == "foo" } as MemberPageNode - assertEquals(root.dri.first().toString(), "[main root]/Outer///PointingToDeclaration/") + assertEquals(root.dri.first().toString(), "[JVM root]/Outer///PointingToDeclaration/") assertNotNull(foo.content.dfs { it is ContentDRILink && it.address.toString() == root.dri.first().toString() } ) } } diff --git a/plugins/base/src/test/kotlin/model/InheritorsTest.kt b/plugins/base/src/test/kotlin/model/InheritorsTest.kt index ce8a87ca..5daebb73 100644 --- a/plugins/base/src/test/kotlin/model/InheritorsTest.kt +++ b/plugins/base/src/test/kotlin/model/InheritorsTest.kt @@ -48,12 +48,10 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", pass { sourceRoots = listOf("common/src/", "jvm/src/") analysisPlatform = "jvm" - targets = listOf("jvm") } pass { sourceRoots = listOf("common/src/", "js/src/") analysisPlatform = "js" - targets = listOf("js") } } } diff --git a/plugins/base/src/test/kotlin/model/PackagesTest.kt b/plugins/base/src/test/kotlin/model/PackagesTest.kt index 676f034a..c777ad05 100644 --- a/plugins/base/src/test/kotlin/model/PackagesTest.kt +++ b/plugins/base/src/test/kotlin/model/PackagesTest.kt @@ -14,8 +14,8 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac """.trimIndent(), prependPackage = false ) { - with((this / "[main root]").cast<DPackage>()) { - name equals "[main root]" + with((this / "[JVM root]").cast<DPackage>()) { + name equals "[JVM root]" children counts 0 } } diff --git a/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt b/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt index a3bf9188..a4d7bd04 100644 --- a/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt +++ b/plugins/base/src/test/kotlin/renderers/RenderingOnlyTestBase.kt @@ -33,10 +33,10 @@ abstract class RenderingOnlyTestBase { DokkaBase().outputWriter to { _ -> files }, DokkaBase().locationProviderFactory to ::DefaultLocationProviderFactory, DokkaBase().htmlPreprocessors to { _ -> RootCreator }, - DokkaBase().externalLocationProviderFactory to { _ -> ::JavadocExternalLocationProviderFactory }, - DokkaBase().externalLocationProviderFactory to { _ -> ::DokkaExternalLocationProviderFactory }, + DokkaBase().externalLocationProviderFactory to { ::JavadocExternalLocationProviderFactory }, + DokkaBase().externalLocationProviderFactory to { ::DokkaExternalLocationProviderFactory }, sourceSetCache = SourceSetCache(), - testConfiguration = DokkaConfigurationImpl("", "", false, null, emptyList(), emptyList(), emptyList(), emptyMap(), emptyList()) + testConfiguration = DokkaConfigurationImpl("", "", null, false, emptyList(), emptyList(), emptyMap(), emptyList()) ) protected val renderedContent: Element by lazy { diff --git a/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt b/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt index fa129760..b10202bb 100644 --- a/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt @@ -10,9 +10,9 @@ import org.junit.jupiter.api.Test import renderers.* class DivergentTest : RenderingOnlyTestBase() { - private val js = SourceSetData("root", "JS", Platform.js, listOf(SourceRootImpl("pl1"))) - private val jvm = SourceSetData("root", "JVM", Platform.jvm, listOf(SourceRootImpl("pl1"))) - private val native = SourceSetData("root", "NATIVE", Platform.native, listOf(SourceRootImpl("pl1"))) + private val js = SourceSetData("root", "js", "JS", Platform.js, listOf(SourceRootImpl("pl1"))) + private val jvm = SourceSetData("root", "jvm", "JVM", Platform.jvm, listOf(SourceRootImpl("pl1"))) + private val native = SourceSetData("root", "native", "NATIVE", Platform.native, listOf(SourceRootImpl("pl1"))) @Test fun simpleWrappingCase() { diff --git a/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt b/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt index c1dc40a7..878f442b 100644 --- a/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt @@ -12,9 +12,9 @@ import renderers.TestPage import renderers.match class SourceSetDependentHintTest : RenderingOnlyTestBase() { - private val pl1 = SourceSetData("root", "pl1", Platform.js, listOf(SourceRootImpl("pl1"))) - private val pl2 = SourceSetData("root","pl2", Platform.jvm, listOf(SourceRootImpl("pl1"))) - private val pl3 = SourceSetData("root","pl3", Platform.native, listOf(SourceRootImpl("pl1"))) + private val pl1 = SourceSetData("root", "pl1", "pl3",Platform.js, listOf(SourceRootImpl("pl1"))) + private val pl2 = SourceSetData("root","pl2", "pl3", Platform.jvm, listOf(SourceRootImpl("pl1"))) + private val pl3 = SourceSetData("root","pl3", "pl3", Platform.native, listOf(SourceRootImpl("pl1"))) @Test fun platformIndependentCase() { diff --git a/plugins/base/src/test/kotlin/utils/ModelUtils.kt b/plugins/base/src/test/kotlin/utils/ModelUtils.kt index f65258b1..9697a843 100644 --- a/plugins/base/src/test/kotlin/utils/ModelUtils.kt +++ b/plugins/base/src/test/kotlin/utils/ModelUtils.kt @@ -9,7 +9,6 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo fun inlineModelTest( query: String, platform: String = "jvm", - targetList: List<String> = listOf("jvm"), prependPackage: Boolean = true, cleanupOutput: Boolean = true, pluginsOverrides: List<DokkaPlugin> = emptyList(), @@ -21,7 +20,6 @@ abstract class AbstractModelTest(val path: String? = null, val pkg: String) : Mo pass { sourceRoots = listOf("src/") analysisPlatform = platform - targets = targetList } } } diff --git a/plugins/gfm/src/main/kotlin/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/GfmPlugin.kt index cc79291c..b10a45b8 100644 --- a/plugins/gfm/src/main/kotlin/GfmPlugin.kt +++ b/plugins/gfm/src/main/kotlin/GfmPlugin.kt @@ -120,7 +120,7 @@ open class CommonmarkRenderer( append(distinct.keys.single()) else distinct.forEach { text, platforms -> - append(platforms.joinToString(prefix = " [", postfix = "] $text") { "${it.moduleName}/${it.sourceSetName}" }) + append(platforms.joinToString(prefix = " [", postfix = "] $text") { "${it.moduleName}/${it.sourceSetID}" }) } } |