aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2020-10-09 14:38:13 +0200
committerGitHub <noreply@github.com>2020-10-09 14:38:13 +0200
commit3a5dfac12cf61d82b244026990b4d0f86d3b24b9 (patch)
tree13dda105ec0986278097519db0b102d2ea914cb6 /plugins/base/src/main
parentabe5113df0aeece35fc959e6b3b15ee125fe101c (diff)
downloaddokka-3a5dfac12cf61d82b244026990b4d0f86d3b24b9.tar.gz
dokka-3a5dfac12cf61d82b244026990b4d0f86d3b24b9.tar.bz2
dokka-3a5dfac12cf61d82b244026990b4d0f86d3b24b9.zip
On this page component (#1504)
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt32
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt2
-rw-r--r--plugins/base/src/main/resources/dokka/scripts/navigation-loader.js2
-rw-r--r--plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js7
4 files changed, 28 insertions, 15 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 07cba90c..8f6129a6 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -13,6 +13,7 @@ import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint
import org.jetbrains.dokka.base.transformers.pages.sourcelinks.hasTabbedContent
import org.jetbrains.dokka.base.renderers.isImage
import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.model.CompositeSourceSetID
import org.jetbrains.dokka.model.DisplaySourceSet
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.model.sourceSetIDs
@@ -105,7 +106,7 @@ open class HtmlRenderer(
}
node.hasStyle(TextStyle.Paragraph) -> p(additionalClasses) { childrenCallback() }
node.hasStyle(TextStyle.Block) -> div(additionalClasses) { childrenCallback() }
- node.isAnchorable -> buildAnchor(node.anchor, node.anchorLabel!!) { childrenCallback() }
+ node.isAnchorable -> buildAnchor(node.anchor!!, node.anchorLabel!!, node.sourceSetsFilters) { childrenCallback() }
else -> childrenCallback()
}
}
@@ -379,7 +380,7 @@ open class HtmlRenderer(
sourceSetRestriction: Set<DisplaySourceSet>?,
style: Set<Style>
) {
- anchorFromNode(contextNode)
+ buildAnchor(contextNode)
div(classes = "table-row") {
div("main-subrow " + contextNode.style.joinToString(separator = " ")) {
buildRowHeaderLink(toRender, pageContext, sourceSetRestriction, contextNode.anchor, "w-100")
@@ -397,7 +398,7 @@ open class HtmlRenderer(
sourceSetRestriction: Set<DisplaySourceSet>?,
style: Set<Style>
) {
- anchorFromNode(contextNode)
+ buildAnchor(contextNode)
div(classes = "table-row") {
addSourceSetFilteringAttributes(contextNode)
div {
@@ -423,7 +424,7 @@ open class HtmlRenderer(
sourceSetRestriction: Set<DisplaySourceSet>?,
style: Set<Style>
) {
- anchorFromNode(contextNode)
+ buildAnchor(contextNode)
div(classes = "table-row") {
addSourceSetFilteringAttributes(contextNode)
div("main-subrow keyValue " + contextNode.style.joinToString(separator = " ")) {
@@ -449,7 +450,7 @@ open class HtmlRenderer(
toRender: List<ContentNode>,
pageContext: ContentPage,
sourceSetRestriction: Set<DisplaySourceSet>?,
- anchorDestination: String,
+ anchorDestination: String?,
classes: String = ""
) {
toRender.filter { it is ContentLink || it.hasStyle(ContentStyle.RowTitle) }.takeIf { it.isNotEmpty() }?.let {
@@ -458,7 +459,7 @@ open class HtmlRenderer(
.forEach {
span("inline-flex") {
it.build(this, pageContext, sourceSetRestriction)
- if(it is ContentLink) buildAnchorCopyButton(anchorDestination)
+ if(it is ContentLink && !anchorDestination.isNullOrBlank()) buildAnchorCopyButton(anchorDestination)
}
}
}
@@ -581,19 +582,21 @@ open class HtmlRenderer(
}
}
- private fun FlowContent.buildAnchor(anchor: String, anchorLabel: String, content: FlowContent.() -> Unit) {
+ private fun FlowContent.buildAnchor(anchor: String, anchorLabel: String, sourceSets: String, content: FlowContent.() -> Unit) {
a {
attributes["data-name"] = anchor
attributes["anchor-label"] = anchorLabel
+ attributes["id"] = anchor
+ attributes["data-filterable-set"] = sourceSets
}
content()
}
- private fun FlowContent.buildAnchor(anchor: String, anchorLabel: String) =
- buildAnchor(anchor, anchorLabel) {}
+ private fun FlowContent.buildAnchor(anchor: String, anchorLabel: String, sourceSets: String) =
+ buildAnchor(anchor, anchorLabel, sourceSets) {}
- private fun FlowContent.anchorFromNode(node: ContentNode) {
- node.anchorLabel?.let { label -> buildAnchor(node.anchor, label) }
+ private fun FlowContent.buildAnchor(node: ContentNode) {
+ node.anchorLabel?.let { label -> buildAnchor(node.anchor!!, label, node.sourceSetsFilters) }
}
@@ -846,5 +849,8 @@ val ContentNode.isAnchorable: Boolean
val ContentNode.anchorLabel: String?
get() = extra[SymbolAnchorHint]?.anchorName
-val ContentNode.anchor: String
- get() = (dci.dri.first().toString() + "/" + extra[SymbolAnchorHint]?.contentKind + "/" + sourceSets.joinToString { it.sourceSetIDs.all.joinToString() }).urlEncoded()
+val ContentNode.anchor: String?
+ get() = extra[SymbolAnchorHint]?.contentKind?.let { contentKind -> (dci.dri.first().toString() + "/" + contentKind + "/" + sourceSets.joinToString { it.sourceSetIDs.all.joinToString() }).urlEncoded() }
+
+val ContentNode.sourceSetsFilters: String
+ get() = sourceSets.sourceSetIDs.joinToString(" ") { it.toString() }
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index 6c3c0330..4582fd67 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -544,7 +544,7 @@ open class DefaultPageCreator(
) {
elements.map {
instance(setOf(it.dri), it.sourceSets.toSet(), extra = PropertyContainer.withAll(SymbolAnchorHint(it.name ?: "", kind))) {
- divergent {
+ divergent(extra = PropertyContainer.empty()) {
group {
+buildSignature(it)
}
diff --git a/plugins/base/src/main/resources/dokka/scripts/navigation-loader.js b/plugins/base/src/main/resources/dokka/scripts/navigation-loader.js
index c2f60ec5..0d9948ad 100644
--- a/plugins/base/src/main/resources/dokka/scripts/navigation-loader.js
+++ b/plugins/base/src/main/resources/dokka/scripts/navigation-loader.js
@@ -16,7 +16,7 @@ window.addEventListener('load', () => {
})
/* Smooth scrolling support for going to the top of the page */
- document.querySelectorAll('a[href^="#"]').forEach(anchor => {
+ document.querySelectorAll('.footer a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
diff --git a/plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js b/plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js
index 022aca4f..26dd9424 100644
--- a/plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js
+++ b/plugins/base/src/main/resources/dokka/scripts/platform-content-handler.js
@@ -114,6 +114,10 @@ function initializeFiltering() {
let cached = window.localStorage.getItem('inactive-filters')
if (cached) {
let parsed = JSON.parse(cached)
+ //Events are used by react to get values in 'on this page'
+ const event = new CustomEvent('sourceset-filter-change', { detail: parsed });
+ window.dispatchEvent(event);
+
filteringContext.activeFilters = filteringContext.restrictedDependencies
.filter(q => parsed.indexOf(q) == -1 )
} else {
@@ -215,6 +219,9 @@ function refreshFiltering() {
elem.setAttribute("data-filterable-current", platformList.join(' '))
}
)
+ const event = new CustomEvent('sourceset-filter-change', { detail: sourcesetList });
+ window.dispatchEvent(event);
+
refreshFilterButtons()
refreshPlatformTabs()
}