diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 36 | ||||
-rw-r--r-- | plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt | 46 |
2 files changed, 59 insertions, 23 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 53222325..439a8fbe 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -27,6 +27,7 @@ open class HtmlRenderer( ) { val additionalClasses = node.style.joinToString(" ") { it.toString().toLowerCase() } return when { + ContentKind.shouldBePlatformTagged(node.dci.kind) -> wrapPlatformTagged(node, pageContext) { childrenCallback() } node.dci.kind == ContentKind.Symbol -> div("symbol $additionalClasses") { childrenCallback() } node.dci.kind == ContentKind.BriefComment -> div("brief $additionalClasses") { childrenCallback() } node.style.contains(TextStyle.Paragraph) -> p(additionalClasses) { childrenCallback() } @@ -35,6 +36,23 @@ open class HtmlRenderer( } } + private fun FlowContent.wrapPlatformTagged( + node: ContentGroup, + pageContext: ContentPage, + childrenCallback: FlowContent.() -> Unit + ) { + div("platform-tagged"){ + node.platforms.forEach { + div("platform-tag ${it.platformType.name}"){ + text(it.platformType.key.toUpperCase()) + } + } + div("content"){ + childrenCallback() + } + } + } + override fun FlowContent.buildPlatformDependent(content: PlatformHintedContent, pageContext: ContentPage) { val distinct = content.platforms.map { it to createHTML(prettyPrint = false).div { @@ -97,6 +115,22 @@ open class HtmlRenderer( } } + private fun TR.buildPlatformTags( + node: ContentGroup + ) { + if(ContentKind.shouldBePlatformTagged(node.dci.kind)) { + td { + div("platform-tagged"){ + node.platforms.forEach { + div(("platform-tag ${it.platformType.key}")) { + text(it.platformType.key.toUpperCase()) + } + } + } + } + } + } + override fun FlowContent.buildTable( node: ContentTable, pageContext: ContentPage, @@ -122,12 +156,14 @@ open class HtmlRenderer( it.build(this, pageContext, platformRestriction) } } + buildPlatformTags(it) } } } } } + override fun FlowContent.buildHeader(level: Int, content: FlowContent.() -> Unit) { when (level) { 1 -> h1(block = content) diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 11f57696..349d9970 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -63,7 +63,9 @@ open class DefaultPageCreator( } protected open fun contentForPackage(p: DPackage) = contentBuilder.contentFor(p) { - header(1) { text("Package ${p.name}") } + group(p.dri, p.platformData.toSet(), ContentKind.Packages){ + header(1) { text("Package ${p.name}") } + } +contentForScope(p, p.dri, p.platformData) } @@ -99,6 +101,7 @@ open class DefaultPageCreator( platformDependentHint(it.dri, it.platformData.toSet()) { +buildSignature(it) } + breakLine() group(kind = ContentKind.BriefComment) { text(it.briefDocumentation()) } @@ -124,11 +127,12 @@ open class DefaultPageCreator( } protected open fun contentForClasslike(c: DClasslike) = contentBuilder.contentFor(c) { - header(1) { text(c.name.orEmpty()) } - platformDependentHint(c.dri, c.platformData.toSet()) { - +buildSignature(c) + group(c.dri, c.platformData.toSet(), ContentKind.Classlikes){ + header(1) { text(c.name.orEmpty()) } + platformDependentHint(c.dri, c.platformData.toSet()) { + +buildSignature(c) + } } - breakLine() +contentForComments(c) { it !is Property } if (c is WithConstructors) { @@ -140,26 +144,20 @@ open class DefaultPageCreator( c.platformData.toSet() ) { link(it.name, it.dri) - group { - platformDependentHint(it.dri, it.platformData.toSet()) { - +buildSignature(it) - } - group(kind = ContentKind.BriefComment) { - text(it.briefDocumentation()) - } + platformDependentHint(it.dri, it.platformData.toSet()) { + +buildSignature(it) + } + group(kind = ContentKind.BriefComment) { + text(it.briefDocumentation()) } } } if (c is DEnum) { - block( - "Entries", 2, ContentKind.Classlikes, c.entries, c.platformData.toSet() - ) { + block("Entries", 2, ContentKind.Classlikes, c.entries, c.platformData.toSet()) { link(it.name.orEmpty(), it.dri) - group { - +buildSignature(it) - group(kind = ContentKind.BriefComment) { - text(it.briefDocumentation()) - } + +buildSignature(it) + group(kind = ContentKind.BriefComment) { + text(it.briefDocumentation()) } } } @@ -196,9 +194,11 @@ open class DefaultPageCreator( }.children protected open fun contentForFunction(f: DFunction) = contentBuilder.contentFor(f) { - header(1) { text(f.name) } - platformDependentHint(f.dri, f.platformData.toSet()) { - +buildSignature(f) + group(f.dri, f.platformData.toSet(), ContentKind.Functions) { + header(1) { text(f.name) } + platformDependentHint(f.dri, f.platformData.toSet()) { + +buildSignature(f) + } } +contentForComments(f) } |