fixed up the kdoc comments to exclude the * on lines between /** and */
This commit is contained in:
@@ -296,10 +296,32 @@ class KModel(var context: BindingContext, var title: String = "Documentation", v
|
||||
if (node?.getElementType() != JetTokens.DOC_COMMENT) return ""
|
||||
var text = node?.getText() ?: ""
|
||||
// lets remove the comment tokens
|
||||
//val lines = text.trim().split("\\n")
|
||||
text = text.trim().trim("/").trim("*").trim()
|
||||
// TODO convert any macros or wiki text!
|
||||
return text
|
||||
val lines = text.trim().split("\\n")
|
||||
if (lines != null) {
|
||||
// lets remove the /** ... * ... */ tokens
|
||||
val buffer = StringBuilder()
|
||||
val last = lines.size - 1
|
||||
for (i in 0.upto(last)) {
|
||||
var text = lines[i] ?: ""
|
||||
text = text.trim()
|
||||
if (i == 0) {
|
||||
text = text.trimLeading("/**").trimLeading("/*")
|
||||
} else {
|
||||
buffer.append("\n")
|
||||
}
|
||||
if (i >= last) {
|
||||
text = text.trimTrailing("*/")
|
||||
} else if (i > 0) {
|
||||
text = text.trimLeading("* ")
|
||||
if (text == "*") text = ""
|
||||
}
|
||||
buffer.append(text)
|
||||
}
|
||||
// TODO convert any macros or wiki text!
|
||||
return buffer.toString() ?: ""
|
||||
} else {
|
||||
return text
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -26,19 +26,19 @@ inline fun String.trim(text: String) = trimLeading(text).trimTrailing(text)
|
||||
/** Returns the string with the prefix and postfix text trimmed */
|
||||
inline fun String.trim(prefix: String, postfix: String) = trimLeading(prefix).trimTrailing(postfix)
|
||||
|
||||
/** Returns the string with all leading occurrences of the given string removed */
|
||||
/** Returns the string with the leading prefix of this string removed */
|
||||
inline fun String.trimLeading(prefix: String): String {
|
||||
var answer = this
|
||||
while (answer.startsWith(prefix)) {
|
||||
if (answer.startsWith(prefix)) {
|
||||
answer = answer.substring(prefix.length())
|
||||
}
|
||||
return answer
|
||||
}
|
||||
|
||||
/** Returns the string with the all the trailing occurrences of the given string removed */
|
||||
/** Returns the string with the trailing postfix of this string removed */
|
||||
inline fun String.trimTrailing(postfix: String): String {
|
||||
var answer = this
|
||||
while (answer.endsWith(postfix)) {
|
||||
if (answer.endsWith(postfix)) {
|
||||
answer = answer.substring(0, length() - postfix.length())
|
||||
}
|
||||
return answer
|
||||
|
||||
Reference in New Issue
Block a user