aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMÃ¥rten Kongstad <amhk@google.com>2022-12-06 16:16:55 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-12-06 16:16:55 +0000
commitcc64ac551970d09a71cf0efbd75fdc5b21bcd373 (patch)
treebcf74e351e509e16d04c9161307f9944ebc11be1
parent1561cf03a908b651be77ab3adc54d8672bb7d852 (diff)
parentb3269255adcd5e68b4de96e0f1f202107afc7796 (diff)
downloaddokka-cc64ac551970d09a71cf0efbd75fdc5b21bcd373.tar.gz
Original change: https://android-review.googlesource.com/c/platform/external/dokka/+/2327957 Change-Id: I56a4e48c2b9f177e631789e67be92e81a996d149 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt16
-rw-r--r--core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt5
-rw-r--r--core/src/main/kotlin/Java/JavadocParser.kt15
-rw-r--r--core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt6
-rw-r--r--core/src/main/kotlin/Model/DocumentationNode.kt3
5 files changed, 41 insertions, 4 deletions
diff --git a/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt b/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt
index 2711a2df9..38921608b 100644
--- a/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt
+++ b/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt
@@ -857,19 +857,31 @@ open class JavaLayoutHtmlFormatOutputBuilder(
protected open fun FlowContent.apiAndDeprecatedVersions(node: DocumentationNode) {
val apiLevelExists = node.apiLevel.name.isNotEmpty()
+ val sdkExtSinceExists = node.sdkExtSince.name.isNotEmpty()
val deprecatedLevelExists = node.deprecatedLevel.name.isNotEmpty()
- if (apiLevelExists || deprecatedLevelExists) {
+ if (apiLevelExists || sdkExtSinceExists || deprecatedLevelExists) {
div(classes = "api-level") {
if (apiLevelExists) {
+"Added in "
a(href = "https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels") {
+"API level ${node.apiLevel.name}"
}
- if (deprecatedLevelExists) {
+ }
+ if (sdkExtSinceExists) {
+ if (apiLevelExists) {
br
+ +"Also in "
+ } else {
+ +"Added in "
+ }
+ a(href = "https://developer.android.com/sdkExtensions") {
+ +"${node.sdkExtSince.name}"
}
}
if (deprecatedLevelExists) {
+ if (apiLevelExists || sdkExtSinceExists) {
+ br
+ }
+"Deprecated in "
a(href = "https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels") {
+"API level ${node.deprecatedLevel.name}"
diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
index a7df4e482..94bb0455d 100644
--- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
@@ -112,7 +112,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
fun nodeForElement(element: PsiNamedElement,
kind: NodeKind,
name: String = element.name ?: "<anonymous>"): DocumentationNode {
- val (docComment, deprecatedContent, attrs, apiLevel, deprecatedLevel, artifactId, attribute) = docParser.parseDocumentation(element)
+ val (docComment, deprecatedContent, attrs, apiLevel, sdkExtSince, deprecatedLevel, artifactId, attribute) = docParser.parseDocumentation(element)
val node = DocumentationNode(name, docComment, kind)
if (element is PsiModifierListOwner) {
node.appendModifiers(element)
@@ -140,6 +140,9 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
apiLevel?.let {
node.append(it, RefKind.Detail)
}
+ sdkExtSince?.let {
+ node.append(it, RefKind.Detail)
+ }
deprecatedLevel?.let {
node.append(it, RefKind.Detail)
}
diff --git a/core/src/main/kotlin/Java/JavadocParser.kt b/core/src/main/kotlin/Java/JavadocParser.kt
index 21cc2bbdf..0c73e7661 100644
--- a/core/src/main/kotlin/Java/JavadocParser.kt
+++ b/core/src/main/kotlin/Java/JavadocParser.kt
@@ -25,6 +25,7 @@ data class JavadocParseResult(
val deprecatedContent: Content?,
val attributeRefs: List<String>,
val apiLevel: DocumentationNode? = null,
+ val sdkExtSince: DocumentationNode? = null,
val deprecatedLevel: DocumentationNode? = null,
val artifactId: DocumentationNode? = null,
val attribute: DocumentationNode? = null
@@ -35,6 +36,7 @@ data class JavadocParseResult(
emptyList(),
null,
null,
+ null,
null
)
}
@@ -109,6 +111,7 @@ class JavadocParser(
val attrRefSignatures = mutableListOf<String>()
var since: DocumentationNode? = null
+ var sdkextsince: DocumentationNode? = null
var deprecated: DocumentationNode? = null
var artifactId: DocumentationNode? = null
var attrName: String? = null
@@ -135,6 +138,9 @@ class JavadocParser(
"since", "apisince" -> {
since = DocumentationNode(tag.getApiLevel() ?: "", Content.Empty, NodeKind.ApiLevel)
}
+ "sdkextsince" -> {
+ sdkextsince = DocumentationNode(tag.getSdkExtSince() ?: "", Content.Empty, NodeKind.SdkExtSince)
+ }
"deprecatedsince" -> {
deprecated = DocumentationNode(tag.getApiLevel() ?: "", Content.Empty, NodeKind.DeprecatedLevel)
}
@@ -153,7 +159,7 @@ class JavadocParser(
attrName?.let { name ->
attr = DocumentationNode(name, attrDesc ?: Content.Empty, NodeKind.AttributeRef)
}
- return JavadocParseResult(result, deprecatedContent, attrRefSignatures, since, deprecated, artifactId, attr)
+ return JavadocParseResult(result, deprecatedContent, attrRefSignatures, since, sdkextsince, deprecated, artifactId, attr)
}
private val tagsToInherit = setOf("param", "return", "throws")
@@ -182,6 +188,13 @@ class JavadocParser(
return null
}
+ fun PsiDocTag.getSdkExtSince(): String? {
+ if (dataElements.isNotEmpty()) {
+ return join(dataElements.map { it.text }, " ")
+ }
+ return null
+ }
+
private fun PsiDocTag.getAttrRef(element: PsiNamedElement): String? {
if (dataElements.size > 1) {
val elementText = dataElements[1].text
diff --git a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
index 6841503fc..098a17f97 100644
--- a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
+++ b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt
@@ -142,6 +142,9 @@ class DescriptorDocumentationParser @Inject constructor(
} else if (name?.toLowerCase() == "since" || name?.toLowerCase() == "apisince") {
val apiLevel = DocumentationNode(it.getContent(), Content.Empty, NodeKind.ApiLevel)
append(apiLevel, RefKind.Detail)
+ } else if (name?.toLowerCase() == "sdkextsince") {
+ val sdkExtSince = DocumentationNode(it.getContent(), Content.Empty, NodeKind.SdkExtSince)
+ append(sdkExtSince, RefKind.Detail)
} else if (name?.toLowerCase() == "deprecatedsince") {
val deprecatedLevel = DocumentationNode(it.getContent(), Content.Empty, NodeKind.DeprecatedLevel)
append(deprecatedLevel, RefKind.Detail)
@@ -223,6 +226,9 @@ class DescriptorDocumentationParser @Inject constructor(
parseResult.apiLevel?.let {
node.append(it, RefKind.Detail)
}
+ parseResult.sdkExtSince?.let {
+ node.append(it, RefKind.Detail)
+ }
parseResult.deprecatedLevel?.let {
node.append(it, RefKind.Detail)
}
diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt
index c84d4169d..7ac6d8f4a 100644
--- a/core/src/main/kotlin/Model/DocumentationNode.kt
+++ b/core/src/main/kotlin/Model/DocumentationNode.kt
@@ -64,6 +64,7 @@ enum class NodeKind {
AttributeRef,
ApiLevel,
+ SdkExtSince,
DeprecatedLevel,
@@ -120,6 +121,8 @@ open class DocumentationNode(val name: String,
get() = references(RefKind.ExternalType).map { it.to }.firstOrNull()
val apiLevel: DocumentationNode
get() = detailOrNull(NodeKind.ApiLevel) ?: DocumentationNode("", Content.Empty, NodeKind.ApiLevel)
+ val sdkExtSince: DocumentationNode
+ get() = detailOrNull(NodeKind.SdkExtSince) ?: DocumentationNode("", Content.Empty, NodeKind.SdkExtSince)
val deprecatedLevel: DocumentationNode
get() = detailOrNull(NodeKind.DeprecatedLevel) ?: DocumentationNode("", Content.Empty, NodeKind.DeprecatedLevel)
val artifactId: DocumentationNode