From 65eb3ef308773a10d6fc07050f8e16357431f6d5 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Sun, 17 May 2020 17:22:46 +0200 Subject: Rename platformRestriction to sourceSetRestriction --- .../src/main/kotlin/renderers/DefaultRenderer.kt | 36 +++++++++++----------- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 18 ----------- 2 files changed, 18 insertions(+), 36 deletions(-) (limited to 'plugins/base/src') diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt index e229f3a6..a089f8f5 100644 --- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt @@ -28,7 +28,7 @@ abstract class DefaultRenderer( abstract fun T.buildList( node: ContentList, pageContext: ContentPage, - platformRestriction: Set? = null + sourceSetRestriction: Set? = null ) abstract fun T.buildNewLine() @@ -36,7 +36,7 @@ abstract class DefaultRenderer( abstract fun T.buildTable( node: ContentTable, pageContext: ContentPage, - platformRestriction: Set? = null + sourceSetRestriction: Set? = null ) abstract fun T.buildText(textNode: ContentText) @@ -51,9 +51,9 @@ abstract class DefaultRenderer( open fun T.buildGroup( node: ContentGroup, pageContext: ContentPage, - platformRestriction: Set? = null + sourceSetRestriction: Set? = null ) = - wrapGroup(node, pageContext) { node.children.forEach { it.build(this, pageContext, platformRestriction) } } + wrapGroup(node, pageContext) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } } open fun T.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) = node.children.forEach { it.build(this, pageContext) } @@ -64,9 +64,9 @@ abstract class DefaultRenderer( open fun T.buildLinkText( nodes: List, pageContext: ContentPage, - platformRestriction: Set? = null + sourceSetRestriction: Set? = null ) { - nodes.forEach { it.build(this, pageContext, platformRestriction) } + nodes.forEach { it.build(this, pageContext, sourceSetRestriction) } } open fun T.buildCode(code: List, language: String, pageContext: ContentPage) { @@ -76,39 +76,39 @@ abstract class DefaultRenderer( open fun T.buildHeader( node: ContentHeader, pageContext: ContentPage, - platformRestriction: Set? = null + sourceSetRestriction: Set? = null ) { - buildHeader(node.level) { node.children.forEach { it.build(this, pageContext, platformRestriction) } } + buildHeader(node.level) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } } } open fun ContentNode.build( builder: T, pageContext: ContentPage, - platformRestriction: Set? = null + sourceSetRestriction: Set? = null ) = - builder.buildContentNode(this, pageContext, platformRestriction) + builder.buildContentNode(this, pageContext, sourceSetRestriction) open fun T.buildContentNode( node: ContentNode, pageContext: ContentPage, - platformRestriction: Set? = null + sourceSetRestriction: Set? = null ) { - if (platformRestriction == null || node.sourceSets.any { it in platformRestriction } ) { + if (sourceSetRestriction == null || node.sourceSets.any { it in sourceSetRestriction } ) { when (node) { is ContentText -> buildText(node) - is ContentHeader -> buildHeader(node, pageContext, platformRestriction) + is ContentHeader -> buildHeader(node, pageContext, sourceSetRestriction) is ContentCode -> buildCode(node.children, node.language, pageContext) is ContentDRILink -> buildLink(locationProvider.resolve(node.address, node.sourceSets.toList(), pageContext)) { - buildLinkText(node.children, pageContext, platformRestriction) + buildLinkText(node.children, pageContext, sourceSetRestriction) } is ContentResolvedLink -> buildLink(node.address) { - buildLinkText(node.children, pageContext, platformRestriction) + buildLinkText(node.children, pageContext, sourceSetRestriction) } is ContentEmbeddedResource -> buildResource(node, pageContext) - is ContentList -> buildList(node, pageContext, platformRestriction) - is ContentTable -> buildTable(node, pageContext, platformRestriction) - is ContentGroup -> buildGroup(node, pageContext, platformRestriction) + is ContentList -> buildList(node, pageContext, sourceSetRestriction) + is ContentTable -> buildTable(node, pageContext, sourceSetRestriction) + is ContentGroup -> buildGroup(node, pageContext, sourceSetRestriction) is ContentBreakLine -> buildNewLine() is PlatformHintedContent -> buildPlatformDependent(node, pageContext) is ContentDivergentGroup -> buildDivergent(node, pageContext) diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 97f0bdbd..9acb0f8f 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -40,24 +40,6 @@ open class HtmlRenderer( } } - private fun FlowContent.wrapPlatformTagged( - node: ContentGroup, - pageContext: ContentPage, - childrenCallback: FlowContent.() -> Unit - ) { - div("platform-tagged") { - node.sourceSets.forEach { - div("platform-tag") { - if (it.sourceSetName.equals("common", ignoreCase = true)) classes = classes + "common" - text(it.sourceSetName) - } - } - div("content") { - childrenCallback() - } - } - } - override fun FlowContent.buildPlatformDependent(content: PlatformHintedContent, pageContext: ContentPage) = buildPlatformDependent(content.sourceSets.map { it to setOf(content.inner) }.toMap(), pageContext) -- cgit