diff options
Diffstat (limited to 'core/src/main/kotlin/pages')
-rw-r--r-- | core/src/main/kotlin/pages/ContentNodes.kt | 12 | ||||
-rw-r--r-- | core/src/main/kotlin/pages/PageNodes.kt | 10 |
2 files changed, 16 insertions, 6 deletions
diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt index 40b5e114..dcc511cc 100644 --- a/core/src/main/kotlin/pages/ContentNodes.kt +++ b/core/src/main/kotlin/pages/ContentNodes.kt @@ -132,4 +132,14 @@ interface HTMLMetadata: Extra { } data class HTMLSimpleAttr(override val key: String, override val value: String): HTMLMetadata -data class HTMLTableMetadata(val item: String, override val key: String, override val value: String): HTMLMetadata
\ No newline at end of file +data class HTMLTableMetadata(val item: String, override val key: String, override val value: String): HTMLMetadata + +fun ContentNode.dfs(predicate: (ContentNode) -> Boolean): ContentNode? = if (predicate(this)) { + this +} else { + if (this is ContentComposite) { + this.children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() + } else { + null + } +} diff --git a/core/src/main/kotlin/pages/PageNodes.kt b/core/src/main/kotlin/pages/PageNodes.kt index 810cd776..6c56d5fe 100644 --- a/core/src/main/kotlin/pages/PageNodes.kt +++ b/core/src/main/kotlin/pages/PageNodes.kt @@ -6,7 +6,7 @@ import org.jetbrains.dokka.links.DRI interface PageNode { val name: String - val content: ContentNode + var content: ContentNode val parent: PageNode? val dri: DRI val documentationNode: DocumentationNode<*>? @@ -42,7 +42,7 @@ abstract class BasicPageNode(children: List<PageNode>) : PageNode { class ModulePageNode( override val name: String, - override val content: ContentNode, + override var content: ContentNode, override val documentationNode: DocumentationNode<*>?, children: List<PageNode>, override val embeddedResources: List<String> = listOf() @@ -62,7 +62,7 @@ class ModulePageNode( class PackagePageNode( override val name: String, - override val content: ContentNode, + override var content: ContentNode, override val dri: DRI, override val documentationNode: DocumentationNode<*>?, children: List<PageNode>, @@ -81,7 +81,7 @@ class PackagePageNode( class ClassPageNode( override val name: String, - override val content: ContentNode, + override var content: ContentNode, override val dri: DRI, override val documentationNode: DocumentationNode<*>?, children: List<PageNode>, @@ -100,7 +100,7 @@ class ClassPageNode( class MemberPageNode( override val name: String, - override val content: ContentNode, + override var content: ContentNode, override val dri: DRI, override val documentationNode: DocumentationNode<*>?, children: List<PageNode> = emptyList(), |