diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-29 13:31:16 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-29 13:31:16 +0100 |
commit | 4e09ac20457e2c4398406a1c23bf1f435f31349e (patch) | |
tree | 87e074f00e3d31ac3c73a2b1d64ad7fc20375f8d /javadoc/src | |
parent | c9d59e9ae85f76e021d53c77ef18bfce0ff7ec7c (diff) | |
parent | 8216501e9a07940ed0a0be3d204733df9a9d811c (diff) | |
download | dokka-4e09ac20457e2c4398406a1c23bf1f435f31349e.tar.gz dokka-4e09ac20457e2c4398406a1c23bf1f435f31349e.tar.bz2 dokka-4e09ac20457e2c4398406a1c23bf1f435f31349e.zip |
Merge branch 'javadoc' of https://github.com/cy6erGn0m/dokka into cy6erGn0m-javadoc
# Conflicts:
# dokka.iml
# javadoc/javadoc.iml
# javadoc/src/main/kotlin/docbase.kt
# javadoc/src/main/kotlin/dokka-adapters.kt
# javadoc/src/main/kotlin/reporter.kt
# javadoc/src/main/kotlin/tags.kt
# src/Analysis/AnalysisEnvironment.kt
# src/Analysis/CompilerAPI.kt
# src/Formats/KotlinWebsiteFormatService.kt
# src/Formats/StructuredFormatService.kt
# src/Java/JavaDocumentationBuilder.kt
# src/Kotlin/ContentBuilder.kt
# src/Kotlin/DocumentationBuilder.kt
# src/Languages/JavaLanguageService.kt
# src/Model/Content.kt
# src/Model/PackageDocs.kt
# src/Utilities/GuiceModule.kt
# src/Utilities/Path.kt
# src/Utilities/ServiceLocator.kt
# test/src/markdown/MarkdownTestRunner.kt
Diffstat (limited to 'javadoc/src')
-rw-r--r-- | javadoc/src/main/kotlin/docbase.kt | 133 | ||||
-rw-r--r-- | javadoc/src/main/kotlin/dokka-adapters.kt | 2 | ||||
-rw-r--r-- | javadoc/src/main/kotlin/reporter.kt | 18 | ||||
-rw-r--r-- | javadoc/src/main/kotlin/tags.kt | 76 | ||||
-rw-r--r-- | javadoc/src/main/resources/dokka/format/javadoc.properties | 1 |
5 files changed, 121 insertions, 109 deletions
diff --git a/javadoc/src/main/kotlin/docbase.kt b/javadoc/src/main/kotlin/docbase.kt index 36371ad8..7625d545 100644 --- a/javadoc/src/main/kotlin/docbase.kt +++ b/javadoc/src/main/kotlin/docbase.kt @@ -5,12 +5,22 @@ import org.jetbrains.dokka.* import java.lang.reflect.Modifier import java.util.Collections import java.util.HashSet +import kotlin.platform.platformStatic +import kotlin.reflect.KClass -open class DocumentationNodeBareAdapter(val docNode: DocumentationNode) : Doc { +private interface HasModule { + val module: ModuleNodeAdapter +} + +private interface HasDocumentationNode { + val node: DocumentationNode +} + +open class DocumentationNodeBareAdapter(override val node: DocumentationNode) : Doc, HasDocumentationNode { private var rawCommentText_ = rawCommentText - override fun name(): String = docNode.name - override fun position(): SourcePosition? = SourcePositionAdapter(docNode) + override fun name(): String = node.name + override fun position(): SourcePosition? = SourcePositionAdapter(node) override fun inlineTags(): Array<out Tag>? = emptyArray() override fun firstSentenceTags(): Array<out Tag>? = emptyArray() @@ -26,46 +36,52 @@ open class DocumentationNodeBareAdapter(val docNode: DocumentationNode) : Doc { override fun getRawCommentText(): String = rawCommentText_ override fun isError(): Boolean = false - override fun isException(): Boolean = docNode.kind == DocumentationNode.Kind.Exception - override fun isEnumConstant(): Boolean = docNode.kind == DocumentationNode.Kind.EnumItem - override fun isEnum(): Boolean = docNode.kind == DocumentationNode.Kind.Enum - override fun isMethod(): Boolean = docNode.kind == DocumentationNode.Kind.Function - override fun isInterface(): Boolean = docNode.kind == DocumentationNode.Kind.Interface - override fun isField(): Boolean = docNode.kind == DocumentationNode.Kind.Property - override fun isClass(): Boolean = docNode.kind == DocumentationNode.Kind.Class - override fun isAnnotationType(): Boolean = docNode.kind == DocumentationNode.Kind.AnnotationClass - override fun isConstructor(): Boolean = docNode.kind == DocumentationNode.Kind.Constructor - override fun isOrdinaryClass(): Boolean = docNode.kind == DocumentationNode.Kind.Class - override fun isAnnotationTypeElement(): Boolean = docNode.kind == DocumentationNode.Kind.Annotation + override fun isException(): Boolean = node.kind == DocumentationNode.Kind.Exception + override fun isEnumConstant(): Boolean = node.kind == DocumentationNode.Kind.EnumItem + override fun isEnum(): Boolean = node.kind == DocumentationNode.Kind.Enum + override fun isMethod(): Boolean = node.kind == DocumentationNode.Kind.Function + override fun isInterface(): Boolean = node.kind == DocumentationNode.Kind.Interface + override fun isField(): Boolean = node.kind == DocumentationNode.Kind.Property + override fun isClass(): Boolean = node.kind == DocumentationNode.Kind.Class + override fun isAnnotationType(): Boolean = node.kind == DocumentationNode.Kind.AnnotationClass + override fun isConstructor(): Boolean = node.kind == DocumentationNode.Kind.Constructor + override fun isOrdinaryClass(): Boolean = node.kind == DocumentationNode.Kind.Class + override fun isAnnotationTypeElement(): Boolean = node.kind == DocumentationNode.Kind.Annotation override fun compareTo(other: Any?): Int = when (other) { !is DocumentationNodeAdapter -> 1 - else -> docNode.name.compareTo(other.docNode.name) + else -> node.name.compareTo(other.node.name) } - override fun equals(other: Any?): Boolean = docNode.qualifiedName == (other as? DocumentationNodeAdapter)?.docNode?.qualifiedName - override fun hashCode(): Int = docNode.name.hashCode() + override fun equals(other: Any?): Boolean = node.qualifiedName == (other as? DocumentationNodeAdapter)?.node?.qualifiedName + override fun hashCode(): Int = node.name.hashCode() - override fun isIncluded(): Boolean = docNode.kind != DocumentationNode.Kind.ExternalClass + override fun isIncluded(): Boolean = node.kind != DocumentationNode.Kind.ExternalClass } // TODO think of source position instead of null // TODO tags -open class DocumentationNodeAdapter(val module: ModuleNodeAdapter, docNode: DocumentationNode) : DocumentationNodeBareAdapter(docNode) { - override fun inlineTags(): Array<out Tag> = buildInlineTags(module, this, docNode.content).toTypedArray() - override fun firstSentenceTags(): Array<out Tag> = buildInlineTags(module, this, docNode.summary).toTypedArray() - override fun tags(): Array<out Tag> = (buildInlineTags(module, this, docNode.content) + docNode.content.sections.flatMap { +open class DocumentationNodeAdapter(override val module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeBareAdapter(node), HasModule { + override fun inlineTags(): Array<out Tag> = buildInlineTags(module, this, node.content).toTypedArray() + override fun firstSentenceTags(): Array<out Tag> = buildInlineTags(module, this, node.summary).toTypedArray() + override fun tags(): Array<out Tag> = (buildInlineTags(module, this, node.content) + node.content.sections.flatMap { when (it.tag) { - "See Also" -> buildInlineTags(module, this, it) + ContentTags.SeeAlso -> buildInlineTags(module, this, it) else -> emptyList<Tag>() } }).toTypedArray() } -val allClassKinds = setOf(DocumentationNode.Kind.Class, DocumentationNode.Kind.Enum, DocumentationNode.Kind.Interface, DocumentationNode.Kind.Object, DocumentationNode.Kind.Exception) +// should be extension property but can't because of KT-8745 +private fun <T> nodeAnnotations(self: T): List<AnnotationDescAdapter> where T : HasModule, T : HasDocumentationNode + = self.node.annotations.map { AnnotationDescAdapter(self.module, it) } + +private fun DocumentationNode.hasAnnotation(klass: KClass<*>) = klass.qualifiedName in annotations.map { it.qualifiedName } + +private val allClassKinds = setOf(DocumentationNode.Kind.Class, DocumentationNode.Kind.Enum, DocumentationNode.Kind.Interface, DocumentationNode.Kind.Object, DocumentationNode.Kind.Exception) -class PackageAdapter(module: ModuleNodeAdapter, val node: DocumentationNode) : DocumentationNodeAdapter(module, node), PackageDoc { +class PackageAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeAdapter(module, node), PackageDoc { private val allClasses = node.members.filter { it.kind in allClassKinds }.toMap { it.name } private val packageFacade = PackageFacadeAdapter(module, node) @@ -96,13 +112,14 @@ class AnnotationDescAdapter(val module: ModuleNodeAdapter, val node: Documentati override fun elementValues(): Array<out AnnotationDesc.ElementValuePair>? = emptyArray() // TODO } -class ProgramElementAdapter(module: ModuleNodeAdapter, val node: DocumentationNode) : DocumentationNodeAdapter(module, node), ProgramElementDoc { +class ProgramElementAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeAdapter(module, node), ProgramElementDoc { override fun isPublic(): Boolean = true override fun isPackagePrivate(): Boolean = false override fun isStatic(): Boolean = node.owner?.kind in listOf(DocumentationNode.Kind.Package, DocumentationNode.Kind.ExternalClass) + || node.hasAnnotation(platformStatic::class) override fun modifierSpecifier(): Int = Modifier.PUBLIC + if (isStatic) Modifier.STATIC else 0 override fun qualifiedName(): String? = node.qualifiedName - override fun annotations(): Array<out AnnotationDesc>? = node.annotations.map { AnnotationDescAdapter(module, it) }.toTypedArray() + override fun annotations(): Array<out AnnotationDesc>? = nodeAnnotations(this).toTypedArray() override fun modifiers(): String? = "public ${if (isStatic) "static" else ""}".trim() override fun isProtected(): Boolean = false @@ -137,29 +154,14 @@ class ProgramElementAdapter(module: ModuleNodeAdapter, val node: DocumentationNo override fun isIncluded(): Boolean = containingPackage()?.isIncluded ?: false && containingClass()?.let { it.isIncluded } ?: true } -public fun DocumentationNode.getArrayElementType(): DocumentationNode? = when (name) { - "Array" -> details(DocumentationNode.Kind.Type).singleOrNull()?.let { et -> et.getArrayElementType() ?: et } ?: DocumentationNode("Object", content, DocumentationNode.Kind.ExternalClass) - "IntArray", "LongArray", "ShortArray", "ByteArray", "CharArray", "DoubleArray", "FloatArray", "BooleanArray" -> DocumentationNode(name.removeSuffix("Array").toLowerCase(), content, DocumentationNode.Kind.Type) - else -> null -} - -fun DocumentationNode.getArrayDimension(): Int = when (name) { - "Array" -> 1 + (details(DocumentationNode.Kind.Type).singleOrNull()?.getArrayDimension() ?: 0) - "IntArray", "LongArray", "ShortArray", "ByteArray", "CharArray", "DoubleArray", "FloatArray", "BooleanArray" -> 1 - else -> 0 -} +open class TypeAdapter(override val module: ModuleNodeAdapter, override val node: DocumentationNode) : Type, HasDocumentationNode, HasModule { + private val javaLanguageService = JavaLanguageService() -//fun DocumentationNode.convertNativeType(): DocumentationNode = when (name) { -// "Unit" -> DocumentationNode("void", content, kind) -// "Int" -> DocumentationNode("int", content, kind) -//} - -open class TypeAdapter(val module: ModuleNodeAdapter, val node: DocumentationNode) : Type { - override fun qualifiedTypeName(): String = node.getArrayElementType()?.qualifiedName ?: node.qualifiedName - override fun typeName(): String = node.getArrayElementType()?.name ?: node.name + override fun qualifiedTypeName(): String = javaLanguageService.getArrayElementType(node)?.qualifiedName ?: node.qualifiedName + override fun typeName(): String = javaLanguageService.getArrayElementType(node)?.name ?: node.name override fun simpleTypeName(): String = typeName() // TODO difference typeName() vs simpleTypeName() - override fun dimension(): String = Collections.nCopies(node.getArrayDimension(), "[]").joinToString("") + override fun dimension(): String = Collections.nCopies(javaLanguageService.getArrayDimension(node), "[]").joinToString("") override fun isPrimitive(): Boolean = node.name in setOf("Int", "Long", "Short", "Byte", "Char", "Double", "Float", "Boolean", "Unit") override fun asClassDoc(): ClassDoc? = if (isPrimitive) null else elementType?.asClassDoc() ?: @@ -184,7 +186,7 @@ open class TypeAdapter(val module: ModuleNodeAdapter, val node: DocumentationNod override fun asAnnotationTypeDoc(): AnnotationTypeDoc? = if (node.kind == DocumentationNode.Kind.AnnotationClass) AnnotationTypeDocAdapter(module, node) else null override fun asAnnotatedType(): AnnotatedType? = if (node.annotations.isNotEmpty()) AnnotatedTypeAdapter(module, node) else null - override fun getElementType(): Type? = node.getArrayElementType()?.let { et -> TypeAdapter(module, et) } + override fun getElementType(): Type? = javaLanguageService.getArrayElementType(node)?.let { et -> TypeAdapter(module, et) } override fun asWildcardType(): WildcardType? = null override fun toString(): String = qualifiedTypeName() + dimension() @@ -194,7 +196,7 @@ open class TypeAdapter(val module: ModuleNodeAdapter, val node: DocumentationNod class AnnotatedTypeAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : TypeAdapter(module, node), AnnotatedType { override fun underlyingType(): Type? = this - override fun annotations(): Array<out AnnotationDesc> = node.annotations.map { AnnotationDescAdapter(module, it) }.toTypedArray() + override fun annotations(): Array<out AnnotationDesc> = nodeAnnotations(this).toTypedArray() } class WildcardTypeAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : TypeAdapter(module, node), WildcardType { @@ -227,7 +229,6 @@ class TypeVariableAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : override fun equals(other: Any?): Boolean = other is Type && other.typeName() == typeName() && other.asTypeVariable()?.owner() == owner() override fun asTypeVariable(): TypeVariableAdapter = this - // override fun asClassDoc(): ClassDoc? = null } class ParameterizedTypeAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : TypeAdapter(module, node), ParameterizedType { @@ -254,17 +255,23 @@ class ParameterizedTypeAdapter(module: ModuleNodeAdapter, node: DocumentationNod } } -class ParameterAdapter(module: ModuleNodeAdapter, val node: DocumentationNode) : DocumentationNodeAdapter(module, node), Parameter { +class ParameterAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeAdapter(module, node), Parameter { override fun typeName(): String? = JavaLanguageService().renderType(node.detail(DocumentationNode.Kind.Type)) override fun type(): Type? = TypeAdapter(module, node.detail(DocumentationNode.Kind.Type)) - override fun annotations(): Array<out AnnotationDesc>? = node.details(DocumentationNode.Kind.Annotation).map { AnnotationDescAdapter(module, it) }.toTypedArray() + override fun annotations(): Array<out AnnotationDesc> = nodeAnnotations(this).toTypedArray() } -class ReceiverParameterAdapter(module: ModuleNodeAdapter, val receiverType: DocumentationNode) : DocumentationNodeAdapter(module, receiverType), Parameter { +class ReceiverParameterAdapter(module: ModuleNodeAdapter, val receiverType: DocumentationNode, val parent: ExecutableMemberAdapter) : DocumentationNodeAdapter(module, receiverType), Parameter { override fun typeName(): String? = receiverType.name override fun type(): Type? = TypeAdapter(module, receiverType) - override fun annotations(): Array<out AnnotationDesc> = emptyArray() - override fun name(): String = "receiver" + override fun annotations(): Array<out AnnotationDesc> = nodeAnnotations(this).toTypedArray() + override fun name(): String = tryName("receiver") + + tailRecursive + private fun tryName(name: String): String = when (name) { + in parent.parameters().drop(1).map { it.name() } -> tryName("$$name") + else -> name + } } fun classOf(fqName: String, kind: DocumentationNode.Kind = DocumentationNode.Kind.Class) = DocumentationNode(fqName.substringAfterLast(".", fqName), Content.Empty, kind).let { node -> @@ -276,7 +283,7 @@ fun classOf(fqName: String, kind: DocumentationNode.Kind = DocumentationNode.Kin node } -open class ExecutableMemberAdapter(module: ModuleNodeAdapter, val node: DocumentationNode) : DocumentationNodeAdapter(module, node), ProgramElementDoc by ProgramElementAdapter(module, node), ExecutableMemberDoc { +open class ExecutableMemberAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeAdapter(module, node), ProgramElementDoc by ProgramElementAdapter(module, node), ExecutableMemberDoc { override fun isSynthetic(): Boolean = false override fun isNative(): Boolean = node.annotations.any { it.name == "native" } @@ -303,7 +310,7 @@ open class ExecutableMemberAdapter(module: ModuleNodeAdapter, val node: Document override fun signature(): String = node.details(DocumentationNode.Kind.Parameter).map { JavaLanguageService().renderType(it) }.joinToString(", ", "(", ")") // TODO it should be FQ types override fun parameters(): Array<out Parameter> = - ((receiverNode()?.let { receiver -> listOf<Parameter>(ReceiverParameterAdapter(module, receiver)) } ?: emptyList()) + ((receiverNode()?.let { receiver -> listOf<Parameter>(ReceiverParameterAdapter(module, receiver, this)) } ?: emptyList()) + node.details(DocumentationNode.Kind.Parameter).map { ParameterAdapter(module, it) } ).toTypedArray() @@ -325,7 +332,7 @@ class ConstructorAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : E override fun name(): String = node.owner?.name ?: throw IllegalStateException("No owner for $node") } -class MethodAdapter(module: ModuleNodeAdapter, val node: DocumentationNode) : DocumentationNodeAdapter(module, node), ExecutableMemberDoc by ExecutableMemberAdapter(module, node), MethodDoc { +class MethodAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeAdapter(module, node), ExecutableMemberDoc by ExecutableMemberAdapter(module, node), MethodDoc { override fun overrides(meth: MethodDoc?): Boolean = false // TODO override fun overriddenType(): Type? = node.overrides.firstOrNull()?.owner?.let { owner -> TypeAdapter(module, owner) } @@ -340,17 +347,17 @@ class MethodAdapter(module: ModuleNodeAdapter, val node: DocumentationNode) : Do override fun returnType(): Type = TypeAdapter(module, node.detail(DocumentationNode.Kind.Type)) } -class FieldAdapter(module: ModuleNodeAdapter, val node: DocumentationNode) : DocumentationNodeAdapter(module, node), ProgramElementDoc by ProgramElementAdapter(module, node), FieldDoc { +class FieldAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeAdapter(module, node), ProgramElementDoc by ProgramElementAdapter(module, node), FieldDoc { override fun isSynthetic(): Boolean = false - override fun constantValueExpression(): String? = null // TODO - override fun constantValue(): Any? = null + override fun constantValueExpression(): String? = node.details(DocumentationNode.Kind.Value).firstOrNull()?.let { it.name } + override fun constantValue(): Any? = constantValueExpression() override fun type(): Type = TypeAdapter(module, node.detail(DocumentationNode.Kind.Type)) - override fun isTransient(): Boolean = false // TODO + override fun isTransient(): Boolean = node.hasAnnotation(transient::class) override fun serialFieldTags(): Array<out SerialFieldTag> = emptyArray() - override fun isVolatile(): Boolean = false // TODO + override fun isVolatile(): Boolean = node.hasAnnotation(volatile::class) } open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNode: DocumentationNode) : DocumentationNodeAdapter(module, classNode), Type by TypeAdapter(module, classNode), ProgramElementDoc by ProgramElementAdapter(module, classNode), ClassDoc { diff --git a/javadoc/src/main/kotlin/dokka-adapters.kt b/javadoc/src/main/kotlin/dokka-adapters.kt index c9183d50..0f7c53d7 100644 --- a/javadoc/src/main/kotlin/dokka-adapters.kt +++ b/javadoc/src/main/kotlin/dokka-adapters.kt @@ -9,7 +9,7 @@ class JavadocGenerator(val conf: DokkaGenerator) : Generator { val module = nodes.single() as DocumentationModule DokkaConsoleLogger.report() - HtmlDoclet.start(ModuleNodeAdapter(module, StandardReporter, conf.outputDir)) + HtmlDoclet.start(ModuleNodeAdapter(module, StandardReporter(conf.logger), conf.outputDir)) } override fun buildOutlines(nodes: Iterable<DocumentationNode>) { diff --git a/javadoc/src/main/kotlin/reporter.kt b/javadoc/src/main/kotlin/reporter.kt index ce80ec7b..fc38368c 100644 --- a/javadoc/src/main/kotlin/reporter.kt +++ b/javadoc/src/main/kotlin/reporter.kt @@ -2,29 +2,33 @@ package org.jetbrains.dokka.javadoc import com.sun.javadoc.DocErrorReporter import com.sun.javadoc.SourcePosition +import org.jetbrains.dokka.DokkaLogger -object StandardReporter : DocErrorReporter { +class StandardReporter(val logger: DokkaLogger) : DocErrorReporter { override fun printWarning(msg: String?) { - System.err?.println("[WARN] $msg") + logger.warn(msg.toString()) } override fun printWarning(pos: SourcePosition?, msg: String?) { - System.err?.println("[WARN] ${pos?.file()}:${pos?.line()}:${pos?.column()}: $msg") + logger.warn(format(pos, msg)) } override fun printError(msg: String?) { - System.err?.println("[ERROR] $msg") + logger.error(msg.toString()) } override fun printError(pos: SourcePosition?, msg: String?) { - System.err?.println("[ERROR] ${pos?.file()}:${pos?.line()}:${pos?.column()}: $msg") + logger.error(format(pos, msg)) } override fun printNotice(msg: String?) { - System.err?.println("[NOTICE] $msg") + logger.info(msg.toString()) } override fun printNotice(pos: SourcePosition?, msg: String?) { - System.err?.println("[NOTICE] ${pos?.file()}:${pos?.line()}:${pos?.column()}: $msg") + logger.info(format(pos, msg)) } + + private fun format(pos: SourcePosition?, msg: String?) = + if (pos == null) msg.toString() else "${pos.file()}:${pos.line()}:${pos.column()}: $msg" }
\ No newline at end of file diff --git a/javadoc/src/main/kotlin/tags.kt b/javadoc/src/main/kotlin/tags.kt index 6f0ebca0..b9b7995d 100644 --- a/javadoc/src/main/kotlin/tags.kt +++ b/javadoc/src/main/kotlin/tags.kt @@ -2,7 +2,7 @@ package org.jetbrains.dokka.javadoc import com.sun.javadoc.* import org.jetbrains.dokka.* -import java.util.* +import java.util.ArrayList class TextTag(val holder: Doc, val content: ContentText) : Tag { val plainText: String @@ -48,7 +48,7 @@ class SeeMethodTagAdapter(holder: Doc, val method: MethodAdapter, content: Conte override fun referencedPackage(): PackageDoc? = null override fun referencedClass(): ClassDoc = method.containingClass() override fun referencedClassName(): String = method.containingClass().name() - override fun label(): String = "fun ${method.containingClass().name()}.${method.name()}" + override fun label(): String = "${method.containingClass().name()}.${method.name()}" override fun inlineTags(): Array<out Tag> = emptyArray() // TODO override fun firstSentenceTags(): Array<out Tag> = inlineTags() // TODO @@ -60,13 +60,13 @@ class SeeClassTagAdapter(holder: Doc, val clazz: ClassDocumentationNodeAdapter, override fun referencedPackage(): PackageDoc? = null override fun referencedClass(): ClassDoc = clazz override fun referencedClassName(): String = clazz.name() - override fun label(): String = "${clazz.classNode.kind.name().toLowerCase()} ${clazz.name()}" // TODO + override fun label(): String = "${clazz.classNode.kind.name().toLowerCase()} ${clazz.name()}" override fun inlineTags(): Array<out Tag> = emptyArray() // TODO override fun firstSentenceTags(): Array<out Tag> = inlineTags() // TODO } -class ParamTagAdapter(val module: ModuleNodeAdapter, val holder: Doc, val parameterName: String, val typeParameter: Boolean, val content: List<ContentNode>) : ParamTag { +class ParamTagAdapter(val module: ModuleNodeAdapter, val holder: Doc, val parameterName: String, val isTypeParameter: Boolean, val content: List<ContentNode>) : ParamTag { constructor(module: ModuleNodeAdapter, holder: Doc, parameterName: String, isTypeParameter: Boolean, content: ContentNode) : this(module, holder, parameterName, isTypeParameter, listOf(content)) override fun name(): String = "@param" @@ -78,7 +78,7 @@ class ParamTagAdapter(val module: ModuleNodeAdapter, val holder: Doc, val parame override fun inlineTags(): Array<out Tag> = content.flatMap { buildInlineTags(module, holder, it) }.toTypedArray() override fun firstSentenceTags(): Array<out Tag> = arrayOf(TextTag(holder, ContentText(text()))) - override fun isTypeParameter(): Boolean = typeParameter + override fun isTypeParameter(): Boolean = isTypeParameter override fun parameterComment(): String = content.toString() // TODO override fun parameterName(): String = parameterName } @@ -103,6 +103,39 @@ class ThrowsTagAdapter(val holder: Doc, val type: ClassDocumentationNodeAdapter) fun buildInlineTags(module: ModuleNodeAdapter, holder: Doc, root: ContentNode): List<Tag> = ArrayList<Tag>().let { buildInlineTags(module, holder, root, it); it } private fun buildInlineTags(module: ModuleNodeAdapter, holder: Doc, node: ContentNode, result: MutableList<Tag>) { + fun surroundWith(module: ModuleNodeAdapter, holder: Doc, prefix: String, postfix: String, node: ContentBlock, result: MutableList<Tag>) { + if (node.children.isNotEmpty()) { + val open = TextTag(holder, ContentText(prefix)) + val close = TextTag(holder, ContentText(postfix)) + + result.add(open) + node.children.forEach { + buildInlineTags(module, holder, it, result) + } + + if (result.last() === open) { + result.remove(result.lastIndex) + } else { + result.add(close) + } + } + } + + fun surroundWith(module: ModuleNodeAdapter, holder: Doc, prefix: String, postfix: String, node: ContentNode, result: MutableList<Tag>) { + if (node !is ContentEmpty) { + val open = TextTag(holder, ContentText(prefix)) + val close = TextTag(holder, ContentText(postfix)) + + result.add(open) + buildInlineTags(module, holder, node, result) + if (result.last() === open) { + result.remove(result.lastIndex) + } else { + result.add(close) + } + } + } + when (node) { is ContentText -> result.add(TextTag(holder, node)) is ContentNodeLink -> { @@ -144,37 +177,4 @@ private fun buildInlineTags(module: ModuleNodeAdapter, holder: Doc, node: Conten else -> result.add(TextTag(holder, ContentText("$node"))) } -} - -fun surroundWith(module: ModuleNodeAdapter, holder: Doc, prefix: String, postfix: String, node: ContentBlock, result: MutableList<Tag>) { - if (node.children.isNotEmpty()) { - val open = TextTag(holder, ContentText(prefix)) - val close = TextTag(holder, ContentText(postfix)) - - result.add(open) - node.children.forEach { - buildInlineTags(module, holder, it, result) - } - - if (result.last() === open) { - result.remove(result.lastIndex) - } else { - result.add(close) - } - } -} - -fun surroundWith(module: ModuleNodeAdapter, holder: Doc, prefix: String, postfix: String, node: ContentNode, result: MutableList<Tag>) { - if (node !is ContentEmpty) { - val open = TextTag(holder, ContentText(prefix)) - val close = TextTag(holder, ContentText(postfix)) - - result.add(open) - buildInlineTags(module, holder, node, result) - if (result.last() === open) { - result.remove(result.lastIndex) - } else { - result.add(close) - } - } }
\ No newline at end of file diff --git a/javadoc/src/main/resources/dokka/format/javadoc.properties b/javadoc/src/main/resources/dokka/format/javadoc.properties new file mode 100644 index 00000000..a58317fc --- /dev/null +++ b/javadoc/src/main/resources/dokka/format/javadoc.properties @@ -0,0 +1 @@ +class=org.jetbrains.dokka.javadoc.JavadocFormatDescriptor
\ No newline at end of file |