diff options
author | vmishenev <vad-mishenev@yandex.ru> | 2021-08-25 17:14:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 16:14:31 +0200 |
commit | 4fa9524e52d8ff422bb355336e3810ab28ae135c (patch) | |
tree | 66d2bc381ffc7d5c598cee4ea9e0ba13f81b1d7b /plugins/base/src/main/kotlin/translators/documentables | |
parent | 742f96bdf5c0b842e68dfaf43f4ab3446e87e3df (diff) | |
download | dokka-4fa9524e52d8ff422bb355336e3810ab28ae135c.tar.gz dokka-4fa9524e52d8ff422bb355336e3810ab28ae135c.tar.bz2 dokka-4fa9524e52d8ff422bb355336e3810ab28ae135c.zip |
Manual highlighting webhelp (#2079)
* Add manual code highlighting
* Fix test
* Add kotlinAsJava highlighting
* Add runtime highlighting via Prism
* Add copy-button for code block
* Add tests and refactor
* Replace `<br>` for prism.js
* Parse trivial default values
Co-authored-by: Marcin Aman <marcin.aman@gmail.com>
Diffstat (limited to 'plugins/base/src/main/kotlin/translators/documentables')
-rw-r--r-- | plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt index f98e284f..cbab6273 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt @@ -122,6 +122,13 @@ open class PageContentBuilder( header(1, text, sourceSets = sourceSets, styles = styles, extra = extra, block = block) } + fun constant(text: String) = text(text, styles = mainStyles + TokenStyle.Constant) + fun keyword(text: String) = text(text, styles = mainStyles + TokenStyle.Keyword) + fun stringLiteral(text: String) = text(text, styles = mainStyles + TokenStyle.String) + fun booleanLiteral(value: Boolean) = text(value.toString(), styles = mainStyles + TokenStyle.Boolean) + fun punctuation(text: String) = text(text, styles = mainStyles + TokenStyle.Punctuation) + fun operator(text: String) = text(text, styles = mainStyles + TokenStyle.Operator) + fun text( text: String, kind: Kind = ContentKind.Main, @@ -194,16 +201,18 @@ open class PageContentBuilder( suffix: String = "", separator: String = ", ", sourceSets: Set<DokkaSourceSet> = mainSourcesetData, // TODO: children should be aware of this platform data + surroundingCharactersStyle: Set<Style> = mainStyles, + separatorStyles: Set<Style> = mainStyles, operation: DocumentableContentBuilder.(T) -> Unit ) { if (elements.isNotEmpty()) { - if (prefix.isNotEmpty()) text(prefix, sourceSets = sourceSets) + if (prefix.isNotEmpty()) text(prefix, sourceSets = sourceSets, styles = surroundingCharactersStyle) elements.dropLast(1).forEach { operation(it) - text(separator, sourceSets = sourceSets) + text(separator, sourceSets = sourceSets, styles = separatorStyles) } operation(elements.last()) - if (suffix.isNotEmpty()) text(suffix, sourceSets = sourceSets) + if (suffix.isNotEmpty()) text(suffix, sourceSets = sourceSets, styles = surroundingCharactersStyle) } } @@ -380,11 +389,12 @@ open class PageContentBuilder( fun <T> sourceSetDependentText( value: SourceSetDependent<T>, sourceSets: Set<DokkaSourceSet> = value.keys, + styles: Set<Style> = mainStyles, transform: (T) -> String ) = value.entries.filter { it.key in sourceSets }.mapNotNull { (p, v) -> transform(v).takeIf { it.isNotBlank() }?.let { it to p } }.groupBy({ it.first }) { it.second }.forEach { - text(it.key, sourceSets = it.value.toSet()) + text(it.key, sourceSets = it.value.toSet(), styles = styles) } } |