diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Formats/HtmlFormatService.kt | 2 | ||||
-rw-r--r-- | src/Formats/KotlinWebsiteFormatService.kt | 11 | ||||
-rw-r--r-- | src/Formats/MarkdownFormatService.kt | 2 | ||||
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 4 | ||||
-rw-r--r-- | src/Kotlin/KotlinLanguageService.kt | 6 | ||||
-rw-r--r-- | src/Model/Content.kt | 11 |
6 files changed, 24 insertions, 12 deletions
diff --git a/src/Formats/HtmlFormatService.kt b/src/Formats/HtmlFormatService.kt index a3cea96a..fee21738 100644 --- a/src/Formats/HtmlFormatService.kt +++ b/src/Formats/HtmlFormatService.kt @@ -18,7 +18,7 @@ public open class HtmlFormatService(locationService: LocationService, return "<span class=\"keyword\">${formatText(text)}</span>" } - override fun formatIdentifier(text: String): String { + override fun formatIdentifier(text: String, kind: IdentifierKind): String { return "<span class=\"identifier\">${formatText(text)}</span>" } diff --git a/src/Formats/KotlinWebsiteFormatService.kt b/src/Formats/KotlinWebsiteFormatService.kt index a009132b..01df0501 100644 --- a/src/Formats/KotlinWebsiteFormatService.kt +++ b/src/Formats/KotlinWebsiteFormatService.kt @@ -81,7 +81,12 @@ public class KotlinWebsiteFormatService(locationService: LocationService, return "<span class=\"keyword\">${formatText(text)}</span>" } - override fun formatIdentifier(text: String): String { - return "<span class=\"identifier\">${formatText(text)}</span>" + override fun formatIdentifier(text: String, kind: IdentifierKind): String { + return "<span class=\"${identifierClassName(kind)}\">${formatText(text)}</span>" } -}
\ No newline at end of file + + private fun identifierClassName(kind: IdentifierKind) = when(kind) { + IdentifierKind.ParameterName -> "parameterName" + else -> "identifier" + } +} diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt index c3f4f469..cc7d7170 100644 --- a/src/Formats/MarkdownFormatService.kt +++ b/src/Formats/MarkdownFormatService.kt @@ -19,7 +19,7 @@ public open class MarkdownFormatService(locationService: LocationService, override fun formatKeyword(text: String): String { return text.htmlEscape() } - override fun formatIdentifier(text: String): String { + override fun formatIdentifier(text: String, kind: IdentifierKind): String { return text.htmlEscape() } diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index dd23b7b3..be647e49 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -26,7 +26,7 @@ public abstract class StructuredFormatService(locationService: LocationService, public abstract fun formatText(text: String): String public abstract fun formatSymbol(text: String): String public abstract fun formatKeyword(text: String): String - public abstract fun formatIdentifier(text: String): String + public abstract fun formatIdentifier(text: String, kind: IdentifierKind): String public abstract fun formatLink(text: String, href: String): String public open fun formatLink(link: FormatLink): String = formatLink(formatText(link.text), link.href) public abstract fun formatStrong(text: String): String @@ -48,7 +48,7 @@ public abstract class StructuredFormatService(locationService: LocationService, is ContentText -> append(formatText(content.text)) is ContentSymbol -> append(formatSymbol(content.text)) is ContentKeyword -> append(formatKeyword(content.text)) - is ContentIdentifier -> append(formatIdentifier(content.text)) + is ContentIdentifier -> append(formatIdentifier(content.text, content.kind)) is ContentNonBreakingSpace -> append(formatNonBreakingSpace()) is ContentStrong -> append(formatStrong(formatText(location, content.children))) is ContentStrikethrough -> append(formatStrikethrough(formatText(location, content.children))) diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt index fd31988d..439ef174 100644 --- a/src/Kotlin/KotlinLanguageService.kt +++ b/src/Kotlin/KotlinLanguageService.kt @@ -106,7 +106,7 @@ class KotlinLanguageService : LanguageService { return } renderSingleModifier(node) - renderLinked(node) { identifier(it.name) } + renderLinked(node) { identifier(it.name, IdentifierKind.TypeName) } if (typeArguments.any()) { symbol("<") renderList(typeArguments, noWrap = true) { @@ -152,7 +152,7 @@ class KotlinLanguageService : LanguageService { private fun ContentBlock.renderParameter(node: DocumentationNode) { renderAnnotationsForNode(node) - identifier(node.name) + identifier(node.name, IdentifierKind.ParameterName) symbol(":") nbsp() val parameterType = node.detail(DocumentationNode.Kind.Type) @@ -208,7 +208,7 @@ class KotlinLanguageService : LanguageService { } private fun ContentBlock.renderAnnotation(node: DocumentationNode) { - identifier(node.name) + identifier(node.name, IdentifierKind.AnnotationName) val parameters = node.details(DocumentationNode.Kind.Parameter) if (!parameters.isEmpty()) { symbol("(") diff --git a/src/Model/Content.kt b/src/Model/Content.kt index ca5dd49b..d343c648 100644 --- a/src/Model/Content.kt +++ b/src/Model/Content.kt @@ -26,9 +26,16 @@ public open class ContentBlock() : ContentNode() { children.hashCode() } +enum class IdentifierKind { + TypeName + ParameterName + AnnotationName + Other +} + public data class ContentText(val text: String) : ContentNode() public data class ContentKeyword(val text: String) : ContentNode() -public data class ContentIdentifier(val text: String) : ContentNode() +public data class ContentIdentifier(val text: String, val kind: IdentifierKind = IdentifierKind.Other) : ContentNode() public data class ContentSymbol(val text: String) : ContentNode() public object ContentNonBreakingSpace: ContentNode() @@ -89,7 +96,7 @@ fun content(body: ContentBlock.() -> Unit): ContentBlock { fun ContentBlock.text(value: String) = append(ContentText(value)) fun ContentBlock.keyword(value: String) = append(ContentKeyword(value)) fun ContentBlock.symbol(value: String) = append(ContentSymbol(value)) -fun ContentBlock.identifier(value: String) = append(ContentIdentifier(value)) +fun ContentBlock.identifier(value: String, kind: IdentifierKind = IdentifierKind.Other) = append(ContentIdentifier(value, kind)) fun ContentBlock.nbsp() = append(ContentNonBreakingSpace) fun ContentBlock.link(to: DocumentationNode, body: ContentBlock.() -> Unit) { |