-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
All Types
page generation (#3267)
* Hide All Types page under a system property * Show documentation if it exists selecting most relevant * Take the minimum SinceKotlin version if they differ * Extract internal configuration properties to one place
- Loading branch information
Showing
20 changed files
with
927 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ts/plugin-base/src/main/kotlin/org/jetbrains/dokka/base/DokkaBaseInternalConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package org.jetbrains.dokka.base | ||
|
||
// revisit in scope of https://github.com/Kotlin/dokka/issues/2776 | ||
internal object DokkaBaseInternalConfiguration { | ||
const val SHOULD_DISPLAY_ALL_TYPES_PAGE_SYS_PROP = "dokka.shouldDisplayAllTypesPage" | ||
const val SHOULD_DISPLAY_SINCE_KOTLIN_SYS_PROP = "dokka.shouldDisplaySinceKotlin" | ||
|
||
var allTypesPageEnabled: Boolean = false | ||
private set | ||
var sinceKotlinRenderingEnabled: Boolean = false | ||
private set | ||
|
||
init { | ||
reinitialize() | ||
} | ||
|
||
// should be private, internal is only for usage in tests | ||
internal fun reinitialize() { | ||
allTypesPageEnabled = getBooleanProperty(SHOULD_DISPLAY_ALL_TYPES_PAGE_SYS_PROP) | ||
sinceKotlinRenderingEnabled = getBooleanProperty(SHOULD_DISPLAY_SINCE_KOTLIN_SYS_PROP) | ||
} | ||
|
||
private fun getBooleanProperty(propertyName: String): Boolean { | ||
return System.getProperty(propertyName) in setOf("1", "true") | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...ubprojects/plugin-base/src/main/kotlin/org/jetbrains/dokka/base/pages/AllTypesPageNode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package org.jetbrains.dokka.base.pages | ||
|
||
import org.jetbrains.dokka.links.DRI | ||
import org.jetbrains.dokka.pages.ContentNode | ||
import org.jetbrains.dokka.pages.ContentPage | ||
import org.jetbrains.dokka.pages.PageNode | ||
|
||
/** | ||
* This page is internal because it's an stdlib-specific feature, | ||
* which is not intended for public use or customization. | ||
* | ||
* For more details, see https://github.com/Kotlin/dokka/issues/2887 | ||
*/ | ||
internal class AllTypesPageNode( | ||
override val content: ContentNode, | ||
override val embeddedResources: List<String> = listOf() | ||
) : ContentPage { | ||
override val dri: Set<DRI> = setOf(DRI) | ||
override val name: String = "All Types" | ||
override val children: List<PageNode> get() = emptyList() | ||
|
||
override fun modified(name: String, children: List<PageNode>): AllTypesPageNode = | ||
modified(name = name, content = this.content, dri = dri, children = children) | ||
|
||
override fun modified( | ||
name: String, | ||
content: ContentNode, | ||
dri: Set<DRI>, | ||
embeddedResources: List<String>, | ||
children: List<PageNode> | ||
): AllTypesPageNode = | ||
if (name == this.name && content === this.content && embeddedResources === this.embeddedResources && children shallowEq this.children) this | ||
else AllTypesPageNode(content, embeddedResources) | ||
|
||
companion object { | ||
val DRI: DRI = DRI(packageName = ".alltypes") | ||
} | ||
} | ||
|
||
// copy-pasted from dokka-core, not sure why it was needed in the first place | ||
private infix fun <T> List<T>.shallowEq(other: List<T>) = | ||
this === other || (this.size == other.size && (this zip other).all { (a, b) -> a === b }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.