From 732d181e4908ed0ddc513e305addc71560c0e109 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 26 Aug 2020 16:56:39 +0200 Subject: Let root package be represented as [root] to the user --- core/src/main/kotlin/model/Documentable.kt | 15 ++++++++++++--- core/src/main/kotlin/pages/PageNodes.kt | 5 +++++ 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index 293b8a30..34ad6c2b 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -111,9 +111,18 @@ data class DPackage( override val sourceSets: Set = emptySet(), override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), WithScope, WithExtraProperties { - override val name = dri.packageName.orEmpty() - override val children: List - get() = (properties + functions + classlikes + typealiases) + + val packageName: String = dri.packageName.orEmpty() + + /** + * !!! WARNING !!! + * This name is not guaranteed to be a be a canonical/real package name. + * e.g. this will return a human readable version for root packages. + * Use [packageName] or `dri.packageName` instead to obtain the real packageName + */ + override val name: String = if (packageName.isBlank()) "[root]" else packageName + + override val children: List = properties + functions + classlikes + typealiases override fun withNewExtras(newExtras: PropertyContainer) = copy(extra = newExtras) } diff --git a/core/src/main/kotlin/pages/PageNodes.kt b/core/src/main/kotlin/pages/PageNodes.kt index 176c0993..a91887b4 100644 --- a/core/src/main/kotlin/pages/PageNodes.kt +++ b/core/src/main/kotlin/pages/PageNodes.kt @@ -92,6 +92,11 @@ class PackagePageNode( override val children: List, override val embeddedResources: List = listOf() ) : PackagePage { + + init { + require(name.isNotBlank()) { "PackagePageNode.name cannot be blank" } + } + override fun modified(name: String, children: List): PackagePageNode = modified(name = name, content = this.content, children = children) -- cgit