diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-15 16:38:25 +0400 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-15 16:38:25 +0400 |
commit | 76e5d70c3e383bfaae688e8308d6dce6ba63f618 (patch) | |
tree | 16e5828840302e7d785710436aeedbda277c1fcc /src | |
parent | 50ec3299734dd2f38ff996de483ce6c345f55d28 (diff) | |
download | dokka-76e5d70c3e383bfaae688e8308d6dce6ba63f618.tar.gz dokka-76e5d70c3e383bfaae688e8308d6dce6ba63f618.tar.bz2 dokka-76e5d70c3e383bfaae688e8308d6dce6ba63f618.zip |
Cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/Generation/FileGenerator.kt | 2 | ||||
-rw-r--r-- | src/Generation/JavaSignatureGenerator.kt | 148 | ||||
-rw-r--r-- | src/Generation/KotlinSignatureGenerator.kt | 167 | ||||
-rw-r--r-- | src/Generation/SignatureGenerator.kt | 17 |
4 files changed, 1 insertions, 333 deletions
diff --git a/src/Generation/FileGenerator.kt b/src/Generation/FileGenerator.kt index dbd631cb..5221c400 100644 --- a/src/Generation/FileGenerator.kt +++ b/src/Generation/FileGenerator.kt @@ -26,7 +26,7 @@ public class FileGenerator(val signatureGenerator: LanguageService, public fun buildOutlines(nodes: Iterable<DocumentationNode>) { for ((location, items) in nodes.groupByTo(LinkedHashMap()) { locationService.location(it) }) { - val file = location.file.appendExtension("yml") + val file = location.file.appendExtension("yml") // TODO: hardcoded file.getParentFile()?.mkdirs() FileOutputStream(file).use { OutputStreamWriter(it, defaultCharset).use { diff --git a/src/Generation/JavaSignatureGenerator.kt b/src/Generation/JavaSignatureGenerator.kt deleted file mode 100644 index 01e51d74..00000000 --- a/src/Generation/JavaSignatureGenerator.kt +++ /dev/null @@ -1,148 +0,0 @@ -package org.jetbrains.dokka - -import org.jetbrains.dokka.DocumentationNode.* - -class JavaSignatureGenerator : SignatureGenerator { - override fun render(node: DocumentationNode): String { - return when (node.kind) { - Kind.Package -> renderPackage(node) - Kind.Class, - Kind.Interface, - Kind.Enum, - Kind.EnumItem, - Kind.Object -> renderClass(node) - - Kind.TypeParameter -> renderTypeParameter(node) - Kind.Type, - Kind.UpperBound -> renderType(node) - - Kind.Constructor, - Kind.Function -> renderFunction(node) - Kind.Property -> renderProperty(node) - else -> "${node.kind}: ${node.name}" - } - } - - override fun renderName(node: DocumentationNode): String { - return when (node.kind) { - Kind.Constructor -> node.owner!!.name - else -> node.name - } - } - - override fun renderPackage(node: DocumentationNode): String { - return "package ${node.name}" - } - - override fun renderModifier(node: DocumentationNode): String { - return when (node.name) { - "open" -> "" - "internal" -> "" - else -> node.name - } - } - - override fun renderType(node: DocumentationNode): String { - return when (node.name) { - "Unit" -> "void" - "Int" -> "int" - "Long" -> "long" - "Double" -> "double" - "Float" -> "float" - "Char" -> "char" - "Boolean" -> "bool" - // TODO: render arrays - else -> node.name - } - } - - override fun renderTypeParameter(node: DocumentationNode): String { - val constraints = node.details(Kind.UpperBound) - return if (constraints.none()) - node.name - else { - node.name + " extends " + constraints.map { renderType(node) }.join() - } - } - - override fun renderParameter(node: DocumentationNode): String { - return "${renderType(node.detail(Kind.Type))} ${node.name}" - } - - override fun renderTypeParametersForNode(node: DocumentationNode): String { - return StringBuilder { - val typeParameters = node.details(Kind.TypeParameter) - if (typeParameters.any()) { - append("<") - append(typeParameters.map { renderTypeParameter(it) }.join()) - append("> ") - } - }.toString() - } - - override fun renderModifiersForNode(node: DocumentationNode): String { - val modifiers = node.details(Kind.Modifier).map { renderModifier(it) }.filter { it != "" } - if (modifiers.none()) - return "" - return modifiers.join(" ", postfix = " ") - } - - override fun renderClass(node: DocumentationNode): String { - return StringBuilder { - when (node.kind) { - Kind.Class -> append("class ") - Kind.Interface -> append("interface ") - Kind.Enum -> append("enum ") - Kind.EnumItem -> append("enum value ") - Kind.Object -> append("class ") - else -> throw IllegalArgumentException("Node $node is not a class-like object") - } - - append(node.name) - append(renderTypeParametersForNode(node)) - }.toString() - } - - override fun renderFunction(node: DocumentationNode): String { - return StringBuilder { - when (node.kind) { - Kind.Constructor -> append(node.owner?.name) - Kind.Function -> { - append(renderTypeParametersForNode(node)) - append(renderType(node.detail(Kind.Type))) - append(" ") - append(node.name) - } - else -> throw IllegalArgumentException("Node $node is not a function-like object") - } - - val receiver = node.details(Kind.Receiver).firstOrNull() // TODO: replace with singleOrNull when fixed - append("(") - if (receiver != null) - append((listOf(receiver) + node.details(Kind.Parameter)).map { renderParameter(it) }.join()) - else - append(node.details(Kind.Parameter).map { renderParameter(it) }.join()) - - append(")") - }.toString() - } - - override fun renderProperty(node: DocumentationNode): String { - return StringBuilder { - when (node.kind) { - Kind.Property -> append("val ") - else -> throw IllegalArgumentException("Node $node is not a property") - } - append(renderTypeParametersForNode(node)) - val receiver = node.details(Kind.Receiver).firstOrNull() // TODO: replace with singleOrNull when fixed - if (receiver != null) { - append(renderType(receiver.detail(Kind.Type))) - append(".") - } - - append(node.name) - append(": ") - append(renderType(node.detail(Kind.Type))) - }.toString() - } -}
\ No newline at end of file diff --git a/src/Generation/KotlinSignatureGenerator.kt b/src/Generation/KotlinSignatureGenerator.kt deleted file mode 100644 index 6bdf9562..00000000 --- a/src/Generation/KotlinSignatureGenerator.kt +++ /dev/null @@ -1,167 +0,0 @@ -package org.jetbrains.dokka - -import org.jetbrains.dokka.DocumentationNode.* - -class KotlinSignatureGenerator : SignatureGenerator { - override fun render(node: DocumentationNode): String { - return when (node.kind) { - Kind.Package -> renderPackage(node) - Kind.Class, - Kind.Interface, - Kind.Enum, - Kind.EnumItem, - Kind.Object -> renderClass(node) - - Kind.TypeParameter -> renderTypeParameter(node) - Kind.Type, - Kind.UpperBound -> renderType(node) - - Kind.Modifier -> renderModifier(node) - Kind.Constructor, - Kind.Function -> renderFunction(node) - Kind.Property -> renderProperty(node) - else -> "${node.kind}: ${node.name}" - } - } - - override fun renderName(node: DocumentationNode): String { - return when (node.kind) { - Kind.Constructor -> node.owner!!.name - else -> node.name - } - } - - override fun renderPackage(node: DocumentationNode): String { - return "package ${node.name}" - } - - override fun renderType(node: DocumentationNode): String { - val typeArguments = node.details(Kind.Type) - val renders = typeArguments.map { renderType(it) } - - if (node.name == "Function${typeArguments.count() - 1}") { - // lambda - return "(${renders.take(renders.size - 1).join()})->${renders.last()}" - } - if (node.name == "ExtensionFunction${typeArguments.count() - 2}") { - // extension lambda - return "${renders.first()}.(${renders.drop(1).take(renders.size - 2).join()})->${renders.last()}" - } - if (typeArguments.none()) - return node.name - return "${node.name}<${renders.join()}>" - } - - override fun renderModifier(node: DocumentationNode): String { - return when (node.name) { - "final" -> "" - "internal" -> "" - else -> node.name - } - } - - override fun renderTypeParameter(node: DocumentationNode): String { - val constraints = node.details(Kind.UpperBound) - return if (constraints.none()) - node.name - else { - node.name + " : " + constraints.map { renderType(node) }.join() - } - } - - override fun renderParameter(node: DocumentationNode): String { - return node.name + ": " + renderType(node.detail(Kind.Type)) - } - - override fun renderTypeParametersForNode(node: DocumentationNode): String { - return StringBuilder { - val typeParameters = node.details(Kind.TypeParameter) - if (typeParameters.any()) { - append("<") - append(typeParameters.map { renderTypeParameter(it) }.join()) - append("> ") - } - }.toString() - } - - override fun renderModifiersForNode(node: DocumentationNode): String { - val modifiers = node.details(Kind.Modifier).map { renderModifier(it) }.filter { it != "" } - if (modifiers.none()) - return "" - return modifiers.join(" ", postfix = " ") - } - - override fun renderClass(node: DocumentationNode): String { - return StringBuilder { - append(renderModifiersForNode(node)) - when (node.kind) { - Kind.Class -> append("class ") - Kind.Interface -> append("trait ") - Kind.Enum -> append("enum class ") - Kind.EnumItem -> append("enum val ") - Kind.Object -> append("object ") - else -> throw IllegalArgumentException("Node $node is not a class-like object") - } - - append(node.name) - append(renderTypeParametersForNode(node)) - - /* - val constructors = node.members(Kind.Constructor) - if (constructors.count() == 1) { - append("(") - append(constructors[0].details(Kind.Parameter).map { renderParameter(it) }.join()) - append(")") - } - */ - }.toString() - } - - override fun renderFunction(node: DocumentationNode): String { - return StringBuilder { - append(renderModifiersForNode(node)) - when (node.kind) { - Kind.Constructor -> append(node.owner!!.name) - Kind.Function -> append("fun ") - else -> throw IllegalArgumentException("Node $node is not a function-like object") - } - append(renderTypeParametersForNode(node)) - val receiver = node.details(Kind.Receiver).firstOrNull() // TODO: replace with singleOrNull when fixed - if (receiver != null) { - append(renderType(receiver.detail(Kind.Type))) - append(".") - } - - if (node.kind != Kind.Constructor) - append(node.name) - - append("(") - append(node.details(Kind.Parameter).map { renderParameter(it) }.join()) - append(")") - if (node.kind != Kind.Constructor) { - append(": ") - append(renderType(node.detail(Kind.Type))) - } - }.toString() - } - - override fun renderProperty(node: DocumentationNode): String { - return StringBuilder { - append(renderModifiersForNode(node)) - when (node.kind) { - Kind.Property -> append("val ") - else -> throw IllegalArgumentException("Node $node is not a property") - } - append(renderTypeParametersForNode(node)) - val receiver = node.details(Kind.Receiver).firstOrNull() // TODO: replace with singleOrNull when fixed - if (receiver != null) { - append(renderType(receiver.detail(Kind.Type))) - append(".") - } - - append(node.name) - append(": ") - append(renderType(node.detail(Kind.Type))) - }.toString() - } -}
\ No newline at end of file diff --git a/src/Generation/SignatureGenerator.kt b/src/Generation/SignatureGenerator.kt deleted file mode 100644 index 81302433..00000000 --- a/src/Generation/SignatureGenerator.kt +++ /dev/null @@ -1,17 +0,0 @@ -package org.jetbrains.dokka - -trait SignatureGenerator { - fun render(node: DocumentationNode): String - fun renderName(node: DocumentationNode): String - fun renderFunction(node: DocumentationNode): String - fun renderClass(node: DocumentationNode): String - fun renderTypeParametersForNode(node: DocumentationNode): String - fun renderTypeParameter(node: DocumentationNode): String - fun renderParameter(node: DocumentationNode): String - fun renderType(node: DocumentationNode): String - fun renderPackage(node: DocumentationNode): String - fun renderProperty(node: DocumentationNode): String - fun renderModifier(node: DocumentationNode): String - fun renderModifiersForNode(node: DocumentationNode): String -} - |