aboutsummaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2016-11-29 15:28:39 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2016-11-29 15:28:39 +0300
commitf3dd7eb1d36913920e431c88a633cf5c5e098820 (patch)
treeef86ef39b956ba5bb82bc40cbf81190ff6522284 /core/src/main
parent5ab32ba0dd61585459bb32bb31fe7b19493c980e (diff)
downloaddokka-f3dd7eb1d36913920e431c88a633cf5c5e098820.tar.gz
dokka-f3dd7eb1d36913920e431c88a633cf5c5e098820.tar.bz2
dokka-f3dd7eb1d36913920e431c88a633cf5c5e098820.zip
Post-review fixes, removed code duplication, fixed @throws support
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/kotlin/Model/Content.kt3
-rw-r--r--core/src/main/kotlin/javadoc/docbase.kt44
-rw-r--r--core/src/main/kotlin/javadoc/tags.kt10
3 files changed, 23 insertions, 34 deletions
diff --git a/core/src/main/kotlin/Model/Content.kt b/core/src/main/kotlin/Model/Content.kt
index 7464d510..1a8bc5d2 100644
--- a/core/src/main/kotlin/Model/Content.kt
+++ b/core/src/main/kotlin/Model/Content.kt
@@ -132,6 +132,7 @@ object ContentTags {
val Description = "Description"
val SeeAlso = "See Also"
val Return = "Return"
+ val Exceptions = "Exceptions"
}
fun content(body: ContentBlock.() -> Unit): ContentBlock {
@@ -237,6 +238,6 @@ open class MutableContent() : Content() {
fun javadocSectionDisplayName(sectionName: String?): String? =
when(sectionName) {
"param" -> "Parameters"
- "throws", "exception" -> "Exceptions"
+ "throws", "exception" -> ContentTags.Exceptions
else -> sectionName?.capitalize()
}
diff --git a/core/src/main/kotlin/javadoc/docbase.kt b/core/src/main/kotlin/javadoc/docbase.kt
index b125a7d4..eafa216b 100644
--- a/core/src/main/kotlin/javadoc/docbase.kt
+++ b/core/src/main/kotlin/javadoc/docbase.kt
@@ -309,10 +309,8 @@ open class ExecutableMemberAdapter(module: ModuleNodeAdapter, node: Documentatio
override fun thrownExceptions(): Array<out ClassDoc> = emptyArray() // TODO
override fun throwsTags(): Array<out ThrowsTag> =
node.content.sections
- .filter { it.tag == "Exceptions" }
- .map { it.subjectName }
- .filterNotNull()
- .map { ThrowsTagAdapter(this, ClassDocumentationNodeAdapter(module, classOf(it, NodeKind.Exception))) }
+ .filter { it.tag == ContentTags.Exceptions && it.subjectName != null }
+ .map { ThrowsTagAdapter(this, ClassDocumentationNodeAdapter(module, classOf(it.subjectName!!, NodeKind.Exception)), it.children) }
.toTypedArray()
override fun isVarArgs(): Boolean = node.details(NodeKind.Parameter).any { false } // TODO
@@ -320,14 +318,7 @@ open class ExecutableMemberAdapter(module: ModuleNodeAdapter, node: Documentatio
override fun isSynchronized(): Boolean = node.annotations.any { it.name == "synchronized" }
override fun paramTags(): Array<out ParamTag> =
- (node.details(NodeKind.Parameter)
- .filter(DocumentationNode::hasNonEmptyContent)
- .map { ParamTagAdapter(module, this, it.name, false, it.content.children) }
-
- + node.content.sections
- .filter { it.subjectName in parameters().map { it.name() } }
- .map { ParamTagAdapter(module, this, it.subjectName ?: "?", true, it.children) }
- ).toTypedArray()
+ collectParamTags(NodeKind.Parameter, sectionFilter = { it.subjectName in parameters().map { it.name() } })
override fun thrownExceptionTypes(): Array<out Type> = emptyArray()
override fun receiverType(): Type? = receiverNode()?.let { receiver -> TypeAdapter(module, receiver) }
@@ -342,14 +333,7 @@ open class ExecutableMemberAdapter(module: ModuleNodeAdapter, node: Documentatio
override fun typeParameters(): Array<out TypeVariable> = node.details(NodeKind.TypeParameter).map { TypeVariableAdapter(module, it) }.toTypedArray()
override fun typeParamTags(): Array<out ParamTag> =
- (node.details(NodeKind.TypeParameter)
- .filter(DocumentationNode::hasNonEmptyContent)
- .map { ParamTagAdapter(module, this, it.name, true, it.content.children) }
-
- + node.content.sections
- .filter { it.subjectName in typeParameters().map { it.simpleTypeName() } }
- .map { ParamTagAdapter(module, this, it.subjectName ?: "?", true, it.children) }
- ).toTypedArray()
+ collectParamTags(NodeKind.TypeParameter, sectionFilter = { it.subjectName in typeParameters().map { it.simpleTypeName() } })
private fun receiverNode() = node.details(NodeKind.Receiver).let { receivers ->
when {
@@ -443,14 +427,7 @@ open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNod
.toTypedArray()
override fun typeParamTags(): Array<out ParamTag> =
- (classNode.details(NodeKind.TypeParameter)
- .filter(DocumentationNode::hasNonEmptyContent)
- .map { ParamTagAdapter(module, this, it.name, true, it.content.children) }
-
- + classNode.content.sections
- .filter { it.subjectName in typeParameters().map { it.simpleTypeName() } }
- .map { ParamTagAdapter(module, this, it.subjectName ?: "?", true, it.children) }
- ).toTypedArray()
+ collectParamTags(NodeKind.TypeParameter, sectionFilter = { it.subjectName in typeParameters().map { it.simpleTypeName() } })
override fun fields(): Array<out FieldDoc> = fields(true)
override fun fields(filter: Boolean): Array<out FieldDoc> = classNode.members(NodeKind.Field).map { FieldAdapter(module, it) }.toTypedArray()
@@ -533,3 +510,14 @@ class ModuleNodeAdapter(val module: DocumentationModule, val reporter: DocErrorR
override fun specifiedClasses(): Array<out ClassDoc> = classes()
}
+
+private fun DocumentationNodeAdapter.collectParamTags(kind: NodeKind, sectionFilter: (ContentSection) -> Boolean) =
+ (node.details(kind)
+ .filter(DocumentationNode::hasNonEmptyContent)
+ .map { ParamTagAdapter(module, this, it.name, true, it.content.children) }
+
+ + node.content.sections
+ .filter(sectionFilter)
+ .map { ParamTagAdapter(module, this, it.subjectName ?: "?", true, it.children) })
+
+ .toTypedArray() \ No newline at end of file
diff --git a/core/src/main/kotlin/javadoc/tags.kt b/core/src/main/kotlin/javadoc/tags.kt
index 5ee2cbac..9e023a81 100644
--- a/core/src/main/kotlin/javadoc/tags.kt
+++ b/core/src/main/kotlin/javadoc/tags.kt
@@ -114,20 +114,20 @@ class ParamTagAdapter(val module: ModuleNodeAdapter,
}
-class ThrowsTagAdapter(val holder: Doc, val type: ClassDocumentationNodeAdapter) : ThrowsTag {
+class ThrowsTagAdapter(val holder: Doc, val type: ClassDocumentationNodeAdapter, val content: List<ContentNode>) : ThrowsTag {
override fun name(): String = "@throws"
override fun kind(): String = name()
override fun holder(): Doc = holder
override fun position(): SourcePosition? = holder.position()
- override fun text(): String = "@throws ${type.qualifiedTypeName()}"
- override fun inlineTags(): Array<out Tag> = emptyArray()
+ override fun text(): String = "${name()} ${exceptionName()} ${exceptionComment()}"
+ override fun inlineTags(): Array<out Tag> = buildInlineTags(type.module, holder, content).toTypedArray()
override fun firstSentenceTags(): Array<out Tag> = emptyArray()
- override fun exceptionComment(): String = ""
+ override fun exceptionComment(): String = content.toString()
override fun exceptionType(): Type = type
override fun exception(): ClassDoc = type
- override fun exceptionName(): String = type.qualifiedName()
+ override fun exceptionName(): String = type.qualifiedTypeName()
}
class ReturnTagAdapter(val module: ModuleNodeAdapter, val holder: Doc, val content: List<ContentNode>) : Tag {