aboutsummaryrefslogtreecommitdiff
path: root/src/Kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'src/Kotlin')
-rw-r--r--src/Kotlin/ContentBuilder.kt12
-rw-r--r--src/Kotlin/DocumentationBuilder.kt11
2 files changed, 20 insertions, 3 deletions
diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt
index 11c40743..44a4f39e 100644
--- a/src/Kotlin/ContentBuilder.kt
+++ b/src/Kotlin/ContentBuilder.kt
@@ -131,17 +131,23 @@ public fun buildInlineContentTo(tree: MarkdownNode, target: ContentBlock, linkRe
}
fun DocumentationBuilder.functionBody(descriptor: DeclarationDescriptor, functionName: String?): ContentNode {
- if (functionName == null)
+ if (functionName == null) {
+ logger.warn("Missing function name in @sample in ${descriptor.signature()}")
return ContentBlockCode().let() { it.append(ContentText("Missing function name in @sample")); it }
+ }
val scope = getResolutionScope(session, descriptor)
val rootPackage = session.getModuleDescriptor().getPackage(FqName.ROOT)!!
val rootScope = rootPackage.getMemberScope()
val symbol = resolveInScope(functionName, scope) ?: resolveInScope(functionName, rootScope)
- if (symbol == null)
+ if (symbol == null) {
+ logger.warn("Unresolved function $functionName in @sample in ${descriptor.signature()}")
return ContentBlockCode().let() { it.append(ContentText("Unresolved: $functionName")); it }
+ }
val psiElement = DescriptorToSourceUtils.descriptorToDeclaration(symbol)
- if (psiElement == null)
+ if (psiElement == null) {
+ logger.warn("Can't find source for function $functionName in @sample in ${descriptor.signature()}")
return ContentBlockCode().let() { it.append(ContentText("Source not found: $functionName")); it }
+ }
val text = when (psiElement) {
is JetDeclarationWithBody -> ContentBlockCode().let() {
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index 2c4c5119..83e5898b 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.types.TypeProjection
import org.jetbrains.kotlin.types.expressions.OperatorConventions
public data class DocumentationOptions(val includeNonPublic: Boolean = false,
+ val reportUndocumented: Boolean = true,
val sourceLinks: List<SourceLinkDefinition>)
private fun isSamePackage(descriptor1: DeclarationDescriptor, descriptor2: DeclarationDescriptor): Boolean {
@@ -46,6 +47,11 @@ class DocumentationBuilder(val session: ResolveSession,
fun parseDocumentation(descriptor: DeclarationDescriptor): Content {
val kdoc = KDocFinder.findKDoc(descriptor)
if (kdoc == null) {
+ if (options.reportUndocumented && !descriptor.isDeprecated() &&
+ descriptor !is ValueParameterDescriptor && descriptor !is TypeParameterDescriptor &&
+ descriptor !is PropertyAccessorDescriptor) {
+ logger.warn("No documentation for ${descriptor.signature()}")
+ }
return Content.Empty
}
var kdocText = kdoc.getContent()
@@ -76,6 +82,10 @@ class DocumentationBuilder(val session: ResolveSession,
return content
}
+ fun DeclarationDescriptor.isDeprecated() = getAnnotations().any {
+ DescriptorUtils.getFqName(it.getType().getConstructor().getDeclarationDescriptor()).asString() == "kotlin.deprecated"
+ }
+
fun DeclarationDescriptor.signature(): String = when(this) {
is ClassDescriptor, is PackageFragmentDescriptor -> DescriptorUtils.getFqName(this).asString()
is PropertyDescriptor -> getContainingDeclaration().signature() + "#" + getName() + receiverSignature()
@@ -122,6 +132,7 @@ class DocumentationBuilder(val session: ResolveSession,
if ("/" in href) {
return ContentExternalLink(href)
}
+ logger.warn("Unresolved link to $href in doc comment of ${descriptor.signature()}")
return ContentExternalLink("#")
}