Doc templating: name things properly

This commit is contained in:
Ilya Gorbunov
2015-10-30 21:05:40 +03:00
parent cb79aadb9d
commit f9bfeb0f32
2 changed files with 18 additions and 18 deletions
@@ -14,10 +14,8 @@ object DocExtensions {
val Family.collection: String
get() = when (this) {
CharSequences -> "char sequence"
Strings -> "string"
Sequences -> "sequence"
Maps -> "map"
ArraysOfObjects, ArraysOfPrimitives, InvariantArraysOfObjects -> "array"
Strings, Sequences, Maps, Lists, Sets, Ranges -> name.singularize().decapitalize()
else -> "collection"
}
@@ -27,6 +25,8 @@ object DocExtensions {
else -> "list"
}
private fun String.singularize() = removeSuffix("s")
fun String.prefixWithArticle() = (if ("aeiou".any { this.startsWith(it, ignoreCase = true) }) "an " else "a ").concat(this)
}