diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-08-26 15:40:23 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-31 15:10:04 +0200 |
commit | 9bf535bf8c0b758fc0abf99b61208fa5430239d6 (patch) | |
tree | f11c932bb8314e8d9aa885825f678c628ce6fef9 /plugins | |
parent | ee13af00483887fb6cfdde10a58cbb43542cf2d7 (diff) | |
download | dokka-9bf535bf8c0b758fc0abf99b61208fa5430239d6.tar.gz dokka-9bf535bf8c0b758fc0abf99b61208fa5430239d6.tar.bz2 dokka-9bf535bf8c0b758fc0abf99b61208fa5430239d6.zip |
Let `DRI.packageName` always be a real package name for root packages ("")
Diffstat (limited to 'plugins')
4 files changed, 11 insertions, 18 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt index 096104cc..f25f85a6 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt @@ -89,7 +89,10 @@ open class DokkaLocationProvider( private fun PageNode.parent() = pageGraphRoot.parentMap[this] private val PageNode.pathName: String - get() = if (this is PackagePageNode) name else identifierToFilename(name) + get() = when (this) { + is PackagePageNode -> if (name.isBlank()) "[root]" else name + else -> identifierToFilename(name) + } companion object { internal val reservedFilenames = setOf("index", "con", "aux", "lst", "prn", "nul", "eof", "inp", "out") diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index fccbe716..18b05df4 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -104,7 +104,7 @@ private class DokkaDescriptorVisitor( descriptor: PackageFragmentDescriptor, parent: DRIWithPlatformInfo ): DPackage { - val name = descriptor.fqName.asString().takeUnless { it.isBlank() } ?: fallbackPackageName() + val name = descriptor.fqName.asString().takeUnless { it.isBlank() } ?: "" val driWithPlatform = DRI(packageName = name).withEmptyInfo() val scope = descriptor.getMemberScope() @@ -590,7 +590,7 @@ private class DokkaDescriptorVisitor( private fun TypeParameterDescriptor.toVariantTypeParameter() = DTypeParameter( variantTypeParameter( - TypeParameter(DRI.from(this).withPackageFallbackTo(fallbackPackageName()), name.identifier) + TypeParameter(DRI.from(this), name.identifier) ), resolveDescriptorData(), null, @@ -603,7 +603,7 @@ private class DokkaDescriptorVisitor( is DynamicType -> Dynamic else -> when (val ctor = constructor.declarationDescriptor) { is TypeParameterDescriptor -> TypeParameter( - dri = DRI.from(ctor).withPackageFallbackTo(fallbackPackageName()), + dri = DRI.from(ctor), name = ctor.name.asString() ) else -> TypeConstructor( @@ -776,14 +776,4 @@ private class DokkaDescriptorVisitor( private fun ConstantsEnumValue.fullEnumEntryName() = "${this.enumClassId.relativeClassName.asString()}.${this.enumEntryName.identifier}" - private fun fallbackPackageName(): String = - "[${sourceSet.displayName} root]"// TODO: error-prone, find a better way to do it -} - -private fun DRI.withPackageFallbackTo(fallbackPackage: String): DRI { - return if (packageName.isNullOrBlank()) { - copy(packageName = fallbackPackage) - } else { - this - } } diff --git a/plugins/base/src/test/kotlin/markdown/LinkTest.kt b/plugins/base/src/test/kotlin/markdown/LinkTest.kt index deef1d2d..b84eead4 100644 --- a/plugins/base/src/test/kotlin/markdown/LinkTest.kt +++ b/plugins/base/src/test/kotlin/markdown/LinkTest.kt @@ -73,7 +73,7 @@ class LinkTest : AbstractCoreTest() { val foo = innerClass.children.first { it.name == "foo" } as MemberPageNode val destinationDri = (root.documentable as WithGenerics).generics.first().dri.toString() - assertEquals(destinationDri, "[JVM root]/Outer///PointingToGenericParameters(0)/") + assertEquals(destinationDri, "/Outer///PointingToGenericParameters(0)/") assertNotNull(foo.content.dfs { it is ContentDRILink && it.address.toString() == destinationDri } ) } } diff --git a/plugins/base/src/test/kotlin/model/PackagesTest.kt b/plugins/base/src/test/kotlin/model/PackagesTest.kt index 86222d95..188ee2c6 100644 --- a/plugins/base/src/test/kotlin/model/PackagesTest.kt +++ b/plugins/base/src/test/kotlin/model/PackagesTest.kt @@ -22,8 +22,8 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac } } ) { - with((this / "[JVM root]").cast<DPackage>()) { - name equals "[JVM root]" + with((this / "").cast<DPackage>()) { + name equals "" children counts 0 } } @@ -131,4 +131,4 @@ class PackagesTest : AbstractModelTest("/src/main/kotlin/packages/Test.kt", "pac // assertEquals(0, model.members.count()) // } // } -}
\ No newline at end of file +} |