transformers.pages.PageTransformerBuilders.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dokka-core Show documentation
Show all versions of dokka-core Show documentation
Dokka is an API documentation engine for Kotlin and Java, performing the same function as Javadoc for Java
package org.jetbrains.dokka.transformers.pages
import org.jetbrains.dokka.pages.PageNode
import org.jetbrains.dokka.pages.RootPageNode
fun pageScanner(block: PageNode.() -> Unit) = object : PageTransformer {
override fun invoke(input: RootPageNode): RootPageNode = input.invokeOnAll(block) as RootPageNode
}
fun pageMapper(block: PageNode.() -> PageNode) = object : PageTransformer {
override fun invoke(input: RootPageNode): RootPageNode = input.alterChildren(block) as RootPageNode
}
fun pageStructureTransformer(block: RootPageNode.() -> RootPageNode) = object : PageTransformer {
override fun invoke(input: RootPageNode): RootPageNode = block(input)
}
fun PageNode.invokeOnAll(block: PageNode.() -> Unit): PageNode =
this.also(block).also { it.children.forEach { it.invokeOnAll(block) } }
fun PageNode.alterChildren(block: PageNode.() -> PageNode): PageNode =
block(this).modified(children = this.children.map { it.alterChildren(block) })
© 2015 - 2025 Weber Informatics LLC | Privacy Policy