aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2020-10-07 14:40:09 +0200
committerKamil Doległo <9080183+kamildoleglo@users.noreply.github.com>2020-10-08 19:05:41 +0200
commit0d2ee179b6563020874db9f60906fb16b6ae1556 (patch)
treed55f43d48eea5966d312a8fe169cf1b493ce927d /plugins/base/src/main/kotlin
parent4331d1b816c30731842ab36827bbc1a4a9b292b3 (diff)
downloaddokka-0d2ee179b6563020874db9f60906fb16b6ae1556.tar.gz
dokka-0d2ee179b6563020874db9f60906fb16b6ae1556.tar.bz2
dokka-0d2ee179b6563020874db9f60906fb16b6ae1556.zip
Add information about content kind and sourceset to anchor
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r--plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt2
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt4
-rw-r--r--plugins/base/src/main/kotlin/resolvers/anchors/AnchorsHint.kt14
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt2
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt2
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt6
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt4
7 files changed, 18 insertions, 16 deletions
diff --git a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt
index 5ae8f04a..80a06a89 100644
--- a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt
+++ b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt
@@ -48,7 +48,7 @@ class MultimodulePageCreator(
val displayedModuleDocumentation = getDisplayedModuleDocumentation(module)
val dri = DRI(packageName = MULTIMODULE_PACKAGE_PLACEHOLDER, classNames = module.name)
val dci = DCI(setOf(dri), ContentKind.Comment)
- val extraWithAnchor = PropertyContainer.withAll(SymbolAnchorHint(module.name))
+ val extraWithAnchor = PropertyContainer.withAll(SymbolAnchorHint(module.name, ContentKind.Main))
val header = linkNode(module.name, dri, DCI(setOf(dri), ContentKind.Main), extra = extraWithAnchor)
val content = ContentGroup(
children =
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index ef5d78b6..07cba90c 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -844,7 +844,7 @@ val ContentNode.isAnchorable: Boolean
get() = anchorLabel != null
val ContentNode.anchorLabel: String?
- get() = extra[SymbolAnchorHint.SymbolAnchorHintKey]?.anchorName
+ get() = extra[SymbolAnchorHint]?.anchorName
val ContentNode.anchor: String
- get() = dci.dri.first().toString().urlEncoded()
+ get() = (dci.dri.first().toString() + "/" + extra[SymbolAnchorHint]?.contentKind + "/" + sourceSets.joinToString { it.sourceSetIDs.all.joinToString() }).urlEncoded()
diff --git a/plugins/base/src/main/kotlin/resolvers/anchors/AnchorsHint.kt b/plugins/base/src/main/kotlin/resolvers/anchors/AnchorsHint.kt
index 0b68db10..8f633b70 100644
--- a/plugins/base/src/main/kotlin/resolvers/anchors/AnchorsHint.kt
+++ b/plugins/base/src/main/kotlin/resolvers/anchors/AnchorsHint.kt
@@ -3,11 +3,13 @@ package org.jetbrains.dokka.base.resolvers.anchors
import org.jetbrains.dokka.model.Documentable
import org.jetbrains.dokka.model.properties.ExtraProperty
import org.jetbrains.dokka.pages.ContentNode
+import org.jetbrains.dokka.pages.Kind
-data class SymbolAnchorHint(val anchorName: String): ExtraProperty<ContentNode> {
- object SymbolAnchorHintKey : ExtraProperty.Key<ContentNode, SymbolAnchorHint>
- override val key: ExtraProperty.Key<ContentNode, SymbolAnchorHint> = SymbolAnchorHintKey
- companion object: ExtraProperty.Key<ContentNode, SymbolAnchorHint> {
- fun from(d: Documentable): SymbolAnchorHint? = d.name?.let { SymbolAnchorHint(it) }
+data class SymbolAnchorHint(val anchorName: String, val contentKind: Kind) : ExtraProperty<ContentNode> {
+ override val key: ExtraProperty.Key<ContentNode, SymbolAnchorHint> = SymbolAnchorHint
+
+ companion object : ExtraProperty.Key<ContentNode, SymbolAnchorHint> {
+ fun from(d: Documentable, contentKind: Kind): SymbolAnchorHint? =
+ d.name?.let { SymbolAnchorHint(it, contentKind) }
}
-} \ No newline at end of file
+}
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
index a89aed9a..fe8c8f84 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt
@@ -44,7 +44,7 @@ open class DokkaLocationProvider(
pageGraphRoot.withDescendants().filterIsInstance<ContentPage>()
.flatMap { page ->
page.content.withDescendants()
- .filter { it.extra[SymbolAnchorHint.SymbolAnchorHintKey] != null }
+ .filter { it.extra[SymbolAnchorHint] != null }
.mapNotNull { it.dci.dri.singleOrNull() }
.distinct()
.flatMap { dri ->
diff --git a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
index 8e1e99f2..069d1125 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
@@ -64,7 +64,7 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent
+ContentTable(
emptyList(),
sources.map {
- buildGroup(node.dri, setOf(it.first), kind = ContentKind.Source, extra = mainExtra + SymbolAnchorHint(it.second)) {
+ buildGroup(node.dri, setOf(it.first), kind = ContentKind.Source, extra = mainExtra + SymbolAnchorHint(it.second, ContentKind.Source)) {
link("(source)", it.second)
}
},
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index caeb6bcb..6c1b5ea4 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -186,7 +186,7 @@ open class DefaultPageCreator(
.groupBy({ it.second }, { it.first }).map { (classlike, platforms) ->
val label = classlike.classNames?.substringBeforeLast(".") ?: classlike.toString()
.also { logger.warn("No class name found for DRI $classlike") }
- buildGroup(setOf(dri), platforms.toSet(), ContentKind.Inheritors, extra = mainExtra + SymbolAnchorHint(label)) {
+ buildGroup(setOf(classlike), platforms.toSet(), ContentKind.Inheritors, extra = mainExtra + SymbolAnchorHint(label, ContentKind.Inheritors)) {
link(label, classlike)
}
},
@@ -530,7 +530,7 @@ open class DefaultPageCreator(
sourceSets = elements.flatMap { it.sourceSets }.toSet(),
kind = kind,
styles = emptySet(),
- extra = elementName?.let { name -> extra + SymbolAnchorHint(name) } ?: extra
+ extra = elementName?.let { name -> extra + SymbolAnchorHint(name, kind) } ?: extra
) {
link(elementName.orEmpty(), elements.first().dri, kind = kind)
divergentGroup(
@@ -540,7 +540,7 @@ open class DefaultPageCreator(
extra = extra
) {
elements.map {
- instance(setOf(it.dri), it.sourceSets.toSet(), extra = PropertyContainer.withAll(SymbolAnchorHint(it.name ?: ""))) {
+ instance(setOf(it.dri), it.sourceSets.toSet(), extra = PropertyContainer.withAll(SymbolAnchorHint(it.name ?: "", kind))) {
divergent {
group {
+buildSignature(it)
diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
index c67fe4b0..1865f276 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
@@ -115,7 +115,7 @@ open class PageContentBuilder(
sourceSets,
kind,
styles,
- extra + SymbolAnchorHint(text.replace("\\s".toRegex(), "").toLowerCase())
+ extra + SymbolAnchorHint(text.replace("\\s".toRegex(), "").toLowerCase(), kind)
) {
text(text, kind = kind)
block()
@@ -185,7 +185,7 @@ open class PageContentBuilder(
else it
}
.map {
- val newExtra = if (needsAnchors) extra + SymbolAnchorHint.from(it) else extra
+ val newExtra = if (needsAnchors) extra + SymbolAnchorHint.from(it, kind) else extra
buildGroup(setOf(it.dri), it.sourceSets.toSet(), kind, styles, newExtra) {
operation(it)
}