diff options
author | Marcin Aman <maman@virtuslab.com> | 2020-06-03 09:30:28 +0200 |
---|---|---|
committer | Paweł Marks <pmarks@virtuslab.com> | 2020-06-12 14:15:24 +0200 |
commit | 3ca8ca75c60892de68f4fe18335aa79f4622c93c (patch) | |
tree | 19b4a936a602edfaf6eec8ec0882285e2af403fb /plugins/base | |
parent | dd44b839eac1b7b647e97f2cc73dd96bd054713b (diff) | |
download | dokka-3ca8ca75c60892de68f4fe18335aa79f4622c93c.tar.gz dokka-3ca8ca75c60892de68f4fe18335aa79f4622c93c.tar.bz2 dokka-3ca8ca75c60892de68f4fe18335aa79f4622c93c.zip |
Stdlib wrapping in signature
Diffstat (limited to 'plugins/base')
4 files changed, 33 insertions, 9 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 67fa2d91..42273d20 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -67,6 +67,15 @@ open class HtmlRenderer( childrenCallback() if (node.hasStyle(TextStyle.Monospace)) copyButton() } + node.hasStyle(TextStyle.BreakableAfter) -> { + span(){ childrenCallback() } + wbr { } + } + node.hasStyle(TextStyle.Breakable) -> { + span("breakable-word"){ childrenCallback() } + } + node.hasStyle(TextStyle.Span) -> span(){ childrenCallback() } + node.dci.kind == ContentKind.Symbol -> div("symbol $additionalClasses") { childrenCallback() } node.dci.kind == ContentKind.BriefComment -> div("brief $additionalClasses") { childrenCallback() } node.dci.kind == ContentKind.Cover -> div("cover $additionalClasses") { filterButtons(node) diff --git a/plugins/base/src/main/kotlin/renderers/html/Tags.kt b/plugins/base/src/main/kotlin/renderers/html/Tags.kt new file mode 100644 index 00000000..a3951eff --- /dev/null +++ b/plugins/base/src/main/kotlin/renderers/html/Tags.kt @@ -0,0 +1,12 @@ +package org.jetbrains.dokka.base.renderers.html + +import kotlinx.html.* + +@HtmlTagMarker +fun FlowOrPhrasingContent.wbr(classes : String? = null, block : WBR.() -> Unit = {}) : Unit = WBR(attributesMapOf("class", classes), consumer).visit(block) + +@Suppress("unused") +open class WBR(initialAttributes : Map<String, String>, override val consumer : TagConsumer<*>) : HTMLTag("wbr", consumer, initialAttributes, null, true, false), + HtmlBlockInlineTag { + +}
\ No newline at end of file diff --git a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt index 7f0e985e..f8141110 100644 --- a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt +++ b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt @@ -25,6 +25,7 @@ interface JvmSignatureUtils { private fun PageContentBuilder.DocumentableContentBuilder.annotations( d: Documentable, ignored: Set<Annotations.Annotation>, + styles: Set<Style>, operation: PageContentBuilder.DocumentableContentBuilder.(Annotations.Annotation) -> Unit ): Unit = when (d) { is DFunction -> d.annotations() @@ -42,7 +43,7 @@ interface JvmSignatureUtils { }?.let { it.entries.forEach { it.value.filter { it !in ignored }.takeIf { it.isNotEmpty() }?.let { annotations -> - group(sourceSets = setOf(it.key), styles = setOf(TextStyle.Block)) { + group(sourceSets = setOf(it.key), styles = styles) { annotations.forEach { operation(it) } @@ -65,13 +66,13 @@ interface JvmSignatureUtils { link(a.dri.classNames!!, a.dri) text("(") a.params.entries.forEachIndexed { i, it -> - group(styles = setOf(TextStyle.Span)) { + group(styles = setOf(TextStyle.BreakableAfter)) { text(it.key + " = ") when (renderAtStrategy) { is All -> All is Never, is OnlyOnce -> Never }.let { strategy -> - valueToSignature(it.value, strategy, listBrackets, classExtension) + valueToSignature(it.value, strategy, listBrackets, classExtension) } if (i != a.params.entries.size - 1) text(", ") } @@ -89,14 +90,16 @@ interface JvmSignatureUtils { is ArrayValue -> { text(listBrackets.first.toString()) a.value.forEachIndexed { i, it -> - valueToSignature(it, renderAtStrategy, listBrackets, classExtension) - if (i != a.value.size - 1) text(", ") + group(styles = setOf(TextStyle.BreakableAfter)) { + valueToSignature(it, renderAtStrategy, listBrackets, classExtension) + if (i != a.value.size - 1) text(", ") + } } text(listBrackets.second.toString()) } is EnumValue -> link(a.enumName, a.enumDri) is ClassValue -> link(a.className + classExtension, a.classDRI) - is StringValue -> text(a.value) + is StringValue -> group(styles = setOf(TextStyle.Breakable)) { text(a.value) } } fun PageContentBuilder.DocumentableContentBuilder.annotationsBlockWithIgnored( @@ -106,7 +109,7 @@ interface JvmSignatureUtils { listBrackets: Pair<Char, Char>, classExtension: String ) { - annotations(d, ignored) { + annotations(d, ignored, setOf(TextStyle.Block)) { group { toSignatureString(it, renderAtStrategy, listBrackets, classExtension) } @@ -120,7 +123,7 @@ interface JvmSignatureUtils { listBrackets: Pair<Char, Char>, classExtension: String ) { - annotations(d, ignored) { + annotations(d, ignored, setOf(TextStyle.Span)) { toSignatureString(it, renderAtStrategy, listBrackets, classExtension) text(Typography.nbsp.toString()) } diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 542f6a1a..04818ebb 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -249,7 +249,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } private fun funType(dri: DRI, sourceSets: Set<SourceSetData>, type: TypeConstructor) = - contentBuilder.contentFor(dri, sourceSets) { + contentBuilder.contentFor(dri, sourceSets, ContentKind.Main) { if (type.extension) { signatureForProjection(type.projections.first()) text(".") |