aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt23
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinLanguageService.kt11
-rw-r--r--core/src/main/kotlin/Model/DocumentationReference.kt1
-rw-r--r--core/src/test/kotlin/format/HtmlFormatTest.kt4
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt4
5 files changed, 37 insertions, 6 deletions
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index f922a25b..afb95fe6 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -197,11 +197,15 @@ class DocumentationBuilder
DescriptorUtils.getFqName(this).asString() in boringBuiltinClasses
fun DocumentationNode.appendAnnotations(annotated: Annotated) {
- annotated.annotations.filter { it.isDocumented() }.forEach {
- val annotationNode = it.build()
- if (annotationNode != null) {
- append(annotationNode,
- if (annotationNode.isDeprecation()) RefKind.Deprecation else RefKind.Annotation)
+ annotated.annotations.forEach {
+ it.build()?.let { annotationNode ->
+ val refKind = when {
+ it.isDocumented() && annotationNode.isDeprecation() -> RefKind.Deprecation
+ it.isDocumented() -> RefKind.Annotation
+ it.isHiddenInDocumentation() -> RefKind.HiddenAnnotation
+ else -> return@forEach
+ }
+ append(annotationNode, refKind)
}
}
}
@@ -687,10 +691,17 @@ class KotlinJavaDocumentationBuilder
}
}
+private val hiddenAnnotations = setOf(
+ KotlinBuiltIns.FQ_NAMES.parameterName.asString()
+)
+
+private fun AnnotationDescriptor.isHiddenInDocumentation() =
+ type.constructor.declarationDescriptor?.fqNameSafe?.asString() in hiddenAnnotations
+
private fun AnnotationDescriptor.isDocumented(): Boolean {
if (source.getPsi() != null && mustBeDocumented()) return true
val annotationClassName = type.constructor.declarationDescriptor?.fqNameSafe?.asString()
- return annotationClassName == "kotlin.ExtensionFunctionType"
+ return annotationClassName == KotlinBuiltIns.FQ_NAMES.extensionFunctionType.asString()
}
fun AnnotationDescriptor.mustBeDocumented(): Boolean {
diff --git a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
index 6fcf3772..75a8a948 100644
--- a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
@@ -141,6 +141,16 @@ class KotlinLanguageService : LanguageService {
}
}
+ private fun ContentBlock.renderFunctionalTypeParameterName(node: DocumentationNode, renderMode: RenderMode) {
+ node.references(RefKind.HiddenAnnotation).map { it.to }
+ .find { it.name == "ParameterName" }?.let {
+ val parameterNameValue = it.detail(NodeKind.Parameter).detail(NodeKind.Value)
+ identifier(parameterNameValue.name.removeSurrounding("\""), IdentifierKind.ParameterName)
+ symbol(":")
+ nbsp()
+ }
+ }
+
private fun ContentBlock.renderType(node: DocumentationNode, renderMode: RenderMode) {
var typeArguments = node.details(NodeKind.Type)
if (node.name == "Function${typeArguments.count() - 1}") {
@@ -153,6 +163,7 @@ class KotlinLanguageService : LanguageService {
}
symbol("(")
renderList(typeArguments.take(typeArguments.size - 1), noWrap = true) {
+ renderFunctionalTypeParameterName(it, renderMode)
renderType(it, renderMode)
}
symbol(")")
diff --git a/core/src/main/kotlin/Model/DocumentationReference.kt b/core/src/main/kotlin/Model/DocumentationReference.kt
index 0c87d719..0165b567 100644
--- a/core/src/main/kotlin/Model/DocumentationReference.kt
+++ b/core/src/main/kotlin/Model/DocumentationReference.kt
@@ -16,6 +16,7 @@ enum class RefKind {
Superclass,
Override,
Annotation,
+ HiddenAnnotation,
Deprecation,
TopLevelPage
}
diff --git a/core/src/test/kotlin/format/HtmlFormatTest.kt b/core/src/test/kotlin/format/HtmlFormatTest.kt
index 12df7c44..4b4eff59 100644
--- a/core/src/test/kotlin/format/HtmlFormatTest.kt
+++ b/core/src/test/kotlin/format/HtmlFormatTest.kt
@@ -134,6 +134,10 @@ class HtmlFormatTest {
verifyHtmlNode("linkWithStarProjection", withKotlinRuntime = true)
}
+ @Test fun functionalTypeWithNamedParameters() {
+ verifyHtmlNode("functionalTypeWithNamedParameters")
+ }
+
private fun verifyHtmlNode(fileName: String, withKotlinRuntime: Boolean = false) {
verifyHtmlNodes(fileName, withKotlinRuntime) { model -> model.members.single().members }
}
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index 6e4c44c8..c425e3f6 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -227,6 +227,10 @@ class MarkdownFormatTest {
verifyMarkdownNodeByName("qualifiedNameLink", "foo", withKotlinRuntime = true)
}
+ @Test fun functionalTypeWithNamedParameters() {
+ verifyMarkdownNode("functionalTypeWithNamedParameters")
+ }
+
@Test fun typeAliases() {
verifyMarkdownNode("typeAliases")
verifyMarkdownPackage("typeAliases")