aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt10
-rw-r--r--core/src/test/kotlin/TestAPI.kt20
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt27
-rw-r--r--core/testdata/format/notPublishedTypeAliasAutoExpansion.kt13
-rw-r--r--core/testdata/format/notPublishedTypeAliasAutoExpansion.md9
5 files changed, 71 insertions, 8 deletions
diff --git a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
index 24f50dac..ffef399d 100644
--- a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
+++ b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
@@ -4,7 +4,10 @@ import com.google.inject.Inject
import org.jetbrains.dokka.Model.DescriptorSignatureProvider
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
+import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink
+import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyPrivateApi
+import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyPublicApi
class DeclarationLinkResolver
@Inject constructor(val resolutionFacade: DokkaResolutionFacade,
@@ -32,13 +35,13 @@ class DeclarationLinkResolver
return ContentExternalLink(externalHref)
}
val signature = descriptorSignatureProvider.signature(symbol)
- val referencedAt = fromDescriptor.sourceLocation()?.let { ", referenced at $it" }.orEmpty()
+ val referencedAt = fromDescriptor.signatureWithSourceLocation()
return ContentNodeLazyLink(href, { ->
val target = refGraph.lookup(signature)
if (target == null) {
- logger.warn("Can't find node by signature $signature$referencedAt")
+ logger.warn("Can't find node by signature $signature, referenced at $referencedAt")
}
target
})
@@ -63,6 +66,9 @@ class DeclarationLinkResolver
if (symbol is CallableMemberDescriptor && symbol.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
return symbol.overriddenDescriptors.firstOrNull()
}
+ if (symbol is TypeAliasDescriptor && !symbol.isDocumented(options)) {
+ return symbol.classDescriptor
+ }
return symbol
}
diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt
index a1a98ec7..6c62c998 100644
--- a/core/src/test/kotlin/TestAPI.kt
+++ b/core/src/test/kotlin/TestAPI.kt
@@ -151,8 +151,15 @@ fun verifyOutput(roots: Array<ContentRoot>,
withJdk: Boolean = false,
withKotlinRuntime: Boolean = false,
format: String = "html",
+ includeNonPublic: Boolean = true,
outputGenerator: (DocumentationModule, StringBuilder) -> Unit) {
- verifyModel(*roots, withJdk = withJdk, withKotlinRuntime = withKotlinRuntime, format = format) {
+ verifyModel(
+ *roots,
+ withJdk = withJdk,
+ withKotlinRuntime = withKotlinRuntime,
+ format = format,
+ includeNonPublic = includeNonPublic
+ ) {
verifyModelOutput(it, outputExtension, roots.first().path, outputGenerator)
}
}
@@ -173,8 +180,17 @@ fun verifyOutput(path: String,
withJdk: Boolean = false,
withKotlinRuntime: Boolean = false,
format: String = "html",
+ includeNonPublic: Boolean = true,
outputGenerator: (DocumentationModule, StringBuilder) -> Unit) {
- verifyOutput(arrayOf(contentRootFromPath(path)), outputExtension, withJdk, withKotlinRuntime, format, outputGenerator)
+ verifyOutput(
+ arrayOf(contentRootFromPath(path)),
+ outputExtension,
+ withJdk,
+ withKotlinRuntime,
+ format,
+ includeNonPublic,
+ outputGenerator
+ )
}
fun verifyJavaOutput(path: String,
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index a2891c47..f572922c 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -392,6 +392,10 @@ class MarkdownFormatTest {
verifyMarkdownNode("typeParameterReference")
}
+ @Test fun notPublishedTypeAliasAutoExpansion() {
+ verifyMarkdownNodeByName("notPublishedTypeAliasAutoExpansion", "foo", includeNonPublic = false)
+ }
+
private fun buildMultiplePlatforms(path: String): DocumentationModule {
val module = DocumentationModule("test")
val options = DocumentationOptions("", "html", generateIndexPages = false, noStdlibLink = true)
@@ -428,8 +432,18 @@ class MarkdownFormatTest {
verifyMarkdownNodes(fileName, withKotlinRuntime) { model -> model.members.single().members }
}
- private fun verifyMarkdownNodes(fileName: String, withKotlinRuntime: Boolean = false, nodeFilter: (DocumentationModule) -> List<DocumentationNode>) {
- verifyOutput("testdata/format/$fileName.kt", ".md", withKotlinRuntime = withKotlinRuntime) { model, output ->
+ private fun verifyMarkdownNodes(
+ fileName: String,
+ withKotlinRuntime: Boolean = false,
+ includeNonPublic: Boolean = true,
+ nodeFilter: (DocumentationModule) -> List<DocumentationNode>
+ ) {
+ verifyOutput(
+ "testdata/format/$fileName.kt",
+ ".md",
+ withKotlinRuntime = withKotlinRuntime,
+ includeNonPublic = includeNonPublic
+ ) { model, output ->
markdownService.createOutputBuilder(output, tempLocation).appendNodes(nodeFilter(model))
}
}
@@ -444,8 +458,13 @@ class MarkdownFormatTest {
}
}
- private fun verifyMarkdownNodeByName(fileName: String, name: String, withKotlinRuntime: Boolean = false) {
- verifyMarkdownNodes(fileName, withKotlinRuntime) { model->
+ private fun verifyMarkdownNodeByName(
+ fileName: String,
+ name: String,
+ withKotlinRuntime: Boolean = false,
+ includeNonPublic: Boolean = true
+ ) {
+ verifyMarkdownNodes(fileName, withKotlinRuntime, includeNonPublic) { model->
val nodesWithName = model.members.single().members.filter { it.name == name }
if (nodesWithName.isEmpty()) {
throw IllegalArgumentException("Found no nodes named $name")
diff --git a/core/testdata/format/notPublishedTypeAliasAutoExpansion.kt b/core/testdata/format/notPublishedTypeAliasAutoExpansion.kt
new file mode 100644
index 00000000..1f29e110
--- /dev/null
+++ b/core/testdata/format/notPublishedTypeAliasAutoExpansion.kt
@@ -0,0 +1,13 @@
+
+class A
+class B
+
+
+internal typealias TA = A
+private typealias TB = B
+
+/**
+ * Correct ref [TA]
+ * Correct ref [TB]
+ */
+fun foo() {} \ No newline at end of file
diff --git a/core/testdata/format/notPublishedTypeAliasAutoExpansion.md b/core/testdata/format/notPublishedTypeAliasAutoExpansion.md
new file mode 100644
index 00000000..9e0f1560
--- /dev/null
+++ b/core/testdata/format/notPublishedTypeAliasAutoExpansion.md
@@ -0,0 +1,9 @@
+[test](test/index) / [foo](test/foo)
+
+# foo
+
+`fun foo(): Unit`
+
+Correct ref [TA](test/-a/index)
+Correct ref [TB](test/-b/index)
+