aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers/html
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-08-31 20:16:01 +0200
committerGitHub <noreply@github.com>2023-08-31 20:16:01 +0200
commit02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 (patch)
tree66f6d6f089a93b863bf1144666491eca6729ad05 /plugins/base/src/main/kotlin/renderers/html
parent6a181a7a2b03ec263788d137610e86937a57d434 (diff)
downloaddokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.gz
dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.bz2
dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.zip
Enable explicit API mode (#3139)
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers/html')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt103
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt6
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt24
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt25
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/Tags.kt34
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/command/consumers/ImmediateResolutionTagConsumer.kt10
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/command/consumers/PathToRootConsumer.kt4
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/command/consumers/ReplaceVersionsConsumer.kt4
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/command/consumers/ResolveLinkConsumer.kt4
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt7
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt20
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt6
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelMerger.kt2
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/innerTemplating/HtmlTemplater.kt12
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt6
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelMerger.kt4
16 files changed, 156 insertions, 115 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 9d361f70..083876d5 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -27,12 +27,13 @@ import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.pages.HtmlContent
import org.jetbrains.dokka.plugability.*
+import org.jetbrains.dokka.transformers.pages.PageTransformer
import org.jetbrains.dokka.utilities.htmlEscape
internal const val TEMPLATE_REPLACEMENT: String = "###"
internal const val TOGGLEABLE_CONTENT_TYPE_ATTR = "data-togglable"
-open class HtmlRenderer(
+public open class HtmlRenderer(
context: DokkaContext
) : DefaultRenderer<FlowContent>(context) {
private val sourceSetDependencyMap: Map<DokkaSourceSetID, List<DokkaSourceSetID>> =
@@ -50,7 +51,7 @@ open class HtmlRenderer(
private var shouldRenderSourceSetTabs: Boolean = false
- override val preprocessors = context.plugin<DokkaBase>().query { htmlPreprocessors }
+ override val preprocessors: List<PageTransformer> = context.plugin<DokkaBase>().query { htmlPreprocessors }
/**
* Tabs themselves are created in HTML plugin since, currently, only HTML format supports them.
@@ -253,7 +254,7 @@ open class HtmlRenderer(
content: PlatformHintedContent,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?
- ) =
+ ) {
buildPlatformDependent(
content.sourceSets.filter {
sourceSetRestriction == null || it in sourceSetRestriction
@@ -262,6 +263,7 @@ open class HtmlRenderer(
content.extra,
content.style
)
+ }
private fun FlowContent.buildPlatformDependent(
nodes: Map<DisplaySourceSet, Collection<ContentNode>>,
@@ -409,19 +411,21 @@ open class HtmlRenderer(
node: ContentList,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?
- ) = when {
- node.ordered -> {
- ol { buildListItems(node.children, pageContext, sourceSetRestriction) }
- }
- node.hasStyle(ListStyle.DescriptionList) -> {
- dl { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } }
- }
- else -> {
- ul { buildListItems(node.children, pageContext, sourceSetRestriction) }
+ ) {
+ return when {
+ node.ordered -> {
+ ol { buildListItems(node.children, pageContext, sourceSetRestriction) }
+ }
+ node.hasStyle(ListStyle.DescriptionList) -> {
+ dl { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } }
+ }
+ else -> {
+ ul { buildListItems(node.children, pageContext, sourceSetRestriction) }
+ }
}
}
- open fun OL.buildListItems(
+ public open fun OL.buildListItems(
items: List<ContentNode>,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>? = null
@@ -434,7 +438,7 @@ open class HtmlRenderer(
}
}
- open fun UL.buildListItems(
+ public open fun UL.buildListItems(
items: List<ContentNode>,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>? = null
@@ -450,12 +454,13 @@ open class HtmlRenderer(
override fun FlowContent.buildResource(
node: ContentEmbeddedResource,
pageContext: ContentPage
- ) = // TODO: extension point there
+ ) { // TODO: extension point there
if (node.isImage()) {
img(src = node.address, alt = node.altText)
} else {
println("Unrecognized resource type: $node")
}
+ }
private fun FlowContent.buildRow(
node: ContentGroup,
@@ -642,7 +647,7 @@ open class HtmlRenderer(
}
- fun FlowContent.buildDefaultTable(
+ public fun FlowContent.buildDefaultTable(
node: ContentTable,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?
@@ -709,7 +714,7 @@ open class HtmlRenderer(
}
- override fun FlowContent.buildNavigation(page: PageNode) =
+ override fun FlowContent.buildNavigation(page: PageNode) {
div(classes = "breadcrumbs") {
val path = locationProvider.ancestors(page).filterNot { it is RendererSpecificPage }.asReversed()
if (path.size > 1) {
@@ -722,6 +727,7 @@ open class HtmlRenderer(
}
}
}
+ }
private fun FlowContent.buildNavigationElement(node: PageNode, page: PageNode) =
if (node.isNavigable) {
@@ -747,7 +753,7 @@ open class HtmlRenderer(
text(to.name)
}
- fun FlowContent.buildAnchorCopyButton(pointingTo: String) {
+ public fun FlowContent.buildAnchorCopyButton(pointingTo: String) {
span(classes = "anchor-wrapper") {
span(classes = "anchor-icon") {
attributes["pointing-to"] = pointingTo
@@ -756,17 +762,23 @@ open class HtmlRenderer(
}
}
- fun FlowContent.buildLink(
+ public fun FlowContent.buildLink(
to: DRI,
platforms: List<DisplaySourceSet>,
from: PageNode? = null,
block: FlowContent.() -> Unit
- ) = locationProvider.resolve(to, platforms.toSet(), from)?.let { buildLink(it, block) }
- ?: run { context.logger.error("Cannot resolve path for `$to` from `$from`"); block() }
+ ) {
+ locationProvider.resolve(to, platforms.toSet(), from)?.let { buildLink(it, block) }
+ ?: run { context.logger.error("Cannot resolve path for `$to` from `$from`"); block() }
+ }
- override fun buildError(node: ContentNode) = context.logger.error("Unknown ContentNode type: $node")
+ override fun buildError(node: ContentNode) {
+ context.logger.error("Unknown ContentNode type: $node")
+ }
- override fun FlowContent.buildLineBreak() = br()
+ override fun FlowContent.buildLineBreak() {
+ br()
+ }
override fun FlowContent.buildLineBreak(node: ContentBreakLine, pageContext: ContentPage) {
if (node.style.contains(HorizontalBreakLineStyle)) {
hr()
@@ -775,25 +787,28 @@ open class HtmlRenderer(
}
}
- override fun FlowContent.buildLink(address: String, content: FlowContent.() -> Unit) =
+ override fun FlowContent.buildLink(address: String, content: FlowContent.() -> Unit) {
a(href = address, block = content)
+ }
override fun FlowContent.buildDRILink(
node: ContentDRILink,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?
- ) = locationProvider.resolve(node.address, node.sourceSets, pageContext)?.let { address ->
- buildLink(address) {
- buildText(node.children, pageContext, sourceSetRestriction)
- }
- } ?: if (isPartial) {
- templateCommand(ResolveLinkCommand(node.address)) {
- buildText(node.children, pageContext, sourceSetRestriction)
- }
- } else {
- span {
- attributes["data-unresolved-link"] = node.address.toString().htmlEscape()
- buildText(node.children, pageContext, sourceSetRestriction)
+ ) {
+ locationProvider.resolve(node.address, node.sourceSets, pageContext)?.let { address ->
+ buildLink(address) {
+ buildText(node.children, pageContext, sourceSetRestriction)
+ }
+ } ?: if (isPartial) {
+ templateCommand(ResolveLinkCommand(node.address)) {
+ buildText(node.children, pageContext, sourceSetRestriction)
+ }
+ } else {
+ span {
+ attributes["data-unresolved-link"] = node.address.toString().htmlEscape()
+ buildText(node.children, pageContext, sourceSetRestriction)
+ }
}
}
@@ -830,7 +845,9 @@ open class HtmlRenderer(
}
}
- override fun FlowContent.buildText(textNode: ContentText) = buildText(textNode, textNode.style)
+ override fun FlowContent.buildText(textNode: ContentText) {
+ buildText(textNode, textNode.style)
+ }
private fun FlowContent.buildText(textNode: ContentText, unappliedStyles: Set<Style>) {
when {
@@ -891,8 +908,11 @@ open class HtmlRenderer(
else -> null
}
- open fun buildHtml(page: PageNode, resources: List<String>, content: FlowContent.() -> Unit): String =
- templater.renderFromTemplate(DokkaTemplateTypes.BASE) {
+ public open fun buildHtml(
+ page: PageNode,
+ resources: List<String>, content: FlowContent.() -> Unit
+ ): String {
+ return templater.renderFromTemplate(DokkaTemplateTypes.BASE) {
val generatedContent =
createHTML().div("main-content") {
page.getDocumentableType()?.let { attributes["data-page-type"] = it }
@@ -912,12 +932,13 @@ open class HtmlRenderer(
)
}
}
+ }
/**
* This is deliberately left open for plugins that have some other pages above ours and would like to link to them
* instead of ours when clicking the logo
*/
- open fun FlowContent.clickableLogo(page: PageNode, pathToRoot: String) {
+ public open fun FlowContent.clickableLogo(page: PageNode, pathToRoot: String) {
if (context.configuration.delayTemplateSubstitution && page is ContentPage) {
templateCommand(PathToRootSubstitutionCommand(pattern = "###", default = pathToRoot)) {
a {
@@ -978,7 +999,7 @@ private fun TabbedContentType.toHtmlAttribute(): String =
*/
private data class ContentTab(val text: String, val tabbedContentTypes: List<TabbedContentType>)
-fun List<SimpleAttr>.joinAttr() = joinToString(" ") { it.extraKey + "=" + it.extraValue }
+public fun List<SimpleAttr>.joinAttr(): String = joinToString(" ") { it.extraKey + "=" + it.extraValue }
private fun String.stripDiv() = drop(5).dropLast(6) // TODO: Find a way to do it without arbitrary trims
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
index 1c414ad8..fccfd145 100644
--- a/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/NavigationDataProvider.kt
@@ -17,15 +17,15 @@ import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.analysis.kotlin.internal.DocumentableLanguage
import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin
-abstract class NavigationDataProvider(
+public abstract class NavigationDataProvider(
dokkaContext: DokkaContext
) {
private val documentableSourceLanguageParser = dokkaContext.plugin<InternalKotlinAnalysisPlugin>().querySingle { documentableSourceLanguageParser }
- open fun navigableChildren(input: RootPageNode): NavigationNode = input.withDescendants()
+ public open fun navigableChildren(input: RootPageNode): NavigationNode = input.withDescendants()
.first { it is ModulePage || it is MultimoduleRootPage }.let { visit(it as ContentPage) }
- open fun visit(page: ContentPage): NavigationNode =
+ public open fun visit(page: ContentPage): NavigationNode =
NavigationNode(
name = page.displayableName(),
dri = page.dri.first(),
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
index c4d53588..eae43daf 100644
--- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
@@ -16,19 +16,19 @@ import org.jetbrains.dokka.model.WithChildren
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
-class NavigationPage(
- val root: NavigationNode,
- val moduleName: String,
- val context: DokkaContext
+public class NavigationPage(
+ public val root: NavigationNode,
+ public val moduleName: String,
+ public val context: DokkaContext
) : RendererSpecificPage {
- override val name = "navigation"
+ override val name: String = "navigation"
- override val children = emptyList<PageNode>()
+ override val children: List<PageNode> = emptyList()
- override fun modified(name: String, children: List<PageNode>) = this
+ override fun modified(name: String, children: List<PageNode>): NavigationPage = this
- override val strategy = RenderingStrategy<HtmlRenderer> {
+ override val strategy: RenderingStrategy = RenderingStrategy<HtmlRenderer> {
createHTML().visit(root, this)
}
@@ -86,7 +86,7 @@ class NavigationPage(
}
}
-data class NavigationNode(
+public data class NavigationNode(
val name: String,
val dri: DRI,
val sourceSets: Set<DisplaySourceSet>,
@@ -99,7 +99,7 @@ data class NavigationNode(
* [CLASS] represents a neutral (a.k.a Java-style) icon,
* whereas [CLASS_KT] should be Kotlin-styled
*/
-enum class NavigationNodeIcon(
+public enum class NavigationNodeIcon(
private val cssClass: String
) {
CLASS("class"),
@@ -122,8 +122,8 @@ enum class NavigationNodeIcon(
internal fun style(): String = "nav-icon $cssClass"
}
-fun NavigationPage.transform(block: (NavigationNode) -> NavigationNode) =
+public fun NavigationPage.transform(block: (NavigationNode) -> NavigationNode): NavigationPage =
NavigationPage(root.transform(block), moduleName, context)
-fun NavigationNode.transform(block: (NavigationNode) -> NavigationNode) =
+public fun NavigationNode.transform(block: (NavigationNode) -> NavigationNode): NavigationNode =
run(block).let { NavigationNode(it.name, it.dri, it.sourceSets, it.icon, it.styles, it.children.map(block)) }
diff --git a/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt b/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt
index f985e4d0..83d4b24f 100644
--- a/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/SearchbarDataInstaller.kt
@@ -16,19 +16,23 @@ import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.transformers.pages.PageTransformer
-data class SearchRecord(
+public data class SearchRecord(
val name: String,
val description: String? = null,
val location: String,
val searchKeys: List<String> = listOf(name)
) {
- companion object
+ public companion object
}
-open class SearchbarDataInstaller(val context: DokkaContext) : PageTransformer {
- data class DRIWithSourceSets(val dri: DRI, val sourceSet: Set<DisplaySourceSet>)
- data class SignatureWithId(val driWithSourceSets: DRIWithSourceSets, val displayableSignature: String) {
- constructor(dri: DRI, page: ContentPage) : this( DRIWithSourceSets(dri, page.sourceSets()),
+public open class SearchbarDataInstaller(
+ public val context: DokkaContext
+) : PageTransformer {
+
+ public data class DRIWithSourceSets(val dri: DRI, val sourceSet: Set<DisplaySourceSet>)
+
+ public data class SignatureWithId(val driWithSourceSets: DRIWithSourceSets, val displayableSignature: String) {
+ public constructor(dri: DRI, page: ContentPage) : this( DRIWithSourceSets(dri, page.sourceSets()),
getSymbolSignature(page, dri)?.let { flattenToText(it) } ?: page.name)
val id: String
@@ -43,7 +47,10 @@ open class SearchbarDataInstaller(val context: DokkaContext) : PageTransformer {
private val mapper = jacksonObjectMapper()
- open fun generatePagesList(pages: List<SignatureWithId>, locationResolver: DriResolver): List<SearchRecord> =
+ public open fun generatePagesList(
+ pages: List<SignatureWithId>,
+ locationResolver: DriResolver
+ ): List<SearchRecord> =
pages.map { pageWithId ->
createSearchRecord(
name = pageWithId.displayableSignature,
@@ -57,7 +64,7 @@ open class SearchbarDataInstaller(val context: DokkaContext) : PageTransformer {
)
}.sortedWith(compareBy({ it.name }, { it.description }))
- open fun createSearchRecord(
+ public open fun createSearchRecord(
name: String,
description: String?,
location: String,
@@ -65,7 +72,7 @@ open class SearchbarDataInstaller(val context: DokkaContext) : PageTransformer {
): SearchRecord =
SearchRecord(name, description, location, searchKeys)
- open fun processPage(page: PageNode): List<SignatureWithId> =
+ public open fun processPage(page: PageNode): List<SignatureWithId> =
when (page) {
is ContentPage -> page.takeIf { page !is ModulePageNode && page !is PackagePageNode }?.dri
?.map { dri -> SignatureWithId(dri, page) }.orEmpty()
diff --git a/plugins/base/src/main/kotlin/renderers/html/Tags.kt b/plugins/base/src/main/kotlin/renderers/html/Tags.kt
index 7d135c95..7d6fc390 100644
--- a/plugins/base/src/main/kotlin/renderers/html/Tags.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/Tags.kt
@@ -10,14 +10,14 @@ import org.jetbrains.dokka.base.renderers.html.command.consumers.ImmediateResolu
import org.jetbrains.dokka.base.templating.Command
import org.jetbrains.dokka.base.templating.toJsonString
-typealias TemplateBlock = TemplateCommand.() -> Unit
+public typealias TemplateBlock = TemplateCommand.() -> Unit
@HtmlTagMarker
-fun FlowOrPhrasingContent.wbr(classes: String? = null, block: WBR.() -> Unit = {}): Unit =
+public 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>, consumer: TagConsumer<*>) :
+public open class WBR(initialAttributes: Map<String, String>, consumer: TagConsumer<*>) :
HTMLTag("wbr", consumer, initialAttributes, namespace = null, inlineTag = true, emptyTag = false),
HtmlBlockInlineTag
@@ -25,22 +25,22 @@ open class WBR(initialAttributes: Map<String, String>, consumer: TagConsumer<*>)
* Work-around until next version of kotlinx.html doesn't come out
*/
@HtmlTagMarker
-inline fun FlowOrPhrasingContent.strike(classes : String? = null, crossinline block : STRIKE.() -> Unit = {}) : Unit = STRIKE(attributesMapOf("class", classes), consumer).visit(block)
+public inline fun FlowOrPhrasingContent.strike(classes : String? = null, crossinline block : STRIKE.() -> Unit = {}) : Unit = STRIKE(attributesMapOf("class", classes), consumer).visit(block)
-open class STRIKE(initialAttributes: Map<String, String>, override val consumer: TagConsumer<*>) :
+public open class STRIKE(initialAttributes: Map<String, String>, override val consumer: TagConsumer<*>) :
HTMLTag("strike", consumer, initialAttributes, null, false, false), HtmlBlockInlineTag
@HtmlTagMarker
-inline fun FlowOrPhrasingContent.underline(classes : String? = null, crossinline block : UNDERLINE.() -> Unit = {}) : Unit = UNDERLINE(attributesMapOf("class", classes), consumer).visit(block)
+public inline fun FlowOrPhrasingContent.underline(classes : String? = null, crossinline block : UNDERLINE.() -> Unit = {}) : Unit = UNDERLINE(attributesMapOf("class", classes), consumer).visit(block)
-open class UNDERLINE(initialAttributes: Map<String, String>, override val consumer: TagConsumer<*>) :
+public open class UNDERLINE(initialAttributes: Map<String, String>, override val consumer: TagConsumer<*>) :
HTMLTag("u", consumer, initialAttributes, null, false, false), HtmlBlockInlineTag
-const val TEMPLATE_COMMAND_SEPARATOR = ":"
-const val TEMPLATE_COMMAND_BEGIN_BORDER = "[+]cmd"
-const val TEMPLATE_COMMAND_END_BORDER = "[-]cmd"
+public const val TEMPLATE_COMMAND_SEPARATOR: String = ":"
+public const val TEMPLATE_COMMAND_BEGIN_BORDER: String = "[+]cmd"
+public const val TEMPLATE_COMMAND_END_BORDER: String = "[-]cmd"
-fun FlowOrMetaDataContent.templateCommandAsHtmlComment(data: Command, block: FlowOrMetaDataContent.() -> Unit = {}): Unit =
+public fun FlowOrMetaDataContent.templateCommandAsHtmlComment(data: Command, block: FlowOrMetaDataContent.() -> Unit = {}): Unit =
(consumer as? ImmediateResolutionTagConsumer)?.processCommand(data, block)
?: let{
comment( "$TEMPLATE_COMMAND_BEGIN_BORDER$TEMPLATE_COMMAND_SEPARATOR${toJsonString(data)}")
@@ -48,24 +48,24 @@ fun FlowOrMetaDataContent.templateCommandAsHtmlComment(data: Command, block: Flo
comment(TEMPLATE_COMMAND_END_BORDER)
}
-fun <T: Appendable> T.templateCommandAsHtmlComment(command: Command, action: T.() -> Unit ) {
+public fun <T: Appendable> T.templateCommandAsHtmlComment(command: Command, action: T.() -> Unit ) {
append("<!--$TEMPLATE_COMMAND_BEGIN_BORDER$TEMPLATE_COMMAND_SEPARATOR${toJsonString(command)}-->")
action()
append("<!--$TEMPLATE_COMMAND_END_BORDER-->")
}
-fun FlowOrMetaDataContent.templateCommand(data: Command, block: TemplateBlock = {}): Unit =
+public fun FlowOrMetaDataContent.templateCommand(data: Command, block: TemplateBlock = {}): Unit =
(consumer as? ImmediateResolutionTagConsumer)?.processCommand(data, block)
?: TemplateCommand(attributesMapOf("data", toJsonString(data)), consumer).visit(block)
-fun <T> TagConsumer<T>.templateCommand(data: Command, block: TemplateBlock = {}): T =
+public fun <T> TagConsumer<T>.templateCommand(data: Command, block: TemplateBlock = {}): T =
(this as? ImmediateResolutionTagConsumer)?.processCommandAndFinalize(data, block)
?: TemplateCommand(attributesMapOf("data", toJsonString(data)), this).visitAndFinalize(this, block)
-fun templateCommandFor(data: Command, consumer: TagConsumer<*>) =
+public fun templateCommandFor(data: Command, consumer: TagConsumer<*>): TemplateCommand =
TemplateCommand(attributesMapOf("data", toJsonString(data)), consumer)
-class TemplateCommand(initialAttributes: Map<String, String>, consumer: TagConsumer<*>) :
+public class TemplateCommand(initialAttributes: Map<String, String>, consumer: TagConsumer<*>) :
HTMLTag(
"dokka-template-command",
consumer,
@@ -77,6 +77,6 @@ class TemplateCommand(initialAttributes: Map<String, String>, consumer: TagConsu
CommonAttributeGroupFacadeFlowInteractivePhrasingContent
// This hack is outrageous. I hate it but I cannot find any other way around `kotlinx.html` type system.
-fun TemplateBlock.buildAsInnerHtml(): String = createHTML(prettyPrint = false).run {
+public fun TemplateBlock.buildAsInnerHtml(): String = createHTML(prettyPrint = false).run {
TemplateCommand(emptyMap, this).visitAndFinalize(this, this@buildAsInnerHtml).substringAfter(">").substringBeforeLast("<")
}
diff --git a/plugins/base/src/main/kotlin/renderers/html/command/consumers/ImmediateResolutionTagConsumer.kt b/plugins/base/src/main/kotlin/renderers/html/command/consumers/ImmediateResolutionTagConsumer.kt
index 78d684fa..9cde1fca 100644
--- a/plugins/base/src/main/kotlin/renderers/html/command/consumers/ImmediateResolutionTagConsumer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/command/consumers/ImmediateResolutionTagConsumer.kt
@@ -15,21 +15,23 @@ import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.query
-class ImmediateResolutionTagConsumer<out R>(
+public class ImmediateResolutionTagConsumer<out R>(
private val downstream: TagConsumer<R>,
private val context: DokkaContext
): TagConsumer<R> by downstream {
- fun processCommand(command: Command, block: TemplateBlock) {
+
+ public fun processCommand(command: Command, block: TemplateBlock) {
context.plugin<DokkaBase>().query { immediateHtmlCommandConsumer }
.find { it.canProcess(command) }
?.processCommand(command, block, this)
?: run { templateCommandFor(command, downstream).visit(block) }
}
- fun processCommandAndFinalize(command: Command, block: TemplateBlock): R =
- context.plugin<DokkaBase>().query { immediateHtmlCommandConsumer }
+ public fun processCommandAndFinalize(command: Command, block: TemplateBlock): R {
+ return context.plugin<DokkaBase>().query { immediateHtmlCommandConsumer }
.find { it.canProcess(command) }
?.processCommandAndFinalize(command, block, this)
?: downstream.templateCommand(command, block)
+ }
}
diff --git a/plugins/base/src/main/kotlin/renderers/html/command/consumers/PathToRootConsumer.kt b/plugins/base/src/main/kotlin/renderers/html/command/consumers/PathToRootConsumer.kt
index a05d7f42..9ac6eb91 100644
--- a/plugins/base/src/main/kotlin/renderers/html/command/consumers/PathToRootConsumer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/command/consumers/PathToRootConsumer.kt
@@ -10,8 +10,8 @@ import org.jetbrains.dokka.base.templating.Command
import org.jetbrains.dokka.base.templating.ImmediateHtmlCommandConsumer
import org.jetbrains.dokka.base.templating.PathToRootSubstitutionCommand
-object PathToRootConsumer: ImmediateHtmlCommandConsumer {
- override fun canProcess(command: Command) = command is PathToRootSubstitutionCommand
+public object PathToRootConsumer: ImmediateHtmlCommandConsumer {
+ override fun canProcess(command: Command): Boolean = command is PathToRootSubstitutionCommand
override fun <R> processCommand(command: Command, block: TemplateBlock, tagConsumer: ImmediateResolutionTagConsumer<R>) {
command as PathToRootSubstitutionCommand
diff --git a/plugins/base/src/main/kotlin/renderers/html/command/consumers/ReplaceVersionsConsumer.kt b/plugins/base/src/main/kotlin/renderers/html/command/consumers/ReplaceVersionsConsumer.kt
index bec33799..dd95c202 100644
--- a/plugins/base/src/main/kotlin/renderers/html/command/consumers/ReplaceVersionsConsumer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/command/consumers/ReplaceVersionsConsumer.kt
@@ -10,8 +10,8 @@ import org.jetbrains.dokka.base.templating.ImmediateHtmlCommandConsumer
import org.jetbrains.dokka.base.templating.ReplaceVersionsCommand
import org.jetbrains.dokka.plugability.DokkaContext
-class ReplaceVersionsConsumer(private val context: DokkaContext) : ImmediateHtmlCommandConsumer {
- override fun canProcess(command: Command) = command is ReplaceVersionsCommand
+public class ReplaceVersionsConsumer(private val context: DokkaContext) : ImmediateHtmlCommandConsumer {
+ override fun canProcess(command: Command): Boolean = command is ReplaceVersionsCommand
override fun <R> processCommand(
command: Command,
diff --git a/plugins/base/src/main/kotlin/renderers/html/command/consumers/ResolveLinkConsumer.kt b/plugins/base/src/main/kotlin/renderers/html/command/consumers/ResolveLinkConsumer.kt
index 25f079d0..292e88b0 100644
--- a/plugins/base/src/main/kotlin/renderers/html/command/consumers/ResolveLinkConsumer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/command/consumers/ResolveLinkConsumer.kt
@@ -15,8 +15,8 @@ import org.jetbrains.dokka.base.templating.ImmediateHtmlCommandConsumer
import org.jetbrains.dokka.base.templating.ResolveLinkCommand
import org.jetbrains.dokka.utilities.htmlEscape
-object ResolveLinkConsumer: ImmediateHtmlCommandConsumer {
- override fun canProcess(command: Command) = command is ResolveLinkCommand
+public object ResolveLinkConsumer: ImmediateHtmlCommandConsumer {
+ override fun canProcess(command: Command): Boolean = command is ResolveLinkCommand
override fun <R> processCommand(command: Command, block: TemplateBlock, tagConsumer: ImmediateResolutionTagConsumer<R>) {
command as ResolveLinkCommand
diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt
index 1754ea32..b6ce4147 100644
--- a/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/htmlFormatingUtils.kt
@@ -7,7 +7,7 @@ package org.jetbrains.dokka.base.renderers.html
import kotlinx.html.FlowContent
import kotlinx.html.span
-fun FlowContent.buildTextBreakableAfterCapitalLetters(name: String, hasLastElement: Boolean = false) {
+public fun FlowContent.buildTextBreakableAfterCapitalLetters(name: String, hasLastElement: Boolean = false) {
if (name.contains(" ")) {
val withOutSpaces = name.split(" ")
withOutSpaces.dropLast(1).forEach {
@@ -23,7 +23,7 @@ fun FlowContent.buildTextBreakableAfterCapitalLetters(name: String, hasLastEleme
}
}
-fun FlowContent.buildBreakableDotSeparatedHtml(name: String) {
+public fun FlowContent.buildBreakableDotSeparatedHtml(name: String) {
val phrases = name.split(".")
phrases.forEachIndexed { i, e ->
val elementWithOptionalDot = e.takeIf { i == phrases.lastIndex } ?: "$e."
@@ -61,6 +61,7 @@ private fun FlowContent.buildBreakableHtmlElement(element: String, last: Boolean
}
}
-fun FlowContent.buildBreakableText(name: String) =
+public fun FlowContent.buildBreakableText(name: String) {
if (name.contains(".")) buildBreakableDotSeparatedHtml(name)
else buildTextBreakableAfterCapitalLetters(name, hasLastElement = true)
+}
diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
index 349fa1a0..dc877605 100644
--- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
@@ -15,7 +15,9 @@ import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.configuration
import org.jetbrains.dokka.transformers.pages.PageTransformer
-open class NavigationPageInstaller(val context: DokkaContext) : NavigationDataProvider(context), PageTransformer {
+public open class NavigationPageInstaller(
+ public val context: DokkaContext
+) : NavigationDataProvider(context), PageTransformer {
override fun invoke(input: RootPageNode): RootPageNode =
input.modified(
children = input.children + NavigationPage(
@@ -26,7 +28,9 @@ open class NavigationPageInstaller(val context: DokkaContext) : NavigationDataPr
)
}
-class CustomResourceInstaller(val dokkaContext: DokkaContext) : PageTransformer {
+public class CustomResourceInstaller(
+ public val dokkaContext: DokkaContext
+) : PageTransformer {
private val configuration = configuration<DokkaBase, DokkaBaseConfiguration>(dokkaContext)
private val customAssets = configuration?.customAssets?.map {
@@ -48,7 +52,7 @@ class CustomResourceInstaller(val dokkaContext: DokkaContext) : PageTransformer
}
}
-class ScriptsInstaller(private val dokkaContext: DokkaContext) : PageTransformer {
+public class ScriptsInstaller(private val dokkaContext: DokkaContext) : PageTransformer {
// scripts ending with `_deferred.js` are loaded with `defer`, otherwise `async`
private val scriptsPages = listOf(
@@ -76,7 +80,7 @@ class ScriptsInstaller(private val dokkaContext: DokkaContext) : PageTransformer
}
}
-class StylesInstaller(private val dokkaContext: DokkaContext) : PageTransformer {
+public class StylesInstaller(private val dokkaContext: DokkaContext) : PageTransformer {
private val stylesPages = listOf(
"styles/style.css",
"styles/main.css",
@@ -96,7 +100,7 @@ class StylesInstaller(private val dokkaContext: DokkaContext) : PageTransformer
}
}
-object AssetsInstaller : PageTransformer {
+public object AssetsInstaller : PageTransformer {
private val imagesPages = listOf(
"images/arrow_down.svg",
"images/logo-icon.svg",
@@ -127,7 +131,7 @@ object AssetsInstaller : PageTransformer {
"images/nav-icons/typealias-kotlin.svg",
)
- override fun invoke(input: RootPageNode) = input.modified(
+ override fun invoke(input: RootPageNode): RootPageNode = input.modified(
children = input.children + imagesPages.toRenderSpecificResourcePage()
)
}
@@ -135,7 +139,9 @@ object AssetsInstaller : PageTransformer {
private fun List<String>.toRenderSpecificResourcePage(): List<RendererSpecificResourcePage> =
map { RendererSpecificResourcePage(it, emptyList(), RenderingStrategy.Copy("/dokka/$it")) }
-class SourcesetDependencyAppender(val context: DokkaContext) : PageTransformer {
+public class SourcesetDependencyAppender(
+ public val context: DokkaContext
+) : PageTransformer {
private val name = "scripts/sourceset_dependencies.js"
override fun invoke(input: RootPageNode): RootPageNode {
val dependenciesMap = context.configuration.sourceSets.associate {
diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt
index 8402d236..3883bc4a 100644
--- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt
@@ -30,7 +30,9 @@ import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.configuration
import java.net.URI
-class DefaultTemplateModelFactory(val context: DokkaContext) : TemplateModelFactory {
+public class DefaultTemplateModelFactory(
+ public val context: DokkaContext
+) : TemplateModelFactory {
private val configuration = configuration<DokkaBase, DokkaBaseConfiguration>(context)
private val isPartial = context.configuration.delayTemplateSubstitution
@@ -38,7 +40,7 @@ class DefaultTemplateModelFactory(val context: DokkaContext) : TemplateModelFact
if (context.configuration.delayTemplateSubstitution || this is ImmediateResolutionTagConsumer) this
else ImmediateResolutionTagConsumer(this, context)
- data class SourceSetModel(val name: String, val platform: String, val filter: String)
+ public data class SourceSetModel(val name: String, val platform: String, val filter: String)
override fun buildModel(
page: PageNode,
diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelMerger.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelMerger.kt
index 4f4f4f78..2f17183d 100644
--- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelMerger.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelMerger.kt
@@ -4,7 +4,7 @@
package org.jetbrains.dokka.base.renderers.html.innerTemplating
-class DefaultTemplateModelMerger : TemplateModelMerger {
+public class DefaultTemplateModelMerger : TemplateModelMerger {
override fun invoke(
factories: List<TemplateModelFactory>,
buildModel: TemplateModelFactory.() -> TemplateMap
diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/HtmlTemplater.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/HtmlTemplater.kt
index cfd6b2c7..1638c9c0 100644
--- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/HtmlTemplater.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/HtmlTemplater.kt
@@ -17,13 +17,15 @@ import org.jetbrains.dokka.plugability.configuration
import java.io.StringWriter
-enum class DokkaTemplateTypes(val path: String) {
+public enum class DokkaTemplateTypes(
+ public val path: String
+) {
BASE("base.ftl")
}
-typealias TemplateMap = Map<String, Any?>
+public typealias TemplateMap = Map<String, Any?>
-class HtmlTemplater(
+public class HtmlTemplater(
context: DokkaContext
) {
@@ -60,11 +62,11 @@ class HtmlTemplater(
templateUpdateDelayMilliseconds = Long.MAX_VALUE
}
- fun setupSharedModel(model: TemplateMap) {
+ public fun setupSharedModel(model: TemplateMap) {
templaterConfiguration.setSharedVariables(model)
}
- fun renderFromTemplate(
+ public fun renderFromTemplate(
templateType: DokkaTemplateTypes,
generateModel: () -> TemplateMap
): String {
diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt
index a669ee4d..3af11bf9 100644
--- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt
@@ -7,13 +7,13 @@ package org.jetbrains.dokka.base.renderers.html.innerTemplating
import org.jetbrains.dokka.base.resolvers.local.LocationProvider
import org.jetbrains.dokka.pages.PageNode
-interface TemplateModelFactory {
- fun buildModel(
+public interface TemplateModelFactory {
+ public fun buildModel(
page: PageNode,
resources: List<String>,
locationProvider: LocationProvider,
content: String
): TemplateMap
- fun buildSharedModel(): TemplateMap
+ public fun buildSharedModel(): TemplateMap
}
diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelMerger.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelMerger.kt
index a28aca77..ada0c6cd 100644
--- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelMerger.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelMerger.kt
@@ -4,6 +4,6 @@
package org.jetbrains.dokka.base.renderers.html.innerTemplating
-fun interface TemplateModelMerger {
- fun invoke(factories: List<TemplateModelFactory>, buildModel: TemplateModelFactory.() -> TemplateMap): TemplateMap
+public fun interface TemplateModelMerger {
+ public fun invoke(factories: List<TemplateModelFactory>, buildModel: TemplateModelFactory.() -> TemplateMap): TemplateMap
}