From 716483c2f20e4af1951342f2acc9a231fcbeab3b Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 30 Dec 2014 17:41:14 +0100 Subject: render annotation classes correctly --- src/Formats/StructuredFormatService.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Formats') diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 2d326854..b75f39d1 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -188,7 +188,8 @@ public abstract class StructuredFormatService(val locationService: LocationServi DocumentationNode.Kind.Class, DocumentationNode.Kind.Interface, DocumentationNode.Kind.Enum, - DocumentationNode.Kind.Object) + DocumentationNode.Kind.Object, + DocumentationNode.Kind.AnnotationClass) }, node, to) appendSection(location, "Constructors", node.members(DocumentationNode.Kind.Constructor), node, to) appendSection(location, "Properties", node.members(DocumentationNode.Kind.Property), node, to) @@ -200,7 +201,9 @@ public abstract class StructuredFormatService(val locationService: LocationServi it.kind !in setOf( DocumentationNode.Kind.Class, DocumentationNode.Kind.Interface, + DocumentationNode.Kind.Enum, DocumentationNode.Kind.Object, + DocumentationNode.Kind.AnnotationClass, DocumentationNode.Kind.Constructor, DocumentationNode.Kind.Property, DocumentationNode.Kind.Package, -- cgit From 7fbff24a81a7bcc453e1c4e30acdcf7b38c68265 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 9 Jan 2015 18:54:06 +0100 Subject: use JUnit for compares; avoid generating trailing whitespace in markdown --- src/Formats/MarkdownFormatService.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Formats') diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt index 96f64eec..38fadf7a 100644 --- a/src/Formats/MarkdownFormatService.kt +++ b/src/Formats/MarkdownFormatService.kt @@ -106,14 +106,15 @@ public open class MarkdownFormatService(locationService: LocationService, } override fun appendTableRow(to: StringBuilder, body: () -> Unit) { - to.append("| ") + to.append("|") body() to.appendln() } override fun appendTableCell(to: StringBuilder, body: () -> Unit) { + to.append(" ") body() - to.append(" | ") + to.append(" |") } var outlineLevel = 0 -- cgit From 4b0dcee83efbdb77ae5e389ee04c309c52446153 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 9 Jan 2015 19:48:44 +0100 Subject: generate ExternalClass nodes to hold extension functions and properties for classes from other packages --- src/Formats/StructuredFormatService.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Formats') diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index b75f39d1..cb510f80 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -178,10 +178,15 @@ public abstract class StructuredFormatService(val locationService: LocationServi for ((breadcrumbs, items) in breakdownByLocation) { appendLine(to, breadcrumbs) appendLine(to) - appendLocation(location, to, items) + appendLocation(location, to, items.filter { it.kind != DocumentationNode.Kind.ExternalClass }) } for (node in nodes) { + if (node.kind == DocumentationNode.Kind.ExternalClass) { + appendSection(location, "Extensions for ${node.name}", node.members, node, to) + continue + } + appendSection(location, "Packages", node.members(DocumentationNode.Kind.Package), node, to) appendSection(location, "Types", node.members.filter { it.kind in setOf( @@ -191,6 +196,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi DocumentationNode.Kind.Object, DocumentationNode.Kind.AnnotationClass) }, node, to) + appendSection(location, "Extensions for External Classes", node.members(DocumentationNode.Kind.ExternalClass), node, to) appendSection(location, "Constructors", node.members(DocumentationNode.Kind.Constructor), node, to) appendSection(location, "Properties", node.members(DocumentationNode.Kind.Property), node, to) appendSection(location, "Functions", node.members(DocumentationNode.Kind.Function), node, to) @@ -210,7 +216,8 @@ public abstract class StructuredFormatService(val locationService: LocationServi DocumentationNode.Kind.Function, DocumentationNode.Kind.PropertyAccessor, DocumentationNode.Kind.ClassObjectProperty, - DocumentationNode.Kind.ClassObjectFunction + DocumentationNode.Kind.ClassObjectFunction, + DocumentationNode.Kind.ExternalClass ) }, node, to) appendSection(location, "Extensions", node.extensions, node, to) -- cgit From e17eaa5fbc296bab0f32e8169d50fea06a6de581 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 9 Jan 2015 20:59:58 +0100 Subject: nice rendering for deprecated members --- src/Formats/HtmlFormatService.kt | 4 ++++ src/Formats/MarkdownFormatService.kt | 4 ++++ src/Formats/StructuredFormatService.kt | 14 ++++++++++++++ 3 files changed, 22 insertions(+) (limited to 'src/Formats') diff --git a/src/Formats/HtmlFormatService.kt b/src/Formats/HtmlFormatService.kt index b23e4a45..f76693dc 100644 --- a/src/Formats/HtmlFormatService.kt +++ b/src/Formats/HtmlFormatService.kt @@ -93,6 +93,10 @@ public open class HtmlFormatService(locationService: LocationService, return "${text}" } + override fun formatStrikethrough(text: String): String { + return "${text}" + } + override fun formatCode(code: String): String { return "${code}" } diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt index 38fadf7a..a2e3ce55 100644 --- a/src/Formats/MarkdownFormatService.kt +++ b/src/Formats/MarkdownFormatService.kt @@ -46,6 +46,10 @@ public open class MarkdownFormatService(locationService: LocationService, return "*$text*" } + override fun formatStrikethrough(text: String): String { + return "~~$text~~" + } + override public fun formatLink(text: String, location: Location): String { return "[$text](${location.path})" } diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index cb510f80..51222ffb 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -1,6 +1,7 @@ package org.jetbrains.dokka import java.util.LinkedHashMap +import com.intellij.openapi.util.text.StringUtil public data class FormatLink(val text: String, val location: Location) @@ -28,6 +29,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi public abstract fun formatLink(text: String, href: String): String public open fun formatLink(link: FormatLink): String = formatLink(formatText(link.text), link.location) public abstract fun formatStrong(text: String): String + public abstract fun formatStrikethrough(text: String): String public abstract fun formatEmphasis(text: String): String public abstract fun formatCode(code: String): String public abstract fun formatList(text: String): String @@ -46,6 +48,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi is ContentKeyword -> append(formatKeyword(content.text)) is ContentIdentifier -> append(formatIdentifier(content.text)) is ContentStrong -> append(formatStrong(formatText(location, content.children))) + is ContentStrikethrough -> append(formatStrikethrough(formatText(location, content.children))) is ContentCode -> append(formatCode(formatText(location, content.children))) is ContentEmphasis -> append(formatEmphasis(formatText(location, content.children))) is ContentList -> append(formatList(formatText(location, content.children))) @@ -116,6 +119,17 @@ public abstract class StructuredFormatService(val locationService: LocationServi for ((summary, items) in breakdownBySummary) { items.forEach { appendBlockCode(to, formatText(location, languageService.render(it))) + val deprecation = it.deprecation + if (deprecation != null) { + val deprecationParameter = deprecation.details(DocumentationNode.Kind.Parameter).firstOrNull() + val deprecationValue = deprecationParameter?.details(DocumentationNode.Kind.Value)?.firstOrNull() + if (deprecationValue != null) { + to.append(formatStrong("Deprecated: ")) + appendLine(to, formatText(StringUtil.unquoteString(deprecationValue.name))) + } else { + appendLine(to, formatStrong("Deprecated")) + } + } } appendLine(to, summary) appendLine(to) -- cgit From c5fc45ce7d8f83042420fa992aa9fc23efb0f555 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 12 Jan 2015 13:25:58 +0100 Subject: code review --- src/Formats/StructuredFormatService.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/Formats') diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 51222ffb..0301543c 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -1,7 +1,6 @@ package org.jetbrains.dokka import java.util.LinkedHashMap -import com.intellij.openapi.util.text.StringUtil public data class FormatLink(val text: String, val location: Location) @@ -125,7 +124,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi val deprecationValue = deprecationParameter?.details(DocumentationNode.Kind.Value)?.firstOrNull() if (deprecationValue != null) { to.append(formatStrong("Deprecated: ")) - appendLine(to, formatText(StringUtil.unquoteString(deprecationValue.name))) + appendLine(to, formatText(deprecationValue.name.substring(0, deprecationValue.name.length()-1))) } else { appendLine(to, formatStrong("Deprecated")) } -- cgit From 23af5e2540aca25ab64deec1821a069f827d7c77 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 12 Jan 2015 15:57:04 +0100 Subject: use .trim() instead of .substring() --- src/Formats/StructuredFormatService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Formats') diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 0301543c..977d81d0 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -124,7 +124,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi val deprecationValue = deprecationParameter?.details(DocumentationNode.Kind.Value)?.firstOrNull() if (deprecationValue != null) { to.append(formatStrong("Deprecated: ")) - appendLine(to, formatText(deprecationValue.name.substring(0, deprecationValue.name.length()-1))) + appendLine(to, formatText(deprecationValue.name.trim("\""))) } else { appendLine(to, formatStrong("Deprecated")) } -- cgit