aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/parsers/Parser.kt
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2020-10-30 19:01:09 +0100
committerGitHub <noreply@github.com>2020-10-30 19:01:09 +0100
commit1aba0ec4973d7915caa93f1e9b3146ad82111903 (patch)
treeb9424de4bc22f8453ecb32aaa8f7f020bcd49e9f /plugins/base/src/main/kotlin/parsers/Parser.kt
parentda498f50eabfad8969eb7795a535e97f7e25ca58 (diff)
downloaddokka-1aba0ec4973d7915caa93f1e9b3146ad82111903.tar.gz
dokka-1aba0ec4973d7915caa93f1e9b3146ad82111903.tar.bz2
dokka-1aba0ec4973d7915caa93f1e9b3146ad82111903.zip
Fix parsing first word in deprecated (#1595)
Fix parsing first word in `Deprecated` annotations, fix `Throws` and `See` tags
Diffstat (limited to 'plugins/base/src/main/kotlin/parsers/Parser.kt')
-rw-r--r--plugins/base/src/main/kotlin/parsers/Parser.kt77
1 files changed, 37 insertions, 40 deletions
diff --git a/plugins/base/src/main/kotlin/parsers/Parser.kt b/plugins/base/src/main/kotlin/parsers/Parser.kt
index 228cc88b..960d7a64 100644
--- a/plugins/base/src/main/kotlin/parsers/Parser.kt
+++ b/plugins/base/src/main/kotlin/parsers/Parser.kt
@@ -8,47 +8,44 @@ abstract class Parser {
abstract fun preparse(text: String): String
- fun parse(text: String): DocumentationNode {
-
- val list = jkdocToListOfPairs(preparse(text))
-
- val mappedList: List<TagWrapper> = list.map {
- when (it.first) {
- "description" -> Description(parseStringToDocNode(it.second))
- "author" -> Author(parseStringToDocNode(it.second))
- "version" -> Version(parseStringToDocNode(it.second))
- "since" -> Since(parseStringToDocNode(it.second))
- "see" -> See(
- parseStringToDocNode(it.second.substringAfter(' ')),
- it.second.substringBefore(' '),
- null
- )
- "param" -> Param(
- parseStringToDocNode(it.second.substringAfter(' ')),
- it.second.substringBefore(' ')
- )
- "property" -> Property(
- parseStringToDocNode(it.second.substringAfter(' ')),
- it.second.substringBefore(' ')
- )
- "return" -> Return(parseStringToDocNode(it.second))
- "constructor" -> Constructor(parseStringToDocNode(it.second))
- "receiver" -> Receiver(parseStringToDocNode(it.second))
- "throws", "exception" -> Throws(
- parseStringToDocNode(it.second.substringAfter(' ')),
- it.second.substringBefore(' ')
- )
- "deprecated" -> Deprecated(parseStringToDocNode(it.second))
- "sample" -> Sample(
- parseStringToDocNode(it.second.substringAfter(' ')),
- it.second.substringBefore(' ')
- )
- "suppress" -> Suppress(parseStringToDocNode(it.second))
- else -> CustomTagWrapper(parseStringToDocNode(it.second), it.first)
- }
+ open fun parse(text: String): DocumentationNode =
+ DocumentationNode(jkdocToListOfPairs(preparse(text)).map { (tag, content) -> parseTagWithBody(tag, content) })
+
+ open fun parseTagWithBody(tagName: String, content: String): TagWrapper =
+ when (tagName) {
+ "description" -> Description(parseStringToDocNode(content))
+ "author" -> Author(parseStringToDocNode(content))
+ "version" -> Version(parseStringToDocNode(content))
+ "since" -> Since(parseStringToDocNode(content))
+ "see" -> See(
+ parseStringToDocNode(content.substringAfter(' ')),
+ content.substringBefore(' '),
+ null
+ )
+ "param" -> Param(
+ parseStringToDocNode(content.substringAfter(' ')),
+ content.substringBefore(' ')
+ )
+ "property" -> Property(
+ parseStringToDocNode(content.substringAfter(' ')),
+ content.substringBefore(' ')
+ )
+ "return" -> Return(parseStringToDocNode(content))
+ "constructor" -> Constructor(parseStringToDocNode(content))
+ "receiver" -> Receiver(parseStringToDocNode(content))
+ "throws", "exception" -> Throws(
+ parseStringToDocNode(content.substringAfter(' ')),
+ content.substringBefore(' '),
+ null
+ )
+ "deprecated" -> Deprecated(parseStringToDocNode(content))
+ "sample" -> Sample(
+ parseStringToDocNode(content.substringAfter(' ')),
+ content.substringBefore(' ')
+ )
+ "suppress" -> Suppress(parseStringToDocNode(content))
+ else -> CustomTagWrapper(parseStringToDocNode(content), tagName)
}
- return DocumentationNode(mappedList)
- }
private fun jkdocToListOfPairs(javadoc: String): List<Pair<String, String>> =
"description $javadoc"