From 6a1c05c2d340a6812a8b58d3027d8e5712db45a2 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Thu, 12 Nov 2020 12:01:00 +0100 Subject: Javadoc @inheritDoc tag support (#1608) --- core/src/main/kotlin/model/doc/TagWrapper.kt | 1 + core/src/main/kotlin/utilities/nodeDebug.kt | 50 ----------------------- core/src/main/kotlin/utilities/safeEnumValueOf.kt | 4 ++ 3 files changed, 5 insertions(+), 50 deletions(-) delete mode 100644 core/src/main/kotlin/utilities/nodeDebug.kt create mode 100644 core/src/main/kotlin/utilities/safeEnumValueOf.kt (limited to 'core') diff --git a/core/src/main/kotlin/model/doc/TagWrapper.kt b/core/src/main/kotlin/model/doc/TagWrapper.kt index cea132a8..f4737093 100644 --- a/core/src/main/kotlin/model/doc/TagWrapper.kt +++ b/core/src/main/kotlin/model/doc/TagWrapper.kt @@ -22,6 +22,7 @@ data class Param(override val root: DocTag, override val name: String) : NamedTa data class Return(override val root: DocTag) : TagWrapper() data class Receiver(override val root: DocTag) : TagWrapper() data class Constructor(override val root: DocTag) : TagWrapper() +//TODO this naming is confusing since kotlin has Throws annotation data class Throws(override val root: DocTag, override val name: String, val exceptionAddress: DRI?) : NamedTagWrapper() data class Sample(override val root: DocTag, override val name: String) : NamedTagWrapper() data class Deprecated(override val root: DocTag) : TagWrapper() diff --git a/core/src/main/kotlin/utilities/nodeDebug.kt b/core/src/main/kotlin/utilities/nodeDebug.kt deleted file mode 100644 index 0e8c61f7..00000000 --- a/core/src/main/kotlin/utilities/nodeDebug.kt +++ /dev/null @@ -1,50 +0,0 @@ -package org.jetbrains.dokka.utilities - -import org.jetbrains.dokka.model.Documentable -import org.jetbrains.dokka.pages.* - -const val DOWN = '\u2503' -const val BRANCH = '\u2523' -const val LAST = '\u2517' - -fun Documentable.pretty(prefix: String = "", isLast: Boolean = true): String { - val nextPrefix = prefix + (if (isLast) ' ' else DOWN) + ' ' - - return prefix + (if (isLast) LAST else BRANCH) + this.toString() + - children.dropLast(1) - .map { it.pretty(nextPrefix, false) } - .plus(children.lastOrNull()?.pretty(nextPrefix)) - .filterNotNull() - .takeIf { it.isNotEmpty() } - ?.joinToString(prefix = "\n", separator = "") - .orEmpty() + if (children.isEmpty()) "\n" else "" -} - -//fun Any.genericPretty(prefix: String = "", isLast: Boolean = true): String { -// val nextPrefix = prefix + (if (isLast) ' ' else DOWN) + ' ' -// -// return prefix + (if (isLast) LAST else BRANCH) + this.stringify() + -// allChildren().dropLast(1) -// .map { it.genericPretty(nextPrefix, false) } -// .plus(allChildren().lastOrNull()?.genericPretty(nextPrefix)) -// .filterNotNull() -// .takeIf { it.isNotEmpty() } -// ?.joinToString(prefix = "\n", separator = "") -// .orEmpty() + if (allChildren().isEmpty()) "\n" else "" -//} -private fun Any.stringify() = when(this) { - is ContentNode -> toString() + this.dci - is ContentPage -> this.name + this::class.simpleName - else -> toString() -} -//private fun Any.allChildren() = when(this){ -// is PageNode -> children + content -// is ContentBlock -> this.children -// is ContentHeader -> this.items -// is ContentStyle -> this.items -// is ContentSymbol -> this.parts -// is ContentComment -> this.parts -// is ContentGroup -> this.children -// is ContentList -> this.items -// else -> emptyList() -//} diff --git a/core/src/main/kotlin/utilities/safeEnumValueOf.kt b/core/src/main/kotlin/utilities/safeEnumValueOf.kt new file mode 100644 index 00000000..8fd5a086 --- /dev/null +++ b/core/src/main/kotlin/utilities/safeEnumValueOf.kt @@ -0,0 +1,4 @@ +package org.jetbrains.dokka.utilities + +inline fun > enumValueOrNull(name: String): T? = + T::class.java.enumConstants.firstOrNull { it.name.toUpperCase() == name.toUpperCase() } \ No newline at end of file -- cgit